Selecting a gem

Now the player must be able to select gems since he's supposed to swap them to form streaks.

The idea: When the player clicks, we can detect mouse coordinates, check if he clicked inside the game area and know which gem he selected.

The development: You already drew the selector, so it's just a matter of placing the selector in the proper tile when the player clicks the mouse.

First we need a new class level variable to create a selector_mc instance.

private var jewels:Array=new Array();
private var gemsContainer:Sprite=new Sprite();
private var gem:gem_mc;
private var selector:selector_mc=new selector_mc();

Notice how I already used the constructor new selector_mc() to have it ready to be used.

Now, in Main constructor function, ...

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.