-
How do I combine states?
Fiddling about with a clone of the arcade game Kung Fu Master. I nailed standing kick and punch with collision box. My problem is when I combine states.
I have Alterable variables to check what state the player is in: Face left, face right, stand punch, stand kick, jump, crouch and crouch kick so far.
Now, I can't figure out how to enable the crouch kick state while in the crouch state, any tips?
Setup for crouch is like this:
Events -
Repeat while joystick is held down
PMO - Object is standing on ground
stand punch = 0
stand kick = 0
crouch kick = 0
Code -
Change speed of animation: 15
Change animation sequence to crouch down
Event 2 -
animation crouch down is playing
code-
set crouch to 1
Event 3 -
animation crouch down has finished playing
code-
set crouch to 0
Setup for crouch kick is like this:
Events -
Pressed fire 2
Repeat while joystick is held down
PMO - Object is standing on ground
stand punch = 0
stand kick = 0
crouch kick = 0
only one action per loop
Code-
Change speed of animation to 15
Change animation sequence to crouch kick
Event 2-
animation crouch kick is playing
only one action when event loops
code-
create hitbox at location x,y
set crouch kick to 1
Event3-
Animation crouch kick has finished
code-
Set crouch kick to 0
destroy hitbox
-
Or, to make it more simple:
If alterable value crouch = 1 and joystick fire 2 is pressed then alterable value crouch kick = 1 and alterable value crouch = 0.
The issue I have with this state setup is that when the state crouch kick = 1 I can't get out of the crouch kick animation, I tried setting a condition to check whether the crouch kick animation has ended, but I guess that due to the nature of states the crouch kick animation plays infinitely, what would you do in order to be able to stand, crouch and crouch kick?