Random frame

Get help using Construct 2

Post » Tue Jun 25, 2013 6:42 am

Hi

I got this working random(19)

But how do I only get a frame to show once

Regards
Flemming
B
28
S
15
G
10
Posts: 338
Reputation: 7,837

Post » Tue Jun 25, 2013 8:27 am

You want to cycle randomly between the frames ? I would use a instance variable "framesToDisplay", initialy set to "0;1;2;...;x;", x being the frame count, and every time I need to change the frame, I would set the frame to round(random(tokenCount(framesToDisplay,";"))), and then remove the frame number from the variable. Once there is no more token (every frame has been used), regenerate the variable.
As you will need to store the frames still to show, or the ones already shown, I don't think there is a solution without variable.
B
17
S
8
G
4
Posts: 461
Reputation: 6,077

Post » Tue Jun 25, 2013 2:24 pm

Hi thanks Guizmus

A little advanced for me,
Would It be hard doing a sample .capx

Cheers
B
28
S
15
G
10
Posts: 338
Reputation: 7,837

Post » Tue Jun 25, 2013 3:21 pm

Here's one way to do it. It's similar to the method Guizmus suggested, but uses an array instead of a string variable.

Demo
Capx

I hope this helps.
B
55
S
17
G
8
Posts: 339
Reputation: 11,736

Post » Tue Jun 25, 2013 3:36 pm

Here is the capx for the method I described. Works with any frame count. Functions can easily be changed to accept multiple instance of the sprite (just add a Sprite.UID argument on each call)
B
17
S
8
G
4
Posts: 461
Reputation: 6,077

Post » Wed Jun 26, 2013 1:07 pm

Just great - Thanks for that !!
will try it out

B
28
S
15
G
10
Posts: 338
Reputation: 7,837


Return to How do I....?

Who is online

Users browsing this forum: BobOfAMillion, jhjconstruct, MAVERICK, tarek2 and 10 guests