Dragonfly

Question: How do you flip a sprite in GameMaker?

Answer

Flipping a sprite in GameMaker can be done by adjusting the image_xscale and image_yscale properties of an instance. These properties can be set to -1 to flip a sprite horizontally or vertically.

Here's how you can flip a sprite:

Horizontally:
CODE_BLOCK_PLACEHOLDER_0

Vertically:
CODE_BLOCK_PLACEHOLDER_1

When flipping sprites, consider the following points:

Finally, if you need to flip the sprite for a specific drawing event rather than altering the instance itself, use the draw_sprite_ext function:

// Draw the sprite flipped horizontally without affecting the instance's actual image_xscale
draw_sprite_ext(sprite_index, image_index, x, y, -1, 1, 0, c_white, 1);

// Draw the sprite flipped vertically without affecting the instance's actual image_yscale
draw_sprite_ext(sprite_index, image_index, x, y, 1, -1, 0, c_white, 1);

In this way, flipping is done on-the-fly during rendering and does not change the underlying properties of the instance.

Was this content helpful?

Other Common Game Engines Questions (and Answers)

White Paper

Free System Design on AWS E-Book

Download this early release of O'Reilly's latest cloud infrastructure e-book: System Design on AWS.

Free System Design on AWS E-Book

Switch & save up to 80% 

Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement. Instantly experience up to a 25X boost in performance and 80% reduction in cost