K
keex
Guest
switch(dirr_state){
case direction_state.left:
x_sprite_center = x + (sprite_width/2);
y_sprite_center = y + (sprite_height/2);
if(xx >= x_sprite_center){
dirr_state = direction_state.right;
image_xscale = -1;
}
break;
case direction_state.right:
x_sprite_center = x - (sprite_width/2);
y_sprite_center = y + (sprite_height/2);
if(xx <= x_sprite_center){
dirr_state = direction_state.left;
image_xscale = 1;
}
break;
}
This is the code and the state machine works as long as you hold down the button but as soon as you let go it moves to the position and then changes the state back to left. Been trying to figure out why this is happening but cant find a solution. if i were to add the image_xscale variable before the if statements it kinda works but i get some visual bugs where it reverts back and forth 1 time before settling on the state.