I’m currently working on a game using Flash MX 04. Thus far I’ve managed to solve every problem I’ve encountered except for this, maybe you can help. Here’s the situation: My game is side scroller (I’m using Mario for my prototype), I’ve got the window sort of, attached, to Mario so it scrolls with him, however, I can’t seem to get the score board to fallow. Also, I’ve set the Goomba to kill Mario on contact (I plan on making the Goomba a lava pit or bed of spikes later), anyways, when Mario “dies” I set the game to skip to the next frame (one that reads, Game Over) - this is where the problem is…for the convenience of the viewer/player I’d like to add a reset button. A simple gotoandplay button isn’t quite what I’m looking for, I need to respawn Mario, the coins and so on; I need to reload the game without, perhaps without actually reloading the game. One other thing too, I’d like to have the Goomba kill Mario if he walks into him, but allow Mario to kill the Goomba if he jumps on him, any ideas? Here’s my action script (thanks for any advice!):
Mario:
onClipEvent (load) {
vel_y = 0;
started = true;
jumping = false;
xspeed = 5;
this.stop();
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop(“run”);
this._xscale = -100;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(“run”);
this._xscale = 100;
}
if (Key.isDown(Key.DOWN)) {
this.gotoAndStop(“duck”);
xspeed = 0;
}
if (Key.isDown(Key.UP) && !jumping) {
this.gotoAndStop(“jump”);
move = false;
vel_y = 17;
jumpSound.start();
jumping = true;
}
if (jumping == true) {
vel_y -= 1;
if (vel_y<=-17) {
vel_y = -17;
}
this._y -= vel_y;
if (!_root.ground.hitTest(this._x, this._y+15, true) && !jumping) {
fall += 1;
move = false;
this.gotoAndStop(“jump”);
if (fall>17) {
fall = 17;
}
this._y += fall;
}
if (_root.ground.hitTest(this._x, this._y+15, true)) {
if (vel_y<=1) {
fall = 0;
vel_y = 0;
jumping = false;
this.jump.gotoAndStop(2);
move = true;
}
}
if (_root.goomba.hitTest(this.jump)) {
if (vel_y<=1) {
_root.goomba.gotoAndPlay(“dead”);
_root.goomba.xspeed = 0;
_root.counter.play();
vel_y = 10;
}
}
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (_root.mario._x>=47.0) {
scroll = 5;
xspeed = 0;
this._x += 5;
_root._x -= scroll;
_root.score._x += scroll;
}
xspeed = 5;
}
if (Key.isDown(Key.LEFT)) {
if (_root.mario._x>=272.2) {
scroll = 5;
xspeed = 0;
this._x -= 5;
_root._x += scroll;
_root.score._x -= scroll;
}
xspeed = 5;
}
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.RIGHT) {
this.gotoAndStop(“idle”);
}
if (Key.getCode() == Key.LEFT) {
this.gotoAndStop(“idle”);
}
if (Key.getCode() == Key.DOWN) {
this.gotoAndStop(“idle”);
xspeed = 5;
}
}
Goomba:
onClipEvent (load) {
xspeed = 2;
started = true;
_root.counter.stop();
b = this.getBounds(this);
}
//=======|goomba’s’s movement and collision|=======//
onClipEvent (enterFrame) {
if (started) {
if (this._xscale == 100) {
_root.counter._x -= xspeed;
this._x -= xspeed;
}
if (this._xscale == -100) {
_root.counter._x += xspeed;
this._x += xspeed;
}
}
if (_root.limits.hitTest(_x+x+b.xmin+5, _y+y+b.ymin+5, true)) {
this._xscale = -100;
}
if (_root.limits.hitTest(_x+x+b.xmax-5, _y+y+b.ymin+5, true)) {
this._xscale = 100;
}
if (!_root.ground.hitTest(this._x, this._y+15, true) && !walking) {
fall += 1;
if (fall>5) {
fall = 5;
}
this._y += fall;
}
if (this._y<=272.0) {
this._xscale = -100;
}
if (this._y>=418.0) {
this._xscale = 100;
}
if (this._x<275.0) {
this._xscale = -100;
}
if (this._x>440.0) {
this._xscale = 100;
}
}
onClipEvent(enterFrame){
if (_root.goomba.hitTest(_root.mario)){
_root.mario._x=(0);
_root.mario._y=(0);
_parent.nextFrame();
}
}
Score:
_root.score = 0;
numCoin = 2;
for (i=2; i<=numCoin; i++) {
coin.duplicateMovieClip(“coin1”+i, i+100);
_root[“coin1”+i]._x = 300;
_root[“coin1”+i]._y = 274.5
;
}
stop();
Coins:
onClipEvent (enterFrame) {
if (this.hitTest(_root.mario)) {
this.play();
_root.score += 1;
}
}
And here’s the whole FLA: