Game Development Reference
In-Depth Information
import com.flashgamebook.iphone.engines.labyrinth.LabyrinthEngine;
final public class GameClip extends Sprite
static public const LEVEL_LENGTH:int = 75; //IN SECONDS
static public const SCORE_MULTIPLIER:int = 150;
public var tfLevel:TextField;
public var tfTime:TextField;
public var tfScore:TextField;
private var _engine:LabyrinthEngine;
private var _level:int = 1;
private var _score:int = 0;
private var _timer:Timer;
Because the engine does all of the heavy lifting, our implemen-
tation of a labyrinth game is pretty simple. There
s a Timer and a
few TextFields to display important information, and then a hand-
ful of methods we
ll look at next.
public function GameClip()
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage,
false, 0, true);
private function onAddedToStage(e:Event):void
_level =;
_score =;
tfLevel.text = _level.toString();
tfScore.text = _score.toString();
private function nextLevel():void
_timer = new Timer(1000, LEVEL_LENGTH);
_timer.addEventListener(TimerEvent.TIMER, onTimer,
false, 0, true);
onTimerComplete, false, 0, true);
var levelClass:Class = getDefinitionByName( " Level " +
_level) as Class;
_engine = new LabyrinthEngine(Marble, levelClass);
_engine.y = 20;
Search Nedrilad ::

Custom Search