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
34
S
18
G
11
Posts: 356
Reputation: 8,819

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
9
G
4
Posts: 473
Reputation: 6,271

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
34
S
18
G
11
Posts: 356
Reputation: 8,819

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

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
9
G
4
Posts: 473
Reputation: 6,271

Post » Wed Jun 26, 2013 1:07 pm

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

B
34
S
18
G
11
Posts: 356
Reputation: 8,819


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 42 guests