Game Development Reference
In-Depth Information
tile.y = i*tile.height;
addChild(tile);
tile.addEventListener(MouseEvent.CLICK,
selectTile, false, 0, true);
}
}
_crosswordClue = new CrosswordClue();
_crosswordClue.y = getRect(this).bottom + 20;
addChild(_crosswordClue);
slinktoits
neighbors, we add it to the master tile list, position it based on
its location in the letter grid, addittotheStage,andattachalis-
tener for mouse clicks. To end this method after the loop has
completed processing all the tiles, we add the previously created
CrosswordClue component to the Stage and position it under-
neath the rest of the puzzle with a little bit of whitespace. A com-
plete crossword puzzle should now exist on the Stage with all the
proper blacked-out squares and certain tiles that are assigned
clue numbers. You may have noticed that the method attached to
the mouse listener for each tile is called selectTile .Wewilldiscuss
it next.
Once the logic has run to determine each tile
'
protected function selectTile(e:MouseEvent):void {
var tile:CrosswordTile = e.target as CrosswordTile;
var acrossWord:Array = _wordListAcross[tile.
acrossIndex-1];
var downWord:Array = _wordListDown[tile.downIndex-1];
clearSelection();
if (tile.letter == CrosswordTile.EMPTY) {
_crosswordClue.text = CrosswordClue.
DEFAULT_VALUE;
stage.removeEventListener(KeyboardEvent.KEY_
DOWN, keyDown);
_selectedTile = null;
return;
}
if (!_selectedTile) stage.addEventListener
(KeyboardEvent.KEY_DOWN, keyDown, false, 0, true);
if (_selectedWord == acrossWord && _selectedTile == tile)
_selectedWord = downWord;
else if (_selectedWord == downWord &&
_selectedTile == tile) _selectedWord =
acrossWord;
else if (_selectedWord == acrossWord &&
_selectedTile != tile) _selectedWord =
acrossWord;
Search Nedrilad ::




Custom Search