Have this sets of codes whereby when reach 0seconds, it would gotoAndPlay(“mythirdframe”);
after that when you restart the game using the restart movieclip, it would start a brand new sets of time of 60seconds for the game to continue when player hits the restart button.
1st Problem:
But for some reason i have no idea why it does not appear a brand new sets of timing for a brand new game when the player restarts de game… Hope someone out there can help me…
error at: public function countdown (event:TimerEvent):void
2nd Problem:
I have this problem whereby my objects that can be clicked only during the game is playing, and should disappear after 60s or the healthbar reaches the bottom, but it does not disappear.
Can someone help me with this problem as well?Thanks alot.
I used a for loop at the bottom to control the spawn as well as removing it but to no avail.
error: at function addOn();
Reply here if u can help me and i will send u all my current files to let you guy(s) see how does my game works. Thanks lots.
Panel:
package
{
import flash.display.MovieClip;
import flash.events.*;
import flash.text.*;
import flash.utils.Timer;
public class Panel extends MovieClip
{
public var clickScore:Number = 0;
public var count:uint;
public var prevCount:uint;
public var timer:Timer;
public var hpbar = new Healthbar(630,370);
public var mkface = new Monkeyface(350,380);
public var countTime:Number = 5;
public var myTimer:Timer = new Timer(2000,countTime);
public var inedible:Inedible = new Inedible();
public var edible:Edible = new Edible();
public var gobg:goBackground = new goBackground();
public var go:gameover = new gameover();
public var ta:tryagain = new tryagain();
public var sgo:startGameone = new startGameone();
public var msg:Message = new Message();
public var nx:Next = new Next();
public function Panel()
{
stage.addChild(sgo);
sgo.addEventListener(MouseEvent.CLICK, sGame);
}
public function sGame(e:MouseEvent)
{
//if(e.target is startGameone)
gotoAndPlay("middlestage");
stage.removeChild(sgo);
stage.removeEventListener(MouseEvent.CLICK, sGame);
}
public function setting ()
{
stage.addEventListener(MouseEvent.CLICK , gameStartone);
parent.addChild(mkface);
parent.addChild(hpbar);
//edible.x = Math.random() * stage.stageWidth;
//edible.y = Math.random() * stage.stageHeight;
parent.addChild(edible);
count++;
//inedible.x = Math.random() * stage.stageWidth;
//inedible.x = Math.random() * stage.stageHeight;
parent.addChild(inedible);
count++;
stage.addEventListener (MouseEvent.CLICK, clickon);
timer = new Timer(6000);
timer.start ();
timer.addEventListener (TimerEvent.TIMER, addOn);
var score:int = 0;
myTimer.start();
myTimer.addEventListener (TimerEvent.TIMER, countdown);
}
public function countdown (event:TimerEvent):void
{
String((countTime) - myTimer.currentCount + "s") =="20";
txtTimer.text = String((countTime) - myTimer.currentCount + "s");
trace(String((countTime) - myTimer.currentCount + "s"));
if (txtTimer.text == "0s")
{
myTimer.stop();
parent.removeEventListener (MouseEvent.CLICK, clickon);
parent.removeChild(hpbar);
parent.removeChild(mkface);
gotoAndPlay ("backstage");
parent.addChild(gobg);
parent.addChild(msg);
parent.addChild(go);
parent.addChild(ta);
parent.addChild(nx);
//parent.removeChild(edible);
//parent.removeChild(inedible);
stage.addEventListener(MouseEvent.CLICK, restart);
trace("GAMEOVER");
}
}
public function restart(e:MouseEvent)
{
if(e.target is tryagain)
{
//stage.removeChild(mkface);
gotoAndPlay("middlestage");
stage.removeChild(ta);
stage.removeChild(go);
stage.removeChild(msg);
stage.removeChild(nx);
stage.removeChild(gobg);
String((countTime) - myTimer.currentCount + "s")+ "20s"
trace("moving down.");
txtTimer.text = String((countTime) - myTimer.currentCount + "s");
trace(String((countTime) - myTimer.currentCount + "s"));
}
}
public function gameStartone(event:MouseEvent)
{
if(event.target is startGameone)
{
gotoAndPlay("middlestage");
}
}
public function clickon (e:MouseEvent)
{
if (e.target is Edible)
{
e.target.die ();
hpbar.plusHealth();
if(mkface.currentLabel == "10face")
{
return mkface.currentLabel == "10face";
}
if(mkface.currentLabel == "9face")
{
mkface.gotoAndPlay("10face");
return;
}
if(mkface.currentLabel == "8face")
{
mkface.gotoAndPlay("9face");
return;
}
if(mkface.currentLabel == "7face")
{
mkface.gotoAndPlay("8face");
return;
}
if(mkface.currentLabel == "6face")
{
mkface.gotoAndPlay("7face");
return;
}
if(mkface.currentLabel == "5face")
{
mkface.gotoAndPlay("6face");
return;
}
if(mkface.currentLabel == "4face")
{
mkface.gotoAndPlay("5face");
return;
}
if(mkface.currentLabel == "3face")
{
mkface.gotoAndPlay("4face");
return;
}
if(mkface.currentLabel == "2face")
{
mkface.gotoAndPlay("3face");
return;
}
if(mkface.currentLabel == "1face")
{
mkface.gotoAndPlay("2face");
return;
}
}
if (e.target is Inedible)
{
e.target.die ();
mkface.minusFace();
if(hpbar.currentLabel == "10Health")
{
hpbar.gotoAndPlay("9Health");
return hpbar.currentLabel == "9Health";
}
if(hpbar.currentLabel == "9Health")
{
hpbar.gotoAndPlay("8Health");
return;
}
if(hpbar.currentLabel == "8Health")
{
hpbar.gotoAndPlay("7Health");
return;
}
if(hpbar.currentLabel == "7Health")
{
hpbar.gotoAndPlay("6Health");
return;
}
if(hpbar.currentLabel == "6Health")
{
hpbar.gotoAndPlay("5Health");
return;
}
if(hpbar.currentLabel == "5Health")
{
hpbar.gotoAndPlay("4Health");
return;
}
if(hpbar.currentLabel == "4Health")
{
hpbar.gotoAndPlay("3Health");
return;
}
if(hpbar.currentLabel == "3Health")
{
hpbar.gotoAndPlay("2Health");
return;
}
if(hpbar.currentLabel == "2Health")
{
hpbar.gotoAndPlay("1Health");
return;
}
}
}
public function addOn (e:TimerEvent)
{
prevCount=count;
count+=count;
//var len:int = deptControlArray.length;
//for(var count:int=0;count<len;count++)
for (var i:int = prevCount; i < count; i++)
{
if(i <= 8)
{
var edible:Edible = new Edible();
//edible.name="edible"+i;
edible.x=Math.random()*stage.width;
edible.y=Math.random()*stage.height;
parent.addChild(edible);
}
if(i <= 8)
{
var inedible:Inedible = new Inedible();
//inedible.name="inedible"+i;
inedible.x=Math.random()*stage.width;
inedible.y=Math.random()*stage.height;
parent.addChild(inedible);
}
/*else
{
return;
}*/
}
for (var r:int = prevCount; r > count; r++)
{
if(r <= 5)
{
parent.removeChild(edible);
}
if(r <= 5)
{
parent.removeChild(inedible);
}
else
{
return;
}
}
//return(edible);
//return(inedible);
}
/*
public function spawnUp ()
{
if(this.numChildren == 1)
{
timer.stop ();
stop();
var i:uint=numChildren;
while (i==-1)
{
removeChildAt(1);
gotoAndPlay("End");
}
}
}
*/
}
}