How do I play animation on instace at random intervals?

Get help using Construct 2

Post » Wed Dec 17, 2014 10:14 pm

Hi there

I have sprite called Tree, that has animation TreeA, TreeB... etc with different trees moving in the wind. Now I would like this animation play in random intervals for each animation...

When the animation is looping it loops infinitely and stop command stops all instances with ether of the animations.
When animation is not looping it doesn't seems to respond to start command, just the looping ones seems to randomly restart from beginning.

What I would like:
is Tree on screen
is Tree Animation TreeA finished?
is Random interval 0? (or wait(random(5))
Then start Animation TreeA from beginning.

Thanks for advice.
B
12
S
2
Posts: 37
Reputation: 707

Post » Thu Dec 18, 2014 3:54 am

set a global variable called treeAnimation = 0
set a global variable called treeIsPlaying = 0


now set up a condition for each animation TreeA
ad the global variable treeAnimation = 1 to that animation condition
ad the global variable treeIsPlaying = 1 to that animation condition
(Action) set treeIsPlaying = 0 after animation


now set up a condition for each animation TreeB
ad the global variable treeAnimation = 1 to that animation condition
ad the global variable treeIsPlaying = 1 to that animation condition
(Action) set treeIsPlaying = 0 after animation

Now you can every tic set variable = int(random(1,2))
ad the global variable treeIsPlaying = 0 to that animation condition
B
8
S
1
Posts: 74
Reputation: 725

Post » Thu Dec 18, 2014 5:58 am

mordiaky wrote:now set up a condition for each animation TreeA
ad the global variable treeAnimation = 1 to that animation condition
ad the global variable treeIsPlaying = 1 to that animation condition
(Action) set treeIsPlaying = 0 after animation


So that means I will have to split it to multiple sprites for each tree animation. Because right now I have only one sprite for all Trees and other for all Grasses.
B
12
S
2
Posts: 37
Reputation: 707

Post » Fri Dec 19, 2014 12:01 am

no you can call the animation
B
8
S
1
Posts: 74
Reputation: 725

Post » Fri Dec 19, 2014 3:11 am

Use the timer object and smartly name your animations....
You do not have the required permissions to view the files attached to this post.
A big fan of JavaScript.
B
74
S
20
G
71
Posts: 2,228
Reputation: 44,888


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 24 guests