[Feature Request]Duration of Animation

Discussion and feedback on Construct 2

Post » Mon Apr 08, 2013 11:39 am

This is the trouble I've been having: http://www.scirra.com/forum/topic66077.html

It's all around coming up with ways to just tell Construct 2 to play a looping animation for a set amount of time and then do something.

But because the animation is never 'finished', the event trigger On Animation Finished cannot be used. So the event trigger Is Playing is used. Which then seems to cause it to go into an eternal loop because the animation is always 'Is Playing', and using system wait doesn't seem to stop it and make it go to the next action.

I've tried using various plugins and behaviors from Rex, but none work.

I just would like a native Duration feature that can be called in the event sheet that works correctly with looping/ping-pong animations.
Create HTML5 games
B
10
S
1
Posts: 27
Reputation: 697

Post » Mon Apr 08, 2013 3:09 pm

A looping animation has an infinite duration, so how does that help?

Animation speeds are in frames per second, so as long as you don't change the individual frame times, the duration for playing through once is number of frames / animation speed. E.g. 10 frames at 5 frames per second = 10 / 5 = 2 seconds duration.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Mon Apr 08, 2013 3:15 pm

I set a looping animation for something like an idle animation. The idea is to have the sprite play it for a set amount of time that can be controlled by the event sheet.

For example, you have a head swaying idle animation. It's on a loop/ping-pong. Assume you already don't care about clipping or made it so it doesn't matter.

You set up an event to have that animation play for random(4) seconds or something similar.

Therefore, the duration of that idle animation lasts for a random amount of time each time that animation would play.

Basically, I don't care about the full length of the animation at all, because it was made to repeat and be clipped. I just want to control how long it stays on-screen regardless of its own length.
Create HTML5 games
B
10
S
1
Posts: 27
Reputation: 697

Post » Tue Apr 09, 2013 8:19 am

On top of my head: each animation has frame numbers. What about instead of random time, you get a random repeat number and then a random frame number. Then count each animation loop and increase them until they reach your target?

For example: get a random repeat number between 2 and 4. (say you got 4)
Then get a random frame number between 0 and 12 (say you get 8)

also get current repeat global variable.

increase current repeat every time animation plays 8
then have a condition that checks current repeat = randomly got repeat number (for our example it was 4) and if true, stop the animation or do sth else.

I hope I could explain it, English is not my main.

Regards;
B
16
S
4
G
1
Posts: 332
Reputation: 3,016

Post » Tue Apr 09, 2013 8:37 am

[QUOTE=Byakko]
It's all around coming up with ways to just tell Construct 2 to play a looping animation for a set amount of time and then do something.
[/QUOTE]

You could achieve this pretty easily with timer variable of your own.

Create instance variables idleDuration and animationTimer for your sprite.

Then do events something like this:

every tick
..add dt to sprite.animationTimer

on animation 'Idle' started
.. set animationTimer to 0

animationTimer > idleDuration
.. animation 'Idle' is playing
.... do the stuff you want to do at the end of your idle animation
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Apr 09, 2013 8:41 am

Well the animation editor has a Repeat count/Repeat to property. If they can be controlled by the event sheet, it would solve a lot of problems. But I don't think it's possible?

Edit: I eventually found a workaround that gets almost the same effect. But thanks, I'll try that when I get back to working on them.

The thing is I tried rex's Duration and Timer plugins, which theoretically should work, but still caused this weird error where my Deer started headbanging erratically and the speed of the animations started going out of whack. As in, they were exceeding the speed I placed in their animation properties.

I have no idea if it was because of some severe event conflict, or I found some kind of bug. It looked like it had something to do with using the 'Is animation playing' event with a looping animation and the action is "Wait X seconds"Byakko2013-04-09 08:49:37
Create HTML5 games
B
10
S
1
Posts: 27
Reputation: 697

Post » Tue Apr 09, 2013 11:19 am

Here is an example that uses technique a little bit like the solution I mentioned before:

Animation stuff
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Tue Apr 09, 2013 11:06 pm

You can simple modify the "repeat count" on the event sheet or configure it when inside the image editor, it will loop the number of times your configured inside the repeat count.

also, don't forget to configure the event to "trigger once while true"...
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,190
Reputation: 18,272

Post » Wed Apr 10, 2013 4:48 am

I can't find a way to manipulate the 'repeat count' of an image in the event sheet, except as just repeating one animation loop. Unless I can set "random(x,y)" in the image editor?

However, thank you for the "Trigger once while/when true" special condition! That was exactly what I was looking for! Since the looping animations I were using were 'always true' which was the problem! I needed this system condition to tell it to count only the moment the animation starts!

So yeah, all working as intended now!
Create HTML5 games
B
10
S
1
Posts: 27
Reputation: 697


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 10 guests