Repeatedly changing the position an object after an amount of time.

Hello!

 

I have just started work on my first project which is going to be a full game, hopefully, however it is only a simple concept to get me started. I won’t go in depth into my full idea but I do need some help with one specific part.

 

I would like to draw an object (button) to the screen, and then after a certain amount of time, I would like to position the object in another position, and then repeat this process another 10 - 20 times. I already know how to change the position of on abject after a certain amount of time using:

timer:performWithDelay()

However I want to know the best way to go about repeating this process? 

 

All I need to get me started on this the structure that I would use as I really don’t know, any help will be appreciated!

 

Matthew. 

Just specify a third argument to the timer.performWithDelay function:

[lua]

timer.performWithDelay(yourDelay, yourFunction, 10)

[/lua]

Also, note that it’s a period, not a colon, between timer and performWithDelay. A colon might make you end up with difficult-to-track bugs.

  • Caleb

This is exactly what I needed! I should have looked at the documentation but now I know for next time, I appreciate your help! I’ll let you know if I have any other questions about it.

No problem :slight_smile:

  • Caleb

Just specify a third argument to the timer.performWithDelay function:

[lua]

timer.performWithDelay(yourDelay, yourFunction, 10)

[/lua]

Also, note that it’s a period, not a colon, between timer and performWithDelay. A colon might make you end up with difficult-to-track bugs.

  • Caleb

This is exactly what I needed! I should have looked at the documentation but now I know for next time, I appreciate your help! I’ll let you know if I have any other questions about it.

No problem :slight_smile:

  • Caleb