0 Favourites

Infinite Loops - While

  • Hi.

    How would I set up an infinite loop with a condition to infinitely cycle through 29 values until the condition is no longer true?

    I've set up the array with the 29 values, but for some reason I'm having trouble nesting the For Each Value under While.

    What's the best way to code this?

    We could obviously try something with less values and just appending a text object.

    This is my first time using While, so I may not be up on all the syntax possibilities.

  • General flow :

    Set premise to false

    While

    Test premise

    .......... change something

    .......... test change

    ........................... set premise false or true based on change

    But in your case, chances are that you dont need a 'while', if we speak about a 1 dimensional array.

    Array > Contains value 'value'

    ................. in the actions the index of that value is stored in the expression Array.IndexOf('value')

    Otherwise.

    Local variable 'counter' ... number .. = 0

    Local variable 'check' ... number .. = 0

    While

    'check' = 0

    _______ Array .. Compare at XY ... x = counter .. y = say 1 ... compare to what you wanna compare

    _______________Set 'check' to 1

    _______System > Compare 2 values ... counter ... is the same as ... Array.widht - 1

    _______________Set 'check' to 1

    _______ System > Every tick

    _______________add 1 to counter

  • Ok, thank you. Let me give this a go and see if I can code a workable solution.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • I did not 'solve' anything for you. I see you say in another topic:

    Basically, I was just doing a ship tilting animation when pressing arrow keys left and right and I wanted it to animate back when the arrow key was released. I coded something with variables that works flawlessly while breaking up the 29 total frame animation into individual frames linked up to a specific variable (my way of keeping track of the frame number).

    A 'while' & 'animation frames' dont match. Simple because a 'while' always happens in 1 tick and 'animation frames' happen over several ticks.

    I suppose you want to play some 'basic animation' when the 'tilting animation' returns to its 'zero' frame.

    Set the 'basic animation' to looping in its property's.

    Now all you need is:

    Sprite > Is playing 'tilting animation'

    Sprite > Compare frame .. = 0 ?

    System > Trigger once while true

    ______________ Sprite > Set animation .. 'basic animation'

    If i understand what you try to do.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
34 5,884
Taurian's avatar
Taurian
Unread hot topic
39 7,143
christina's avatar
christina
Unread hot topic
0 Favourites
[PLUGIN] While-loop
33 8,101
rexrainbow's avatar
rexrainbow