How do I make a sprite go to random frame when touched?

Get help using Construct 2

Post » Sun Jun 01, 2014 11:09 pm

Hi,
I am wondering about the delay when I click on the sprite which is supposed to change color on every touch/click.

The sprite has 6 frames (0 - 5) and the event sheet looks like this:
Touch > On touched Sprite | Sprite - Set animation frame to random(0,5)

When I load run this app, it opens, showing the sprite on frame 0 (red)
When I click on it nothing happens at first. After a while, the colors change but not predictably.

What am I missing?
You do not have the required permissions to view the files attached to this post.
B
14
S
4
Posts: 190
Reputation: 1,735

Post » Sun Jun 01, 2014 11:20 pm

For me it works 100%.it changes instantly color and if one time it does not change it is because it picks the same color again since it is random and it seems that it is not working when in matter of fact it does
Last edited by Roccinio on Sun Jun 01, 2014 11:22 pm, edited 1 time in total.
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Jun 01, 2014 11:22 pm

I believe random produces a floating point number? 1.23, 3.65 etc... try it with floor/round in front of it "floor(random(0,6))" (keeping mind random the 6 is not included in the selection range) or you could do "choose(0,1,2,3,4,5)"
B
20
S
7
G
1
Posts: 221
Reputation: 2,077

Post » Sun Jun 01, 2014 11:23 pm

Oh yes! You must use the choose and then the numbers separated by comas
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Jun 01, 2014 11:26 pm

AWESOME! ... let me try that :)

Thank you guys!
B
14
S
4
Posts: 190
Reputation: 1,735


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, kainrazial and 7 guests