·

How to Flip Your Character in GameMaker

One of the basic things you’ll want is for your character to face the right way. Luckily, GameMaker makes this super simple.

The Setup

We’ll assume a side-view game where your character can face left or right. Instead of drawing two sprites, we’ll use just one right-facing sprite and let GameMaker flip it for us.

Using image_xscale

GameMaker gives every sprite a property called image_xscale, which controls how wide it’s drawn. By default, it’s set to 1, meaning the sprite shows at its normal size. If you set it to a bigger number, the sprite stretches wider; a smaller number squishes it.

The really useful part, though, is that a negative value flips the sprite. Setting image_xscale = -1 makes your right-facing sprite instantly face left. You won’t need a second, left-facing sprite!

Flip with the Mouse

To make the character face the mouse, add this to the Step Event:

if (mouse_x > x) {
    image_xscale = 1;  // face right
}
if (mouse_x < x) {
    image_xscale = -1; // face left
}

Since the sprite starts facing right, 1 is your default. Flipping to -1 makes it look left without a second sprite required!

That’s all it takes to get your character turning naturally!