How do I Mirror Non Platform - Non Directional Sprite

Get help using Construct 2

Post » Sat Jan 02, 2016 7:07 am

I have a sprite moving via the rex_moveto behavior. Everything is fine, it moves around from waypoint to waypoint, but I cannot for the life of me to mirror the sprite based on the direction its moving. I have done this before, but cannot find the example capx I did it in. Anyone have any tips?
B
8
S
2
Posts: 36
Reputation: 599

Post » Sat Jan 02, 2016 12:28 pm

You can use the sine behavior like this example:
how-do-i-move-enemies-like-in-mario_t119088?&hilit=sine+mirror&start=10
Image
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Sat Jan 02, 2016 5:28 pm

I've looked at that one. The way points my sprites follow are random though. Isn't that example based off touching an invisible sprite which turns them? I had gotten the sprites to mirror when the moving angle was 180 or 0, but it only worked some of the time and that's probably because when they move they could be going slightly up or slightly down so the angle isn't exactly 180 or 0.
B
8
S
2
Posts: 36
Reputation: 599

Post » Sat Jan 02, 2016 11:44 pm

I figured it out. If anyone else runs into this issue, and doesn't want to use sine, or platform, or any other behavior in a work around fashion this is how I did it.

Get the plugin rex_moveto - http://c2rexplugins.weebly.com/rex_moveto.html

For Debug purposes I set it up to update a instance variable on my sprite so I could see the angles.

Create Instance Variable - MovingAngle (number)

Add Event - Sprite -> (condition) MoveTo is moving
Action - Set Sprite MovingAngle to Sprite.MoveTo.MovingAngleStart

Add Event - Sprite -> (condition) Compare Instance Variable MovingAngle > 90 AND MovingAngle < 270
Action - Set Mirrored

Add Event - Sprite -> (condition) Compare Instance Variable MovingAngle > 270 OR MovingAngle < 90
Action - Not Mirrored
B
8
S
2
Posts: 36
Reputation: 599


Return to How do I....?

Who is online

Users browsing this forum: kabaal, oddreal, raulcg1981, SondeepH and 11 guests