Infinite Loops - While

0 favourites
  • 4 posts
From the Asset Store
A set of Backgrounds, objects, characters that you can immediately use for your project with ease!
  • 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


    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')


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

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


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

  • Try Construct 3

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

    Try 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)