Copy link to clipboard
Copied
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.Timer;
import flash.text.TextField;
import flash.text.TextFormat;
public class Game extends MovieClip
{
static var boat:MovieClip;
static var enemyShipTimer:Timer;
static var scoreText:TextField;
static var score:Number
static var healthMeter:HealthMeter;
static var gameOverMenu:GameOverMenu;
static var powerUpTimer:Timer;
static var miniBossTimer:Timer;
static var bossCountDown:Number;
public function Game()
{
Key.initialize(stage);
boat = new Boat();
addChild(boat);
boat.shield.visible = false;
bossCountDown = 3;
boat.x = 300
boat.y = 150
enemyShipTimer = new Timer(1000);
enemyShipTimer.addEventListener("timer", sendEnemy);
enemyShipTimer.start();
miniBossTimer.start();
var scoreFormat = new TextFormat("Calabri MS", 20, 0XFFFFFF);
scoreText = new TextField();
scoreText.defaultTextFormat = scoreFormat;
scoreText.x = 290;
scoreText.text = String(0);
addChild(scoreText);
healthMeter = new HealthMeter();
addChild(healthMeter);
healthMeter.x = 10;
healthMeter.y = 10;
gameOverMenu = new GameOverMenu();
gameOverMenu.x = 300;
gameOverMenu.y = 150;
addChild(gameOverMenu);
gameOverMenu.visible = false;
gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
powerUpTimer = new Timer(10000);
powerUpTimer.addEventListener("timer", sendPowerUp);
powerUpTimer.start();
miniBossTimer = new Timer (20000);
miniBossTimer.addEventListener("timer", sendMiniBoss);
miniBossTimer.start();
resetScore();
}
function sendMiniBoss(e:Event)
{
miniBossTimer.stop();
if(bossCountDown ==0)
{
var boss = new Boss();
stage.addChild(boss);
bossCountDown = 3;
}
else
{
var miniBoss = new MiniBoss();
stage.addChild(miniBoss);
bossCountDown -= 1;
}
}
function sendEnemy(e:Event)
{
var enemy = new EnemyShip();
stage.addChild(enemy);
}
function sendPowerUp(e:Event)
{
var powerUp = new PowerUp();
stage.addChild(powerUp);
}
static function updateScore(points)
{
score += points;
scoreText.text = String(score);
}
static function resetScore()
{
score = 0;
scoreText.text = String(score);
}
function newGame(e:Event)
{
gameOverMenu.visible = false;
boat.visible = true;
boat.x = 300;
boat.y = 150;
boat.takeDamage(-boat.maxHealth);
boat.addEventListener("enterFrame",boat.move);
resetScore();
enemyShipTimer.start();
}
static function gameOver()
{
gameOverMenu.visible = true;
enemyShipTimer.stop();
miniBossTimer.stop();
for(var i in EnemyShip.list)
{
EnemyShip.list.kill();
}
}
}
}
You only need to remove the line 35: miniBossTimer.start();
because it cannot be started with null values..
Copy link to clipboard
Copied
Says line 35 is the issue?
Copy link to clipboard
Copied
You only need to remove the line 35: miniBossTimer.start();
because it cannot be started with null values..