Game Development Reference
In-Depth Information
Settings
This game requires following setting for your AS3 project:
Dimensions : 550
400
Frames per second : 30
The Code
With the graphics and sound assets in your library, you are now ready to create the Balloon Saw
game.
For this example, we need only a single Game.as class that will be the document for our Flash
movie, as we did previously. Since the code for this game is fairly limited, we will start by showing
you all of its code, highlighting the differences from the first example in bold. We will then
describe what is happening.
package {
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.*;
import flash.events.*;
import flash.geom.Rectangle;
import flash.media.Sound;
import flash.text.*;
public class Game extends flash.display.MovieClip{
public static const STATE_INIT:int = 10;
public static const STATE_PLAY:int = 20;
public static const STATE_END_GAME:int = 30;
public var gameState:int = 0;
public var score:int = 0;
public var chances:int = 0;
public var bg:MovieClip;
public var enemies:Array;
public var player:MovieClip;
public var level:Number = 0;
public var scoreLabel:TextField = new TextField();
public var levelLabel:TextField = new TextField();
public var chancesLabel:TextField = new TextField();
public var scoreText:TextField = new TextField();
public var levelText:TextField = new TextField();
public var chancesText:TextField = new TextField();
public const SCOREBOARD_Y:Number =380;
public function Game() {
addEventListener(Event.ENTER_FRAME, gameLoop);
Search WWH ::




Custom Search