Basically, I have a menu bar where the left right buttons change the middle button and clicking on the middle button plays the pressed animation and letting go reverts to unpressed animation.
I have numbered the animations such that odds are ‘pressed’ and even are ‘unpressed’ (including 0 - if 0 can be considered even).
Is there a way to check if animation (by number) is odd or even (i.e. animation number % 2 = 0)?
You can mod number of animation and check if its equal to 0 or 1
Modulo expression is like looping number around some range
For example imagine you have seconds counter and seconds go from 0 to 999
But you want them to count from 0 to 9 then go back to 0 and start counting over
You would use mod(YourSeconds,10)
Same if you would want 60 sec out of it mod(YourSeconds,60)
Anyway you can also do it to animation and go with mod(Animation,2)
And instead it goes with animation 0 1 2 3 4 5 6 7 8 9… it will go with 0 1 0 1 0 1 0 1 0 1 0 1 0 1…
And by checking if its equal to 0 or 1 you would determine if its even or odd number
I tried using this to make an object appear at alternating locations based on the level the player is on, but it only puts the object at the even-numbered spot even if the variable is odd.
Turns out the problem was that it was looking for a local variable while “stage” is a global variable, so it needed to say “f(x) mod(GlobalVariable(stage),2)”, instead