Picking random animation frames?

Get help using Construct 2

Post » Wed Feb 19, 2014 1:24 am

Hello,

I've been trying to get random objects to spawn in an endless jumper type template, by spawning it at a random frame.

I used this expression:

Sprite   | Set animation frame to int(random(3))

to test out the first 4 objects, but it doesn't work. It doesn't even show the frame 0 sprite, but it spawns frame 3 every time. I've also tried changing the random value to (random(0,3)) in case it was a range, but that also spawns the last frame constantly. Changing the initial frame of the animation also has no effect.

Any ideas?
Cheers!
B
5
G
1
Posts: 22
Reputation: 467

Post » Wed Feb 19, 2014 1:54 am

Set the animation speed of that animation to 0.
Open up the image editor, at the properties panel on the left. set animation speed to 0.

It will stop the animation from playing.
B
17
S
8
G
4
Posts: 93
Reputation: 3,190

Post » Wed Feb 19, 2014 2:09 am

Thanks for the reply, but that didn't seem to work.

Here's a .capx with the broken mechanic:

https://www.dropbox.com/s/y6yii2dbbb1q4hd/EndlessExample.capx
B
5
G
1
Posts: 22
Reputation: 467

Post » Wed Feb 19, 2014 4:02 am

I made the following changes to your capx.
1)Set the animation speed of "objects" to 0.
2)On start of layout, set "objects" bullet angle to 180.
3)On create "objects", set animation frame to floor(random(Objects.animationframecount))

https://www.dropbox.com/s/0v0j0l3spfcfdt6/EndlessExample%28Allbrotnar%29.capx
B
17
S
8
G
4
Posts: 93
Reputation: 3,190

Post » Wed Feb 19, 2014 11:20 am

Excellent, thanks very much!
B
5
G
1
Posts: 22
Reputation: 467


Return to How do I....?

Who is online

Users browsing this forum: David181, yiuyiu6666, zenox98 and 24 guests