gav.cooper
11-09-2007, 10:40 PM
Hello,
I’m trying to add a life system into a game I’m working on…
Thus far I have this Var setup on the main timeline…
var numLife:Number = 3;
txtLife.text = numLife
then inside an MC (each MC holds a seperate level) i have this code attached to a button...
on (release) {
if (_root.numLife <1)
gotoAndPlay ("gameover");
}else{
_root.numLife = _root.numLife - 1
_root.txtLife.text=_root.numLife
}
then i'm getting this error...
**Error** Symbol=Lv 01 STAGE 01 MC, layer=wave sy, frame=14:Line 4: 'else' encountered without matching 'if'
}else{
Total ActionScript Errors: 1 Reported Errors: 1
_root.numLife = _root.numLife - 1
_root.txtLife.text=_root.numLife}
basically i want it so that when the player clicks the button it takes off 1 life, after 3 clicks it then goes to the "gameover" screen...
can anyone help fix my code? :confused:
I’m trying to add a life system into a game I’m working on…
Thus far I have this Var setup on the main timeline…
var numLife:Number = 3;
txtLife.text = numLife
then inside an MC (each MC holds a seperate level) i have this code attached to a button...
on (release) {
if (_root.numLife <1)
gotoAndPlay ("gameover");
}else{
_root.numLife = _root.numLife - 1
_root.txtLife.text=_root.numLife
}
then i'm getting this error...
**Error** Symbol=Lv 01 STAGE 01 MC, layer=wave sy, frame=14:Line 4: 'else' encountered without matching 'if'
}else{
Total ActionScript Errors: 1 Reported Errors: 1
_root.numLife = _root.numLife - 1
_root.txtLife.text=_root.numLife}
basically i want it so that when the player clicks the button it takes off 1 life, after 3 clicks it then goes to the "gameover" screen...
can anyone help fix my code? :confused: