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?