|
-
jumping on a slope!
I have this rather cool code for a _mc on a slope. The only problem I am having is making the sprite.mc change states/animation when the sprite.mc is jumping. Can you help? duh...
here's the code I have:
onClipEvent(load){
speed = 5;
gravity = 0;
r = _height/2; //radius
jumping = false;
jumpingheight = 15;
}
onClipEvent(enterFrame){
if(key.isDown(key.RIGHT)){
_x + =speed;
}
if(key.isDown(key.LEFT)){
_x - =speed;
}
if(key.isDown(key.UP) &&! jumping){
jumping = true;
gravity = -jumpheight;
}
if(!_root.ground.hitTest(_x,_y, true)){
gravity++;
_y+ = gravity;
}else{
jumping =false;
gravity = 0;
}
while(_root.ground.hitTest(_x,_y-1+r,true)){
jumping = false;
_y--;
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|