J
Jack
Guest
Hey, I have an animation bug atm. I know the problem just not how to fix it.
My problem is that when my player spawns in he is rolling through the attack animation automatically even though its supposed to be only when you press X. I have tried to fix this only to mess up something else so if you have a solution PLEASE tell me. Thanks! (this is a brand new project so barely any code yet.
Step Event:
//sprites
//LR animations (working fine)
if (keyboard_check(ord('D'))) {
image_index=1;
}
if (keyboard_check(ord('A'))) {
image_index=2;
}
//attack animation (broken)
if (keyboard_check(ord('X'))) {
sprite_index = spr_player_attack
image_speed = 1;
}
else
{
sprite_index = spr_player;
}
//player movement
hspeed = flyspd * (keyboard_check(ord('D')) - keyboard_check(ord('A')));
vspeed = flyspd * (keyboard_check(ord('S')) - keyboard_check(ord('W')));
//collisions
if hspeed!=0
if !place_free(x+hspeed,y)
{
if hspeed>0 move_contact_solid(0,hspeed)
if hspeed<0 move_contact_solid(180,-hspeed)
hspeed=0
}
if vspeed!=0
if !place_free(x+hspeed,y+vspeed)
{
if vspeed>0 move_contact_solid(270,vspeed)
if vspeed<0 move_contact_solid(90,-vspeed)
vspeed=0
}
My problem is that when my player spawns in he is rolling through the attack animation automatically even though its supposed to be only when you press X. I have tried to fix this only to mess up something else so if you have a solution PLEASE tell me. Thanks! (this is a brand new project so barely any code yet.
Step Event:
//sprites
//LR animations (working fine)
if (keyboard_check(ord('D'))) {
image_index=1;
}
if (keyboard_check(ord('A'))) {
image_index=2;
}
//attack animation (broken)
if (keyboard_check(ord('X'))) {
sprite_index = spr_player_attack
image_speed = 1;
}
else
{
sprite_index = spr_player;
}
//player movement
hspeed = flyspd * (keyboard_check(ord('D')) - keyboard_check(ord('A')));
vspeed = flyspd * (keyboard_check(ord('S')) - keyboard_check(ord('W')));
//collisions
if hspeed!=0
if !place_free(x+hspeed,y)
{
if hspeed>0 move_contact_solid(0,hspeed)
if hspeed<0 move_contact_solid(180,-hspeed)
hspeed=0
}
if vspeed!=0
if !place_free(x+hspeed,y+vspeed)
{
if vspeed>0 move_contact_solid(270,vspeed)
if vspeed<0 move_contact_solid(90,-vspeed)
vspeed=0
}