Time Machine Apps
After a few months of hard work, we come back with a lot of work well done, new supergames soon available and new post in our blog. The fruits of this labour are a big account of snippets that we want to share with all of you. In this post, we are going to see a topic related to timer in Corona SDK. As always, sorry for my bad English
Timers are very useful in many situations in a game development: events that activate doors, make a gamer invulnerable during a few seconds, etc. However, what happens when we want to pause the game? How can we make to stop and restore the timers state when we make a pause during the game? In other frameworks, we can directly pause the timer and play them when the pause ends. But we can not make this in Corona SDK, so if we do not control it, the actions associated to a timer will be execute when the game is paused.
Now we are going to show the source code that can be used to solve this problem. In this example, two buttons appear in the screen, one to pause the game and another one to put bombs in the game. This last button executes a timer that will produce the bomb explosion after three seconds. Logically all these explosions will be simulated and all the information will be shown in the Corona SDK’s console.
The code is commented. We hope it was useful for you.
Regards.