PDA

View Full Version : Score recognition, trouble ending game



Sektor
June 2nd, 2004, 07:30 PM
I want a game to end when the player reaches a score of 2500. I tried an if statement and a go to and play command but neither have worked. Here's what the code calculating the score looks like:
(NOTE: This code works fine)

onClipEvent (enterFrame) {
this._x+=laserMoveSpeed;
if (this._x>600){
this.removeMovieClip();
}
for (i=1; i<=_root.numEnemy; i++){
if (this.hitTest( _root["enemy"+i])){
_root.score+=100;
_root["enemy"+i].gotoAndPlay( 2 );
}
}
}

I tried doing something like this:

onClipEvent (enterFrame) {
this._x+=laserMoveSpeed;
if (this._x>600){
this.removeMovieClip();
}
for (i=1; i<=_root.numEnemy; i++){
if (this.hitTest( _root["enemy"+i])){
_root.score+=100;
_root["enemy"+i].gotoAndPlay( 2 );
if ( score >= 2500 )
gotoAndPlay ( 5 );
}
}
}

but it didn't work. Can I get a helping hand to tell me what I'm doing wrong?

dangerskew
June 2nd, 2004, 07:59 PM
Did you try "gotoAndStop();"? Or, "_root.gotoAndStop();"?

Sektor
June 2nd, 2004, 08:04 PM
No, I didn't use that but if Go to and Play doesn't send me to frame 5 in the first place, I dont know if that will fix my problem

signifer123
June 2nd, 2004, 08:25 PM
is therr more than 1 scene?

Sektor
June 3rd, 2004, 09:47 AM
is therr more than 1 scene?Yes, the game is on the 3rd scene

tommythewolfboy
June 3rd, 2004, 02:16 PM
give the frame that you want to go to a label (such as 'end') and then gotoAndPlay ("end"); instead

tommythewolfboy
June 3rd, 2004, 02:17 PM
Oh and I find life is much simpler if I avoid scenes! Works for some people, but I find you come across problems like this.