Major Platforming Issues!

Okay, here’s the deal: I’m making a platformer/RPG. Here’s my main problem: The platforming doesn’t work. I’ve TRIED to program it so that the elf animates but it’s the background that actually moves, so when he jumps, the background moves.

Instead, he freezes in the jumping pose and doesn’t move.

So yah, if you could give me a hand with the coding.

WARNING: Requires Flash 8 :frowning:

THE FILE: http://lfs.lfhost.com/clocktowers/ELF.fla

Umm, have you looked over the internet? And, i’m actually working on a platformer myself: Here’s the jump code:

if (jumping) {
	vel_y -= 1;
	if (vel_y<=-10) {
		vel_y = -10;
	}
	this._y -= vel_y;
}
if (Ledge.hitTest(this._x, this._y+this._height/2+15, true)) {
	vel_y = 0;
	jumping = false;
}

Gah, forgot to post the code. >_<

onClipEvent (load) {
    gravity = 10;
    scale = _xscale;
    walkSpeed = 6;
    maxjump = 6;
}
onClipEvent (enterFrame) {
    if (air == true) {
        _root.loller1.y -= gravity;
        state = 3;
    }
    if (Key.isDown(Key.LEFT) && !_root.leftbound.hitTest(_x, _y, true)) {
        _root.loller1.x += walkSpeed;
        _xscale = -scale;
    }
    if (Key.isDown(Key.RIGHT) && !_root.rightbound.hitTest(_x, _y, true)) {
        _root.loller1.x -= walkSpeed;
        _xscale = scale;
    }
    if (_root.loller1.platforms.hitTest(_x, _y, true)) {
        air = false;
    } else {
        air = true;
    }
    if (Key.isDown(Key.SPACE) && jump == true) {
        _root.loller1.y += jumpSpeed;
    }
    if (air == false) {
        jump = true;
        jumpcount = 0;
        jumpSpeed = 22;
    }
    if (Key.isDown(Key.SPACE)) {
        jumpcount += 1;
    }
    if (jumpcount > maxjump && jumpSpeed > -2) {
        jumpSpeed -= 2;
    }
    if (air == false && !Key.isDown(Key.LEFT) && !Key.isDown(65) && _currentframe < 4 or air == false && !Key.isDown(Key.RIGHT) && !Key.isDown(65) && _currentframe < 4) {
        state = 1;
    }
    if (Key.isDown(Key.LEFT) && air == false && !Key.isDown(65) && _currentframe < 4 or Key.isDown(Key.RIGHT) && air == false && !Key.isDown(65) && _currentframe < 4) {
        state = 2;
    }
    if (!Key.isDown(65)) {
        gotoAndStop(state);
    }
    _root.statetxt = state;
}
onClipEvent (keyUp) {
    if (Key.getCode() == 83) {
        jump = false;
    }
}

try changing the _root.loller1.x to _root.loller1._x , same with the y’s (to _y)

looks like you are just moving the property x of loller without moving it on stage (_x)

maybe this will answer your question?

Gah, tried that, still not working. Here’s the Flash file, maybe a look at the whole thing would help. >_<

http://lfs.lfhost.com/clocktowers/ELF.fla

Alright, I’ve decided to try to use Nathan’s code, but my computer keeps reporting the same syntax error, that being:
[COLOR=red]Error Scene=level 1, layer=Layer 2, frame=1:Line 34: ‘)’ expected
speed++;

Total ActionScript Errors: 1 Reported Errors: 1[/COLOR]
Now, the code in question:

} else if (Key.isDown(Key.RIGHT)) {
if (speed
speed++;
}

Now I have a feeling something is missing, so I try:

} else if (Key.isDown(Key.RIGHT)) {
if (speed<maxmove) {
speed++;
}

I get the following error:
[COLOR=red]Error Scene=level 1, layer=Layer 2, frame=1:Line 7: Statement block must be terminated by '}'
onClipEvent (enterFrame) {

Error Scene=level 1, layer=Layer 2, frame=1:Line 62: Syntax error.
}

Total ActionScript Errors: 2 Reported Errors: 2[/COLOR]

In response to which I try adding a } on the last line.

…And then the entire thing goes to hell. Check the links to see the what I mean. o_O;

FLA: http://rapidshare.de/files/17613951/ELF.fla.html
SWF: http://img127.imageshack.us/my.php?image=elf5cf.swf (NOTE: The preloader is a bit glitchy, so just right click and press play after it reaches 90% or so.)

Try this. Not sure exactly what I did but it seems to work.
http://rapidshare.de/files/17615020/ELF.fla.html

Geh, it still has some glitches. He only faces right, and only falls when he jumps. >_<

what I would do, is, make 2 mcs, the characer instance name, c, and the ground, instance name, gr;

then I woukld modify this code;

sh = 20, c.ysp=4
c.onEnterFrame = function() {
 Key.isDown(Key.UP) && !jumping ? (jumping=true, jump=-20) : !gr.hitTest(this._x, this._y+1, true) && !jumping ? this._y+=this.ysp++ : null;
 jumping ? ((!Key.isDown(Key.UP) && jump<=-3 ? jump *= .5 : null), (jump<=-3 ? this._y += (jump *= .85) : jump>-3 ? this._y += (jump++) : null)) : null;
 Key.isDown(Key.LEFT) && !gr.hitTest(this.getBounds(_root).xMin, this._y-sh, true) ? this._x -= 3 : Key.isDown(Key.RIGHT) && !gr.hitTest(this.getBounds(_root).xMax, this._y-sh, true) ? this._x += 3 : null;
 while (gr.hitTest(this._x, this._y, true)) {
  this._y--, this.ysp = 4, jump=jumping=false;
 }
};

See, thing is I’m very new to actionscript, and wouldn’t know what to change. My main problem with that code is that my game is intented to be a sidescroller. >_<

how exactly do you want it?

So that the screen follows the character across the level, and that the character us always centered on the screen.

sh = 20, c.ysp=4
c.onEnterFrame = function() {
 Key.isDown(Key.UP) && !jumping ? (jumping=true, jump=-20) : !gr.hitTest(this._x, this._y+1, true) && !jumping ? this._y+=this.ysp++ : null;
 jumping ? ((!Key.isDown(Key.UP) && jump<=-3 ? jump *= .5 : null), (jump<=-3 ? this._y += (jump *= .85) : jump>-3 ? this._y += (jump++) : null)) : null;
 Key.isDown(Key.LEFT) && !gr.hitTest(this.getBounds(_root).xMin, this._y-sh, true) ? gr._x += 3 : Key.isDown(Key.RIGHT) && !gr.hitTest(this.getBounds(_root).xMax, this._y-sh, true) ? gr._x -= 3 : null;
 while (gr.hitTest(this._x, this._y, true)) {
  this._y--, this.ysp = 4, jump=jumping=false;
 }
};