ForumsProgramming ForumJumping kick, Please Help

8 3239
staticzone
offline
staticzone
67 posts
Nomad

I have a character that you can control, but the problem is that when he jumps he is still. I want him to be running then you jump and kick like a combo sort of. How do you make him do something as he is jumping?

  • 8 Replies
staticzone
offline
staticzone
67 posts
Nomad

Anyone?

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

what do you mean? Do you want him to play a movie clip while he is jumping?

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

First, you need a set of frames for the kick animation.
Then, In your code where you tell the character to jump add:
if(xspeed > 0 or xspeed < 0) // assuming you have an xspeed variable
{
_root.character.gotoAndPlay(2); // assuming the kick animation starts at frame 2.
}

And in the last frame inside the character add:
gotoAndStop(1);

Voidcrystal
offline
Voidcrystal
138 posts
Nomad

haha ab, do you always have to help every0ne ;P? I get no one to help hehe ^^.

No actually i like that you are taking your time to help everyone.

staticzone
offline
staticzone
67 posts
Nomad

Well here is my code on the guy


onClipEvent (load) {
power = 3;
radius = 10;
_x = 85;
_y = 193;
}
onClipEvent (enterFrame) {

if (Key.isDown(Key.DOWN)) {

this._y = this._y+10;

gotoAndStop(2);

}

if (Key.isDown(Key.UP)) {

this._y = this._y-10;

gotoAndStop(4);

}

if (Key.isDown(Key.RIGHT)) {

this._x = this._x+10;

gotoAndStop(3);

}

if (Key.isDown(Key.LEFT)) {

this._x = this._x-10;

gotoAndStop(5);

}


if (Key.isDown(Key.ALT)&&(Key.LEFT)) {

this._x = this._x-10;

gotoAndStop(6);

}

if (Key.isDown(Key.ALT)&&(Key.RIGHT)) {

this._x = this._x+10;

gotoAndStop(6);

}
}
while (_root.wall.hitTest(_x, _y+radius, true)) {
_y--;
}
while (_root.wall.hitTest(_x, _y-radius, true)) {
_y++;
}
while (_root.wall.hitTest(_x-radius, _y, true)) {
_x++;
}
while (_root.wall.hitTest(_x+radius, _y, true)) {
_x--;
}
if ((_root.cop.hitTest(_x, _y+radius, true)) or (_root.cop.hitTest(_x, _y-radius, true)) or (_root.cop.hitTest(_x+radius, _y, true)) or (_root.cop.hitTest(_x-radius, _y, true))) {
_x = 85;
_y = 193;
}
}

onClipEvent (keyUp) {
gotoAndPlay(1);
}




I want to do like a combo of two buttons but its not working,

Basicly want i want to do is to be able to hold down the RIGHT arrow key then press alt to jump, and he jumps right.

AbnormalIdiot
offline
AbnormalIdiot
110 posts
Nomad

First of all, I'm gonna teach your a couple shortcuts. Instead of using "this._x" you can just use "_x" and instead of using "_y = _y + 10;" you can use "_y += 10;"


Second of all, your code, if it worked properly, would make you move twice as fast to the left or right when alt is pressed. Instead, right after checking if the right arrow key is pressed add:

else if(Key.isDown(Key.ALT) && Key.isDown(Key.RIGHT))
{
_y += 10;
_x += 10;
}
And do the same thing after left, but lower the x value instead of increasing it.

For some reason, anything using the alt key isn't working. Maybe you could use space?


VoidCrystal: Nope, actually I can't help most people, I've just gotten lucky recently =P

staticzone
offline
staticzone
67 posts
Nomad

Ok ill try it, thank you

tehQED
offline
tehQED
33 posts
Nomad

AbnormalIdiot is right. If that doesn't work, try making a button like spacebar jump. Keyboards are hooked up weird; sometimes certain keys won't work when pressed at the same time

Showing 1-8 of 8