Animating Frames At Random

This forum is currently in read-only mode.
From the Asset Store
Selection frame like in RTS games, works both on mobile and desktop devices.
  • 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
  • Set the animation frame to 1+random(number of frames in animation), every X milliseconds or ticks.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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
  • 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

    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...

  • [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:

    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...

    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
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)