Book Image

Flash Game Development by Example

By : Emanuele Feronato
Book Image

Flash Game Development by Example

By: Emanuele Feronato

Overview of this book

<p>You can't call yourself a Flash game developer unless you know how to build certain essential games, and can quickly use the skills and techniques that make them up.<br /><br />Flash Game Development by Example is an ultra-fast paced game development course. Learn step-by-step how to build 10 classic games. Each game introduces new game development skills, techniques, and concepts. By the end of the book you will have built ten complete games &ndash; and have the skills you need to design and build your own game ideas.<br /><br />The book starts with simple well known puzzle games: Concentration and Minesweeper. After learning the basics of game design you&rsquo;ll introduce AI with a four-in-a-row game. Then as you build your own versions of old arcade games such as Snake, Tetris, and Astro Panic. The book ends with a collection of modern casual classics.</p>
Table of Contents (17 chapters)
Flash Game Development by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Where to Go Now
Index

Killing an enemy—for good


A level is completed when all enemies have been killed. When you kill an enemy, the game must continue rather than stop like it does now. We must flag enemies killed by the spaceship so they won't harm anymore, and let the game continue.

First, when we create a new enemy, let's set a new property called killed. It will be true if the enemy has been killed, so it starts with false.

private function placeEnemy(enemy_level:uint):void {
  enemy=new enemy_mc();
  enemy.killed=false;
  ...
}

Then we have to heavily recode killEnemy function. We won't remove listeners as we don't want the game to stop, but we'll set killed property to true and remove the bullet as if it had flown out of the stage.

private function killEnemy(theEnemy:enemy_mc):void {
  var glow:GlowFilter=new GlowFilter(0xFF00FF,1,10,10,6,6);
  theEnemy.filters=new Array(glow);
  // don't remove listeners
  theEnemy.killed=true;
  removeChild(bullet);
  bullet=null;
  isFiring=false;
}

Last but not least, we...