D
Doooooli
Guest
I've run into some problems with my sprite animation! I'm making a platformer 2D game and i want the character to be able to move to the left and right and change sprite in the way he's looking!
So this is my movement code:
And then a simple
sprite8 is a sprite that changes the players sprite to look to the left! and vice versa for 7! But it doesn't work really! I can't figure out what's wrong! I don't get any error, but the doesn't change any sprite when i press A or D
anyone know what to do? thx!
So this is my movement code:
Code:
left = -keyboard_check(ord("A"));
right = keyboard_check(ord("D"));
up = keyboard_check(ord("W"));
var move = left + right;
hsp = move * movespeed;
if (!place_free(x,y+1) && up) {vsp = -movespeed;}
if (vsp < 10) {vsp += grav;}
if (!place_free(x+hsp,y))
{
while (place_free(x+sign(hsp),y))
{
x += sign(hsp);
}
hsp = 0;
}
if (!place_free(x,y+vsp))
{
while (place_free(x,y+sign(vsp)))
{
y += sign(vsp);
}
vsp = 0;
}
x += hsp;
y += vsp;
Code:
if(left) then { sprite_index = sprite8 }
if(right) then { sprite_index = sprite7 }
anyone know what to do? thx!