2
\$\begingroup\$

I want my character to 'flip' or 'mirror' when I press 'A' or 'S'. Thing is, I've placed the origin everywhere on the character and he seems to only face one direction.

Video showing what I see: https://www.youtube.com/watch?v=1zZEDpO0yAM&feature=youtu.be

(This video shows the character not 'mirroring' or 'flipping' properly.)

I have done hours of research into this, and I get the same results: "Make sure the sprite has the center origin."

How would I accomplish this?

\$\endgroup\$
2
\$\begingroup\$

That's pretty simple if you think about it. All you have to do is scale the sprite using a negative factor, which in the end will cause sides to mirror around it's origin.

So all you have to do is assigning a negative scale using image_xscale:

image_xscale = -1;

The documentation page for image_xscale actually shows you an example with different scaling factors.

\$\endgroup\$
  • \$\begingroup\$ This only works correctly when the pivot is set at the center of the sprite(otherwise it's collision mask will be off the sprite). \$\endgroup\$ – DH. Jun 6 '16 at 10:52
  • \$\begingroup\$ @DH. I think a good designer will place the pivot at the center of a sprite most of the time, and when he doesn't he should know what to do to correct the following sprite behavior. \$\endgroup\$ – liggiorgio Jun 6 '16 at 15:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.