V
vleermuis2003
Guest
i am just new to gamemaker studio 2 and programming itself. and still learning the basics, but now i ran in another issue i can't figure out.
i am a little bit struggling with my code for moving with my sprites. but everything seems to work fine now, but the only issue i still got is that my running sprite stops already after 1 frame while i am still moving.
i don't know what i am doing wrong so i hope someone could help me out!
here is my code for the animated sprite movement:
i am a little bit struggling with my code for moving with my sprites. but everything seems to work fine now, but the only issue i still got is that my running sprite stops already after 1 frame while i am still moving.
i don't know what i am doing wrong so i hope someone could help me out!
here is my code for the animated sprite movement:
GML:
//sprite animation movements
if (x > xprevious)
{
image_speed = 1;
sprite_index = PLAYERRUN;
}
if (x < xprevious)
{
image_speed = 1;
sprite_index = PLAYERRUN;
}
if (y > yprevious)
{
sprite_index = PLAYERJUMP;
image_index = 1;
image_speed = 1;
if(place_meeting(x,y,objectWALLMETAL)) and hspeed = 0
{
sprite_index = PLAYER;
image_speed = 0;
}
if(place_meeting(x,y,objectWALLMETAL)) and hspeed != 0
{
image_speed = 1;
sprite_index = PLAYERRUN;
}
if(place_meeting(x,y,ObjectROCKANDGRASSPATH))and hspeed = 0
{
sprite_index = PLAYER;
image_speed = 0;
}
if(place_meeting(x,y,ObjectROCKANDGRASSPATH)) and hspeed != 0
{
image_speed = 1;
sprite_index = PLAYERRUN;
}
}
if (y < yprevious)
{
sprite_index = PLAYERJUMP;
image_index = 0;
image_speed = 1;
if(place_meeting(x,y,objectWALLMETAL)) and hspeed = 0
{
sprite_index = PLAYER;
image_speed = 0;
}
if(place_meeting(x,y,objectWALLMETAL)) and hspeed != 0
{
image_speed = 1;
sprite_index = PLAYERRUN ;
}
if(place_meeting(x,y,ObjectROCKANDGRASSPATH)) and hspeed = 0
{
sprite_index = PLAYER;
image_speed = 0;
}
if(place_meeting(x,y,ObjectROCKANDGRASSPATH)) and hspeed != 0
{
image_speed = 1;
sprite_index = PLAYERRUN;
}
}
if (hspeed = 0) and (vspeed = 0)
{
sprite_index = PLAYER;
image_speed = 1;
}