I started following this tutorial and wanted to resolve something before continuing.
Around the 3:46 mark, she mentions that if you're using a different sprite for idle, then to use another switch statement.
So, I tried this and my player always faces to the right when going idle.
Any ideas, why the idle switch statement isn't working? Thank you!
Around the 3:46 mark, she mentions that if you're using a different sprite for idle, then to use another switch statement.
So, I tried this and my player always faces to the right when going idle.
GML:
// Movement
hInput = keyRight - keyLeft;
vInput = keyDown - keyUp;
dir = point_direction(0,0,hInput,vInput);
if (hInput != 0 or vInput != 0)
{
moveX = lengthdir_x(spd, dir);
moveY = lengthdir_y(spd, dir);
x += moveX;
y += moveY;
// Set Sprite
switch(dir)
{
case 0: sprite_index = sPlayer_Walk_R; break;
case 90: sprite_index = sPlayer_Walk_U; break;
case 180: sprite_index = sPlayer_Walk_L; break;
case 270: sprite_index = sPlayer_Walk_D; break;
}
image_speed = 0.4;
}
else
{
// Set Sprite
switch(dir)
{
case 0: sprite_index = sPlayer_Idle_R; break;
case 90: sprite_index = sPlayer_Idle_U; break;
case 180: sprite_index = sPlayer_Idle_L; break;
case 270: sprite_index = sPlayer_Idle_D; break;
}
image_speed = 0.4;
}
Last edited: