PDA

View Full Version : [AS2] Platform game help


Miller@KN
12-14-2010, 01:55 PM
I am making a platform style game but my plateform does not work right instead of the charactor having to jump up stairs or on top of a pillar the charactor just automatically bumps to the top of it. Is there some other way to do the script so that the blocks will prevent the charactor from moving through them without it bumping him to the top this is my script so far.

onClipEvent(load){
speed = 15
gravity = 0;
r =_height/2;
jumping = false;
jumpheight = 15;
running = 10
}
onClipEvent (enterFrame){
if(Key.isDown(Key.UP) && !jumping){
gravity = -jumpheight;
jumping = true;
}
if(!_root.ground.hitTest(_x, _y, true)){
gravity++;
_y += gravity;
}else{
jumping = false;
running = false;
gravity = 0;
}
while(_root.ground.hitTest(_x,_y-1 +r, true)){
jumping = false;
_y--;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
play();
_x+= speed;
_xscale = -scale;
} else {

if (Key.isDown(Key.LEFT)) {
play();
_x -= speed;
_xscale = scale;
} else {
stop();
}
}
}