Placing the gems

Placing the gems on stage may seem just a matter of adding some random DisplayObjects to Display List, but you'll see that we'll find ourselves in trouble very soon.

The idea: We are going to populate the array and physically place the jewels in the same script, so we'll fill the array with random integer numbers between 0 and 6, to represent each of the possible jewels. At the same time, we'll place a gem in the proper position and show the proper frame.

The development: You already know what we need to place the jewels as it's the same concept as placing cards, mines, crates, or whatever kind of asset in a tile-based game. Anyway, let's recap once again. We need:

  • a two-dimensional array to represent the game field
  • a DisplayObject ...

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.