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
33
S
17
G
11
Posts: 350
Reputation: 8,695

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: 473
Reputation: 6,191

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
33
S
17
G
11
Posts: 350
Reputation: 8,695

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
63
S
19
G
8
Posts: 341
Reputation: 12,130

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: 473
Reputation: 6,191

Post » Wed Jun 26, 2013 1:07 pm

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

B
33
S
17
G
11
Posts: 350
Reputation: 8,695


Return to How do I....?

Who is online

Users browsing this forum: 25games, Blendi1223, jatin1726, kiki4construct, Username05 and 34 guests