Greetings. I am currently hammering away on a section of my portfolio that will be centered around Super Mario Brothers for the NES (long story.)
Anyway;
I am currently having a rather difficult time with getting the scrolling behavior down. I’ve attached my latest FLA for you examination, its currently hell on toast.
The dimensions of the frame is 900 X 400 but it is currently subject to change. The level I am plotting is larger that the dimensions of the frame, this is where scroilling supposedly comes into play.
I’ve come across two massive problems when I attempted to implement scrolling.
1.) I’ve been able to get my character to stop at the left and right boundaries of the level but if I hold down, for example, the right arrow, the ‘camera’ keeps scrolling right indefinately as long as the right arrow is held down. This simply won’t do and I’ve been so far unsuccesful in trying to have the ‘camera’ stop at the level boundaries along with Mario. I currently have a method working for the left side of the screen but the right scrolling still isn’t working. It also causes …
2.) I can’t get my character to have the freedom of movement he should have once things start scrolling. The scrolling is based on his movement and while i’ve come up with a crude method of making the character and the camera stop when he reaches the left side of the screen when he then tries to proceed right the level scrolls right but he still stuck in the left hand side of the screen.
As I said, i’ve attached the file but if for whatever reason the file won’t open here is the Actionscript in question which is attached to the character.
[SIZE=1]//movement
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
this._x -= xspeed;
}
if (Key.isDown(Key.RIGHT)) {
this._x += xspeed;
}
if (started) {
if (move) {
if (Key.isDown(Key.DOWN)) {
this.gotoAndStop(“duck”);
xspeed = 0;
}
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop(“run”);
this._xscale = -100;
}
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(“run”);
this._xscale = 100;
}
}
}
}
//idle animations
onClipEvent (keyUp) {
if (move) {
if (Key.getCode() == Key.RIGHT) {
this.gotoAndStop(“idle”);
}
if (Key.getCode() == Key.LEFT) {
this.gotoAndStop(“idle”);
}
if (Key.getCode() == Key.DOWN) {
this.gotoAndStop(“idle”);
}
}
}
//jumping
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP) && !jumping) {
this.gotoAndStop(“jump”);
move = false;
vel_y = 17;
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;
vel_y = 10;
_root.counter.play();
}
}
}
//questionable scrolling effect
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
scroll = 5;
xspeed = 0;
this._x -= 5;
_root._x += scroll;
}
if (Key.isDown(Key.RIGHT)) {
scroll = 5; //setting his scrolling speed//
xspeed = 0; //ceasing his movement//
this._x += 5;
_root._x -= scroll;
}
}
//level barriers
onClipEvent (enterFrame) {
//level barrier (left)
if (_root._x > 0 && _root._x <600) {
_root._x = 0;
}
if (this._x<20) {
this._x = 20;
}
// level barrier (top)
if (this._y<0) {
this._y = 0;
}
// level barrier (bottom);
if (this._y>500) {
this._y = 500;
}
// level barrier (right)
if (this._x>1244) {
this._x = 1244;
}
//grond text xMax
if (_root.ground.hitTest(getBounds(_root).xMax, _y, true)) {
_x -= xspeed;
}
//ground test xMin
if (_root.ground.hitTest(getBounds(_root).xMin, _y, true)) {
_x += xspeed;
}
}[/SIZE]
Any help would greatly be appreciated.
-Brian Peterson
http://www.enorme.org/peterson/
I’m trying to achieve the same type of freedom that he had in the original game.