O'Reilly logo

Starling Game Development Essentials by Juwal Bose

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the game level

The Flag Defense game is essentially an event-based game, which only needs a very simple game loop. This is because in this turn-based game, each action occurs sequentially and is based on events. So, our game loop essentially is very simple and involves only advancing of animation frames, moving characters, rendering the updated level, and switching few game states.

Consider the following code in the MainLevel class:

private function loop(e:EnterFrameEvent):void { Starling.juggler.advanceTime(e.passedTime);diceAnim.update(e.passedTime); worldLayer.render(e.passedTime, groundImage); if(gameState == GameStates.GREEN_MOVE && worldLayer.noneWalking()){ clearPath(); switchGameState(GameStates.BLUE_DICE); }else if(gameState ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required