BananaPandaDemographic
Member
when i move the attack animation plays instead of my move animation. trying to get the hang of states.
step
animation end
if (sprite_index == sPYattack) state = st.normal;
step
Code:
switch(state)
{
case st.normal:
{
scrPinputs()
vsp = vsp + grv;
hsp = 0
if (key_left) || (key_right)
{
state = st.move;
}
if (key_enter)
{
state = st.attack;
}
sprite_index = sPYand;
scrCollision()
break;
}
case st.move:
{
scrPinputs()
//Calculate movement
var move = key_right - key_left;
hsp = move * walksp;
vsp = vsp + grv;
if (hsp != 0) image_xscale = sign(hsp);
image_speed = 1;
sprite_index = sPYmove;
if (hsp = 0)
{
state = st.normal;
}
if (key_enter)
{
state = st.attack;
}
scrCollision()
}
case st.attack:
{
scrPinputs()
vsp = vsp + grv;
{
//Animate
sprite_index = sPYattack;
if (image_index >= 1) && (image_index <= 3)
{
instance_create_layer(x,y,layer,oHitbox)
}
}
scrCollision()
}
}
if (sprite_index == sPYattack) state = st.normal;