Cheers for taking time to look at this.
Im needing to get this little game finished in a week or so and having problems with a working energy bar which decreases when a bullys face gets to big before you shoot it. The energy bar is a simple movie tween consisting of 3 frames for the decreasing energy.
if I take out these parts of the code my game works ok:
var score:int;
var energy:int; (and all the sections which work with these :int; 's.)
This is posing a problem becuase I need an energy bar for the game to have a win lose ending.
HERE IS THE CODE
var monstersInGame:uint;
var monsterMaker:Timer;
var container_mc:MovieClip;
var cursor:MovieClip;
var score:int;
var energy:int;
function initializeGame(): void
{
monstersInGame = 15;
monsterMaker = new Timer (1000, monstersInGame);
container_mc = new MovieClip();
addChild(container_mc);
monsterMaker.addEventListener(TimerEvent.TIMER, createMonsters);
monsterMaker.start();
cursor = new Cursor();
addChild(cursor);
cursor.enabled = false
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, dragCursor);
score = 0;
energy = energy_mc.totalFrames;
energy_mc.gotoAndStop(energy);
}
function dragCursor(event:MouseEvent):void
{
cursor.x = this.mouseX;
cursor.y = this.mouseY;
}
function createMonsters(event:TimerEvent):void
{
var monster:MovieClip;
monster = new bullyface();
monster.x = Math.random() * stage.stageWidth;
monster.y = Math.random() * stage.stageHeight;
container_mc.addChild(monster);
}
function increaseScore():void
{
score++;
if(score >= monstersInGame)
{
monsterMaker.stop();
trace(“you beat that bully good!”);
}
}
function decreseEnergy():void
{
energy --;
if(energy <=0)
{
monsterMaker.stop();
trace(“you lose!”)
}
else
{
energy_mc.gotoAndStop(energy);
}
}
initializeGame();
THESE ARE THE ERRORS
Scene1: Layer’Actions’ Frame1, Line25 - 1120: Access of undefined property energy_mc. energy = energy_mc.totalFrames;
Scene1: Layer’Actions’ Frame1, Line 26 - 1120: Access of undefined property energy_mc. energy_mc.gotoAndStop(energy);
Scene1: Layer’Actions’ Frame1, Line 64 - 1120: Access of undefined property energy_mc. energy_mc.gotoAndStop(energy);
I appreciate any help with this matter, Thanks again for taking time to look over this.
Leon