Phaser for Beginners

Using timers to schedule events

Phaser allows us to create a variety of time driven events, in a simple and intuitive way., callback, callbackContext) adds a timer event which will execute callback function in the callbackContext context after tick time has passed.

Phaser.Timer.SECOND is a Phaser reserved variable which means “one second”, checkTiles is the name of the function we are going to call after a second we realized the player uncovered two tiles. The use of this should now clearly suggest you how to declare checkTiles function.

What should we write in checkTiles function?

Exactly the same code we used for checking tiles when there is a match and remove/cover them.

Now run the game, and you will see the game waits a second with both tiles shown on the stage before removing or covering back them. Now, the last – but not least – difference between our game and a real Concentration game: our tiles are always placed in the same, predictable, place. We have to spice up a bit the game by shuffling the tiles.

Download Source


Next Tutorial →

Shuffling the tiles

← Previous Tutorial

Checking for successful matches and removing tiles or turning them back