double jump?
- canada92
-
canada92
- Member since: Apr. 11, 2008
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
ok, my character can jump just fine with this code but i dont know how to make him double jump!
iv tried many different things but nothing works, can someone please help me out here?
i would really appreciate it =]
onClipEvent (load) {
moveSpeed = 15;
}
onClipEvent (enterFrame) {
if(Key.isDown(Key.UP)){
player.gotoAndPlay(3)
}
if (Key.isDown(Key.UP) && !jumping) {
vel_y = 45;
vel_y = 45;
jumping = true;
}
if (jumping == true) {
vel_y -= 2;
if (vel_y<=-15) {
vel_y = -15;
}
this._y -= vel_y;
}
while (_root.ground.hitTest(this._x, this._y, true)) {
vel_y = 0;
_y--
jumping = false;
}
while (_root.ground.hitTest(this._x+15, this._y-10, true)) {
_x--
}
while (_root.ground.hitTest(this._x-15, this._y-10, true)) {
_x++
}
while (_root.ground.hitTest(this._x, this._y-80, true)) {
_y++
}
}
onClipEvent (enterFrame) {
this._y += 16;
}
- canada92
-
canada92
- Member since: Apr. 11, 2008
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
oh! and my double jump animation is in frame 4
thanks!!
- Deadclever23
-
Deadclever23
- Member since: Nov. 27, 2006
- Offline.
-
- Forum Stats
- Member
- Level 12
- Blank Slate
Just do it so that if he's at a certain height compared to his original position he can jump again.
- canada92
-
canada92
- Member since: Apr. 11, 2008
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
thats easier said than done, im no expert proggramer, sure i might be able to fix up a bit of an error in actionscripting but i dont know how to translate english to flash code -__-"
do yu know along the lines of what code i should be using??
=S
- Denvish
-
Denvish
- Member since: Apr. 25, 2003
- Offline.
-
- Send Private Message
- Browse All Posts (15,977)
- Block
-
- Forum Stats
- Member
- Level 46
- Blank Slate
Something like this, but it'll probably need adapting in places
onClipEvent(load){
moveSpeed=15;
}
onClipEvent(enterFrame){
this._y+=16;
if(Key.isDown(Key.UP)){
if(!jumping){
player.gotoAndPlay(3);
vel_y=45;
jumping=1;
}
if(!doublejumping && jumping && _y<_root.ground._y-100){
player.gotoAndPlay(4);
vel_y=45;
doublejumping=1;
}
}
if(jumping || doublejumping){
vel_y -= 2;
if(vel_y<=-15){vel_y=-15;}
this._y-=vel_y;
}
while(_root.ground.hitTest(_x,_y,true)){
vel_y=0;_y--;jumping=doublejumping=0;
}
while(_root.ground.hitTest(_x+15,_y-10,true)){
_x--
}
while(_root.ground.hitTest(_x-15,_y-10,true)){
_x++
}
while(_root.ground.hitTest(_x,_y-80,true)){
_y++
}
} 


