How do I select a random animation frame?

Get help using Construct 2

Post » Thu Sep 10, 2015 11:18 am

All I need to know is how to select a random animation frame. I have the animation speed set to 0.

Help would be appreciated, thanks!
B
5
S
1
Posts: 37
Reputation: 463

Post » Thu Sep 10, 2015 12:00 pm

There is a "Set frame" action on sprites.

Set frame
Set the current zero-based animation frame number that is showing. The animation will continue to play at its current speed.
B
10
S
2
G
1
Posts: 51
Reputation: 761

Post » Thu Sep 10, 2015 12:01 pm

I don´t have C2 around currently, but you could set the animation frame to "int(random(x))". That generates a random number between 0 and X.
B
16
S
3
Posts: 69
Reputation: 1,048

Post » Thu Sep 10, 2015 12:08 pm

Thanks it works a treat
B
5
S
1
Posts: 37
Reputation: 463

Post » Thu Sep 10, 2015 1:54 pm

WackyToaster wrote:I don´t have C2 around currently, but you could set the animation frame to "int(random(x))". That generates a random number between 0 and X.


"int(random(x))" will generate a random number between 0 and X, but 0 and X will have 50% less chances to be generated comparing to all the numbers in between.

It's better to use "floor(random(x+1))" if you need a range between 0 and X.
OR
"floor(random(b-a+1))+a" if you need a range between A and B.
ImageImageImage
B
31
S
19
G
82
Posts: 1,037
Reputation: 46,203

Post » Thu Sep 10, 2015 9:44 pm

or set frame (choose(0,1,2,3,4)) (as required) :twisted:

(viewtopic.php?f=147&t=153638&p=968300#p968300)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests