• 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!

Moving Problems

W

whickedarkness

Guest
Hello I made a character with a walking left animation and a walking right animation also with an idle animation when i go to code my character to move left he jumps to the left but when i click the right key he moves right with no problems any suggestions? all my sprites are also centered im using the Drag And Drop coding also
 
Last edited by a moderator:
B

betitoas1

Guest
var sp = 3
If keyboard_check(vk_right) {
x+=sp;
image_xscale =1
sprite_index(spr_player_walking)
}
If keyboard_check(vk_left) {
x-=sp;
image_xscale = -1
sprite_index(spr_player_walking)
}
If keyboard_check(vk_nokey) {
sprite_index = spr_player_iddle
sp = 0
}
 
W

whickedarkness

Guest
var sp = 3
If keyboard_check(vk_right) {
x+=sp;
image_xscale =1
sprite_index(spr_player_walking)
}
If keyboard_check(vk_left) {
x-=sp;
image_xscale = -1
sprite_index(spr_player_walking)
}
If keyboard_check(vk_nokey) {
sprite_index = spr_player_iddle
sp = 0
}
sprite index not found
 
D

DevNorway

Guest
Try this instead.
Create event-
Code:
spd = 3;
move = 0;

Step event-

Code:
move = keyboard_check(vk_left) + -keyboard_check(vk_right)
if move != 0 {
    image_xscale = sign(move);
    sprite_index = PUT IN YOUR MOVING SPRITE HERE
} else {
    sprite_index = PUT IN YOUR IDLE SPRITE HERE
}
 
Top