Thank you for visiting Blazing Games

Blasting Gorbons

Implementing the Gorbon ship was fairly simple. The cursor is displayed only if the player has a gun and the ship movement is a simple motion using an alien ship class that has the ability to blow up. If the player has the gun and clicks on the ship before it lands then the explosion animation is triggered with the ending frame of the ship-explosion animation being a blank frame. This way the ship will vanish if the player clicks on it when they have the gun even though underneath the surface the ship movement animation is continuing to play.

// frame 1 code

function fireGun(evt:Event)
{
if (ship_movie.hitTestPoint(mouseX, mouseY)) {
ship_movie.explodeShip();
removeEventListener(MouseEvent.MOUSE_UP, fireGun);
setTargeting(false);
}
}

function setTargeting(b:Boolean)
{
if (b) {
// trace("targetting on");
addEventListener(Event.ENTER_FRAME, targeting);
Mouse.hide();
sight_movie.visible = true;
} else {
// trace("targetting off");
removeEventListener(Event.ENTER_FRAME, targeting);
Mouse.show();
if (sight_movie != null)
sight_movie.visible = false;
}
}

function targeting(evt:Event)
{
if (sight_movie != null) {
sight_movie.x = mouseX;
sight_movie.y = mouseY;
}
}

// Window code

setTargeting(haveGun);
if (haveGun) {
firedGun = false;
addEventListener(MouseEvent.MOUSE_UP, fireGun);
}
nextRoom_btn.addEventListener(flash.events.MouseEvent.CLICK, toHallway);
nextRoom_btn.removeEventListener(flash.events.MouseEvent.CLICK, toWindow);

Previous page
Chapter 29 Page 4

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2008 Blazing Games Inc. All Rights Reserved