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
31
S
17
G
11
Posts: 348
Reputation: 8,636

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,097

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
31
S
17
G
11
Posts: 348
Reputation: 8,636

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
61
S
17
G
8
Posts: 341
Reputation: 11,940

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,097

Post » Wed Jun 26, 2013 1:07 pm

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

B
31
S
17
G
11
Posts: 348
Reputation: 8,636


Return to How do I....?

Who is online

Users browsing this forum: Jhorbam and 9 guests