Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 ViewsOk, I am working on a fighting engine and I learned some basic code to get this punch to work and so far it you hold the A key she will keep doing the same attack. How do I make it like a regular fighting game where if you press the button, the character will only attack once if the button is held but do a combo if you press 3 times continuously.
This is the code
onClipEvent (load) {
attack = false;
}
onClipEvent (enterFrame) {
if (attack == false) {
if (Key.isDown(Key.RIGHT)) {
gotoAndStop(2);
this._x += 4;
} else if (Key.isDown(Key.LEFT)) {
gotoAndStop(3);
this._x -= 4;
} else {
gotoAndStop(1);
}
if (Key.isDown(65)) {
gotoAndStop(4);
attack = true;
}
}
} Sorry for double post but forgot to add example.
http://megaswf.com/serve/1934965
Well it would be a nice idea to use the currentFrame attribute to determine where the animation is and act accordingly.
Here is what I would do:
I would set a variable to true when the character starts attacking
when a key is pressed, I would check if the character is attacking (variable).
If the player is attacking, I would check what frame he is to determine the animation
ex: (10 to 20 = punching)
If the frames match to a moment where a combo is possible, I would tell the MC to play the next move
If the frames do not match, I would do nothing
Also, checking every frame where the animation is could be important. That way you can trigger actions based on where the animation is. One important example is to bring back the player to the "idle" animation when its over and setting the "attacking" variable to false.
If you are wondering why I am not giving you any code, that's because you need to learn to think about what you are doing instead of copy-pasting code.
Either way if I would hold the A key wouldn't it just go straight through the combo? Since I am holding A anyway and the punch doesn't stop even though I am still holding A?
at the last frame of your attack animation (inside movie clip) type in on the last frame:
_root.gotoAndStop("idle");
idle = the mc of your idle pose
and on your idle frame (not inside idle movie clip) type in:
stop(); I have that, I have 4 movie clips in one. The 4th one is the punch on the last frame of the punch movie clip it is directed back to that main movie clip(with the 4 inside) using root and Instance Name to go back to the idle frame.
try the false function
this.attack = false;
(attack would be the instance of your attack animation)
i might be wrong
I know it was ages ago but did you ever solve this problem?
At 2/3/14 10:00 AM, smivie wrote: I know it was ages ago but did you ever solve this problem?
Considering the the OP hasn't posted for over two years it's safe to say she's not going to see your question. Please don't pointlessly revive old threads. If you have a problem that is similar to hers just post a new thread and ask for help.