For Loop: Action every 4 steps?

Get help using Construct 2

Post » Fri Mar 15, 2013 3:57 am

I searched the forums but couldn't figure this out. I might be using the wrong terms. I have a ForX=1to32 and ForY=1to32 event loop, and instead of performing the action every 1 step, I want it to perform the action every 4th step. Something like this:...

Step1: X=0, Y=0 - Do action
Step2: X=4, Y=4 - Do Action
Step3: X=8, Y=8 - Do Action
Etc...

Thanks
B
6
S
1
Posts: 31
Reputation: 1,237

Post » Fri Mar 15, 2013 5:09 am

store the number 4 in a variable, and multiply that in the steps
B
18
S
5
G
4
Posts: 568
Reputation: 5,079

Post » Fri Mar 15, 2013 5:42 am

You can use a modulo operation. For example if your event loop is 1 to 32, use from 0 to 31 and add a sub condition "if loopindex % 4 = 0". You won't need an extra variable in this case, saving on memory and processing!
B
17
S
5
G
4
Posts: 24
Reputation: 4,039


Return to How do I....?

Who is online

Users browsing this forum: djcrazypants, marekmk and 7 guests