|
Projects -
Flash CS3
|
|
Written by drooza
|
|
Tuesday, 23 September 2008 19:02 |
|
Page 1 of 9 If you aren't already familiar with Neopets.com then you should go check them out. I believe they have one of - if not - the biggest audiences of users of online games. With just over 660 billion page views they have a massive audience. Neopets is an online community based on an online pet and in order to feed this pet you must play online games (to gain money or neopoints) to buy food. This mini-world even has their own economy and stock market! One of the games there caught my eye, Destruct-o-Match, which is in its third installment. One of my favorite time-killing games. I didn't just kill time playing the game but analyzing how it works and developing my own version.
Now I'm going to show you how I did it using Flash CS3 and Actionscript 3.0. First we'll start off with the idea of the game: A group of colored tiles that when 2 or more are grouped together may be destroyed in exchange for points. If you destroy all the blocks on the field, or you gain enough points, you advance to the next level Second we'll start building the foundation of the game. What other great place to start than the tiles! Lets start off with a new class named Tile. /** Linkage class for the Library Item Tile. The library item must have 1 tile per * frame with a flag: "blank" on the last frame to denote it's empty. This will * enable easy customization and updating. * * @author dRooza */ package { import flash.display.MovieClip; import fl.transitions.Tween; public class Tile extends MovieClip { public var checked:Boolean; //flag to eliminate duplicate checking public var highLighted:Boolean; //flag for destruction destroy public var column:int; //coordinates for where public var row:int; // tile is located
// pointer to tween so garbage collector doesn't remove prior to completion public var tween:Tween;
/** Constructor initializes tile to a random frame and sets the boolean * highlighted to false. */ public function Tile() { turnOff(); this.gotoAndStop(Math.round(Math.random() * (this.totalFrames - 1))); } /** Highlights the tile, marking it as checked. * */ public function turnOn():void { this.alpha = .25; this.highLighted = true; markAsChecked(); } /** Sets tile back to normal state: not checked nor highlighted * */ public function turnOff():void { this.alpha = 1; this.highLighted = false; this.checked = false; }
/** Checks to see if the tile is highlighted * @return if the tile is highlighted */ public function isHighLighted():Boolean { return highLighted; } /** Set the tile as checked to prevent it from being checked again * */ public function markAsChecked():void { checked = true; } /** Checks to see if the tile is highlighted * @return if the tile has been checked */ public function isChecked():Boolean { return checked; } /** Removes the tile from the stage * */ public function destroy() { if(this.parent != null) { this.parent.removeChild(this); } } } //end class } //end package
|
|
Last Updated ( Saturday, 22 November 2008 13:05 )
|