Flagging tiles

Now the player must be given the option to flag tiles. You can take a breath as it's quite easy.

The idea: The player can flag/unflag a tile by clicking on it while holding Shift key. A flagged tile cannot be uncovered until it's unflagged.

The development: Modify onTileClicked function this way:

private function onTileClicked(e:MouseEvent):void { var clicked_tile:tile_movieclip=e.currentTarget as tile_movieclip; var clickedRow:uint=clicked_tile.nrow; var clickedCol:uint=clicked_tile.ncol; var clickedValue:uint=mineField[clickedRow][clickedCol]; if (e.shiftKey) { clicked_tile.gotoAndStop(5-clicked_tile.currentFrame); } else { if (clicked_tile.currentFrame==1) { clicked_tile.removeEventListener( MouseEvent.CLICK,onTileClicked); ...

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.