J
Jadie
Guest
Hi,
I am new to Gamemaker and I am making my first 8Bit pixel art game. I am trying to get my player to change sprite animation when collecting an item. I have tried to use a variable to do this in the collision event for the player and the object its is colliding with, but nothing is changing. Please see below!
Thanks,
Jadie
I am new to Gamemaker and I am making my first 8Bit pixel art game. I am trying to get my player to change sprite animation when collecting an item. I have tried to use a variable to do this in the collision event for the player and the object its is colliding with, but nothing is changing. Please see below!
Thanks,
Jadie
Code:
//STEP EVENT TO MAKE THE PLAYER MOVE //
playerSpeed = 2;
playerState = 1;
MOVELEFT = keyboard_check(vk_left);
MOVERIGHT= keyboard_check(vk_right);
MOVEUP = keyboard_check(vk_up);
MOVEDOWN = keyboard_check(vk_down);
NOBUTTON = keyboard_check(vk_nokey);
if (MOVELEFT){
playerState = 1;
x -= playerSpeed;
image_xscale = -2;
}
if (MOVERIGHT){
playerState = 1;
x += playerSpeed;
image_xscale = +2;
}
if (MOVEUP){
sprite_index = spr_up;
y -= playerSpeed;
}
if (MOVEDOWN){
sprite_index = spr_down;
y += playerSpeed;
}
if (NOBUTTON){
sprite_index = spr_standing;
}
with (obj_eardef){
playerState = 2;
}
// PLAYER COLLISION EVENT WITH OTHER OBJECT//
playerState = 1;
if playerState = 1 { sprite_index = spr_walking;
}
if (playerState == 2){
sprite_index = spr_earwear;
}