GMS 2 [SOLVED]New to GMS

Q

Quantum_Compooter

Guest
I am new to GMS as in I have less than 24 hours with it. I am simply trying to go from an idle animation to a run animation and back. I am using Spine Pro for the sprite animation. Anytime I move my sprite it just freezes. If I understand correctly it is because every "tick" it is restarting my run animation but I do not know how to rectify this. Any help would be greatly appreciated.

Code:
key_right = keyboard_check(ord("D"));
key_left = keyboard_check(ord("A"));
mv_dir = key_right - key_left;


movement = mv_dir * walksp;

x += movement;

if(mv_dir != 0){
  image_xscale = mv_dir;
  skeleton_animation_set("Run");
}else{
  skeleton_animation_set("Idle");
}
 

rIKmAN

Member
I am new to GMS as in I have less than 24 hours with it. I am simply trying to go from an idle animation to a run animation and back. I am using Spine Pro for the sprite animation. Anytime I move my sprite it just freezes. If I understand correctly it is because every "tick" it is restarting my run animation but I do not know how to rectify this. Any help would be greatly appreciated.

Code:
key_right = keyboard_check(ord("D"));
key_left = keyboard_check(ord("A"));
mv_dir = key_right - key_left;


movement = mv_dir * walksp;

x += movement;

if(mv_dir != 0){
  image_xscale = mv_dir;
  skeleton_animation_set("Run");
}else{
  skeleton_animation_set("Idle");
}
Assuming this is a Step Event, you are setting the animation every single frame which results in it being set back to frame 0 every frame and this is why it appears to "freeze" - it's just frame 0 every frame.

Add a check to see what animation is already playing before you set it, for example you only want to change to the "run" animation if the run animation isn't already playing.
 
Q

Quantum_Compooter

Guest
Assuming this is a Step Event, you are setting the animation every single frame which results in it being set back to frame 0 every frame and this is why it appears to "freeze" - it's just frame 0 every frame.

Add a check to see what animation is already playing before you set it, for example you only want to change to the "run" animation if the run animation isn't already playing.
Ok I will give this a try. I appreciate it.
 
Top