Checking for matching tiles

It's time to let the player know whether he picked two matching tiles or not. Let's think about Concentration like a turn-based game; at every turn the player can pick no more than two cards before knowing if he has got a matching pick.

So we are going to add the following features:

  • Don't let the player pick the same tile twice in a turn.
  • Once he picked the second tile, check if selected tiles match.
  • If they match, remove them from stage.
  • If they do not match, turn them back again.

The idea is quite simple as we'll be using an array to store picked tiles. Once the array contains two elements (two picked tiles), we'll see if tile values match.

So we need to declare a new array to be available in all main class functions and ...

Get Flash Game Development by Example now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.