Animating Frames At Random

For questions about using Classic.

Post » Tue Dec 14, 2010 4:53 pm

Hi Folks.

I am new here.

What I am trying to do is make a game where there are squares flashing, and pressing a button stops the squares from flashing (a la The TV game show "Press Your Luck").

I already animated the frames that I drew the squares on in sequence. However what I want to do is actually animate the frames at random, so I won't know what square I am going to stop on when I press the button. Also, before each turn, I want to turn off the highlighted square, so all of the squares are not flashing, then when I start the randomizer, they will flash again.

How can I make my game do this process?

Thanks much.

- Chris
B
1
G
2
Posts: 8
Reputation: 641

Post » Tue Dec 14, 2010 5:27 pm

Set the animation frame to 1+random(number of frames in animation), every X milliseconds or ticks.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Tue Dec 14, 2010 6:50 pm

Thank you so much Davioware. :)

That worked like a charm. However, I am afraid that I have some bad news. I originally had the SPACE Bar set to pause the animation, and the F1 Key to resume it. However when I use these controls, their said commands do not happen.

Now I had played around w/those controls, and still, the same thing occurs.

What am I doing wrong? Any help is always appreciated.

Thanks again. :)

- Chris
B
1
G
2
Posts: 8
Reputation: 641

Post » Wed Dec 15, 2010 7:40 am

[quote="chriskvideochallenge":64b12ivw]Thank you so much Davioware. :)

That worked like a charm. However, I am afraid that I have some bad news. I originally had the SPACE Bar set to pause the animation, and the F1 Key to resume it. However when I use these controls, their said commands do not happen.

Now I had played around w/those controls, and still, the same thing occurs.

What am I doing wrong? Any help is always appreciated.

Thanks again. :)

- Chris[/quote:64b12ivw]

Sounds like you were just stopping a normal animation before, and didn't change that to work with your new random animations.

If you are doing a simple 'Every X milliseconds, set animation frame ...' to animate the squares, then you cannot stop it like you can a normal animation. You should make a global variable to flag whether the squares should animate or not, then only change the frame if it is true.

Something like so:

On SPACE key pressed : set global variable 'FlashSquares' to 0

On F1 key pressed : set global variable 'FlashSquares' to 1

Global variable 'FlashSquares' equals 1
Every 100 milliseconds : set the animation frame randomly...
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Sat May 21, 2011 12:55 pm

[quote:yk0ebv1h]Sounds like you were just stopping a normal animation before, and didn't change that to work with your new random animations.

If you are doing a simple 'Every X milliseconds, set animation frame ...' to animate the squares, then you cannot stop it like you can a normal animation. You should make a global variable to flag whether the squares should animate or not, then only change the frame if it is true.

Something like so:

[i]On SPACE key pressed : set global variable 'FlashSquares' to 0

On F1 key pressed : set global variable 'FlashSquares' to 1

Global variable 'FlashSquares' equals 1
Every 100 milliseconds : set the animation frame randomly...[/quote:yk0ebv1h]

Hiya Silent Cacophony, :)

I have not been on here or have been using Construct in the last few months. I've been tied up heavily during that time.

I already set the global variables for the key controls, but, I am still unclear as to how do I set the animation frame randomly so that I can stop the flashing squares by pressing the Space button.

Would you guide me step by step as to how I can do this. I'm so clueless sometimes when it comes to programming. I greatly appreciate it.

Thank you so much.

- Chris
B
1
G
2
Posts: 8
Reputation: 641


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest