0
votes

I have created Mario character, it is playing different animation like standing, walking, jumping...Everything is ok but flip horizontally. In my key_down function I set if rightKey is pressed player.scaleX = 1, else leftKey is pressed player.scaleX = -1;

It works, my english is not so good so here is the link to understand better :

http://www.fastswf.com/vsi-Wps

The only problem is that even if you touch only one time left or right key, it will flip player but also it will move the player about 30px (lets say).

I used this before and it works ok if player has center registration point, but now I have top-left registration point and dont know how to fix this?

Can anyone explain?

1

1 Answers

0
votes

After scaling by a factor of -1, you have to move your DisplayObject to the right by width number of pixels. Here's an image illustrating what I mean. The orange dot in the image is the registration point. Illustration

And here's what you need to add to the code:

player.scaleX = -1;
player.x += width;