Talk about everything under the sun. Unless it’s against the rules. You must have a member level of 3 or greater to post new topics here and a level of 3 to post replies.
Power Egg
Member Lvl: 15
Egg Points: 23084
Posts: 3400
Posted: Dec 11, 2008 3:31 p.m. - Subject: Actionscript/Flash help
Okay so I have some code for a whack-a-mole type game (By the way, if you don’t know Action5cript, can you please give me a good community for this kind of help BESIDES NEWGROUNDS.)
And don’t worry about the // *, they are just notes.
Quote:
init();
function init(){
for(i = 0; i < 10; i++){
_root.attachMovie("target", "target_" + i, 100 + i);
theTarget = eval("target_" + i);
theTarget._x = i * (theTarget._width + 5) + 50;
theTarget._y = 200;
theTarget.state = "down";
theTarget.gotoAndStop("down");
//larger popUpRate makes targets pop up more frequently
theTarget.popUpRate = .01;
//larger resetFrames makes targets stay up longer
theTarget.resetFrames = 12;
theTarget.onEnterFrame = function(){
if (this.state == "down"){
//pop up randomly
if (Math.random() < this.popUpRate){
this.state = "up";
this.gotoAndStop("up");
this.counter = this.resetFrames;
} // end "pop up" if
} else {
//count down because target is currently up
this.counter--;
if (this.counter < 0){
//go back down
this.state = "down";
this.gotoAndStop("down");
misses++;
} // end if
} // end "up or down" if
} // end enterFrame
theTarget.onPress = function(){
if (this.state == "up"){
this.state = "down";
this.gotoAndStop("down");
hits++;
} // end if
} // end onRelease
} // end for loop
} // end init
So what I’m trying to do is make so if you get a certain amount of misses like 10, it goes to the lose frame, and if you get like 5 hits it goes on to the next level frame.
All I need is the damn code for it.
I tried:
If {(misses == 10))
_root.GotoAndStop ("lose");
}