Hello all I’m currently working on a game which requires a reset script.
A sample file is attached.
I’ve tried resetting the blue box with…
score = 0;
shooter.speed = 10;
this.onEnterFrame = function() {
if (Key.isDown(Key.LEFT)) {
shooter._x -= shooter.speed;
}
if (Key.isDown(Key.RIGHT)) {
shooter._x += shooter.speed;
}
if (Key.isDown(Key.UP)) {
shooter._y -= shooter.speed;
}
if (Key.isDown(Key.DOWN)) {
shooter._y += shooter.speed;
}
if (shooter.hitTest(box1)) {
score += 10;
trace(score);
box1.gotoAndStop("small");
box1 = false;
}
if (shooter.hitTest(box2)) {
score += 10;
trace(score);
box2.gotoAndStop("small");
box2 = false;
}
if (shooter.hitTest(box3)) {
score += 10;
trace(score);
box3.gotoAndStop("small");
box3 = false;
}
}
resetBtn.onRelease = function () {
score = 0;
box1 = true;
box2 = true;
box3 = true;
box1.gotoAndStop("big");
box2.gotoAndStop("big");
box3.gotoAndStop("big");
}
…but it doesn’t seem to work? Is there an alternative?
I’ve tried using ‘false’ to disable the endless score loop but I don’t know how to reset it to it’s original state of the box and the score.