K
Krano Network Squirrell
Guest
I am trying to make a walking animation where my character uses 4 different sprites per direction, but when I try to edit Image Speed it only applies to one sprite! I need help, as soon as my character is moving it should play the animation and when it stops moving show the first frame facing the same direction, but it isn't working.
Code:
///actions
//movement AAA
key_right = keyboard_check(ord("D")) || (gamepad_axis_value(0,gp_axislh) > 0) || keyboard_check(vk_right);
key_left = keyboard_check(ord("A")) || (gamepad_axis_value(0,gp_axislh) < 0) || keyboard_check(vk_left);
Key_up = keyboard_check(ord("W")) || (gamepad_axis_value(0,gp_axislv) < 0) || keyboard_check(vk_up);
key_down = keyboard_check(ord("S")) || (gamepad_axis_value(0,gp_axislv) > 0) || keyboard_check(vk_down);
//react to imputs
var moveV = key_right - key_left;
var moveH = Key_up - key_down;
hsp = moveV * movespeedwalk
vsp = moveH * movespeedwalk
//H Collision
if (place_meeting(x+hsp,y,obj_wall))
{
while (!place_meeting(x+sign(hsp),y,obj_wall))
{
x = x + sign(hsp);
}
hsp = 0;
}
x = x + hsp;
//V Collision
if (place_meeting(x,y+vsp,obj_wall))
{
while(!place_meeting(x,y+sign(vsp),obj_wall))
{
y = y + sign(vsp);
}
vsp = 0;
}
y = y + vsp;
//animation
if (moveH > 0)
{
sprite_index = spr_neko_walkF
}
if (moveH < 0)
{
sprite_index = spr_neko_walkB
}
if (moveV > 0)
{
sprite_index = spr_neko_walkR
}
if (moveV < 0)
{
sprite_index = spr_neko_walkL
}
if (hsp * vsp = 0)
{
sprite_index = 0
image_speed = 1
}