Copy link to clipboard
Copied
I need to make a loop, which keeps a spawned item within the boundaries of the screen. It needs to be like this:
if (square_x + (width/2) > 480)
{
square_x = square_x - 5
}
(square_x is a variable defined before the conditional) but it needs to be a loop, so that it keeps repeating that effect until it satisfies the statement: "square_x < 480"
Copy link to clipboard
Copied
If you need it to loop, then you might just try using a while loop...
while(square_x >= 480){
if (square_x + (width/2) > 480){
square_x = square_x - 5
}
}
Copy link to clipboard
Copied
Why do you need a loop? Why not to just position object within boundaries?
Are you talking about initial positioning or keeping object within boundaries while animating it?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now