• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM How do i change the sprite by clicking a keyboard key?

L

Levy

Guest
Heya, i'm new at gamemaker but i know a few things, i'm making a 2D game and i want to add a Easter Egg, making the character dance when i click the key "E", and stops when i walk, how do i make this? Pls help
 

CloseRange

Member
Code:
if(keyboard_check_pressed(ord('E')))
    sprite_index = spr_dancing_man;
if(sprite_index == spr_dancing_man && (x != xprevious || y != yprevious))
    sprite_index = spr_walking;
sprite_index changes the image to what you want.
keyboard_check_pressed will detect a key press
ord('E') means detecting the e key
(x != xprevious || y != yprevious) is a 'hacky' way to check if you are moving
 
L

Levy

Guest
Code:
if(keyboard_check_pressed(ord('E')))
    sprite_index = spr_dancing_man;
if(sprite_index == spr_dancing_man && (x != xprevious || y != yprevious))
    sprite_index = spr_walking;
sprite_index changes the image to what you want.
keyboard_check_pressed will detect a key press
ord('E') means detecting the e key
(x != xprevious || y != yprevious) is a 'hacky' way to check if you are moving
Yoo! Thanks so much bro <3
 
Top