How do I play animation on instace at random intervals?

  • Hi there

    I have sprite called Tree, that has animation TreeA, TreeB... etc with different trees moving in the wind. Now I would like this animation play in random intervals for each animation...

    When the animation is looping it loops infinitely and stop command stops all instances with ether of the animations.

    When animation is not looping it doesn't seems to respond to start command, just the looping ones seems to randomly restart from beginning.

    What I would like:

    is Tree on screen

    is Tree Animation TreeA finished?

    is Random interval 0? (or wait(random(5))

    Then start Animation TreeA from beginning.

    Thanks for advice.

  • set a global variable called treeAnimation = 0

    set a global variable called treeIsPlaying = 0

    now set up a condition for each animation TreeA

    ad the global variable treeAnimation = 1 to that animation condition

    ad the global variable treeIsPlaying = 1 to that animation condition

    (Action) set treeIsPlaying = 0 after animation

    now set up a condition for each animation TreeB

    ad the global variable treeAnimation = 1 to that animation condition

    ad the global variable treeIsPlaying = 1 to that animation condition

    (Action) set treeIsPlaying = 0 after animation

    Now you can every tic set variable = int(random(1,2))

    ad the global variable treeIsPlaying = 0 to that animation condition

  • now set up a condition for each animation TreeA

    ad the global variable treeAnimation = 1 to that animation condition

    ad the global variable treeIsPlaying = 1 to that animation condition

    (Action) set treeIsPlaying = 0 after animation

    So that means I will have to split it to multiple sprites for each tree animation. Because right now I have only one sprite for all Trees and other for all Grasses.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • no you can call the animation

  • Use the timer object and smartly name your animations....

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)