0

I put this code for my sprite to reverse the position according to its direction but it reverses the position and it looks skinny. How to fix this?

key_left = keyboard_check(ord("A"))
key_right = keyboard_check(ord("D"))
key_jump = keyboard_check(vk_space)



var move = key_right - key_left

hspd = move * spd;

vspd = vspd + grv;

if (hspd != 0) {
image_xscale = sign(hspd)
}
halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

2

The code's correct. You must have resized the sprite in the room editor, delete the instance and put it in again and don't resize it, it should work.

Also if you need it a little bigger you can (If 1.5 doesn't satisfy you, feel free to use a bigger number).

image_xscale = sign(hspd) * 1.5;
hell
  • 21
  • 4
1

The code seem to be correct, have you tried setting the origin point at the center? By default the origin point is on the top-left, and once it's set at the center of your sprite, it won't change positions when turning around.

You can set the origin point at the sprite window.

Steven
  • 1,996
  • 3
  • 22
  • 33