How do I mirrored an object with Sin behaviour

Get help using Construct 2

Post » Mon May 12, 2014 9:45 pm

Hi guys,

I got a character which its face is always looking to the right side. I need this character to move left and right at a fixed position, so I set the Sin behavior for it and set its movement to horizontal.

When the character moves from the left side to the right side, it is fine because it always faces to the right side. However, if it moves back from the right side to the left side, its face still looking to the right side which looks weird. Is there any way I can use the mirrored attribute in this case.

Thanks in advance.
B
10
S
4
G
2
Posts: 36
Reputation: 2,207

Post » Mon May 12, 2014 11:50 pm

Attached is a capx example for you.

All I did was add an event for when the Sprite reached the end of the sine magnitude - 1 which mirrored the Sprite object.

I hope that gets you what you need and good luck with your project.
You do not have the required permissions to view the files attached to this post.
B
38
S
12
G
11
Posts: 331
Reputation: 7,712

Post » Tue May 13, 2014 12:08 am

As a bonus, I decided to include another capx that shows another way to do the same thing. This method only uses 1 event for changing between the 2 directions but, it is much more difficult to read. It uses 2 animations for showing the different directions instead of mirroring the Sprite. Then uses a ternary operation (look it up on Google if you don't know what that is) to decide which animation to show.

This is a more advanced method that can cut down your event count, but can be a nightmare to upkeep if you ever have to go back and fix it. That is unless you have a good grasp on what a ternary operator is and how it works.
You do not have the required permissions to view the files attached to this post.
B
38
S
12
G
11
Posts: 331
Reputation: 7,712

Post » Tue May 13, 2014 2:08 am

Awesome, thanks. I will apply and see how it works. Will let you know soon.

Cheers,
B
10
S
4
G
2
Posts: 36
Reputation: 2,207


Return to How do I....?

Who is online

Users browsing this forum: part12studios, Yahoo [Bot] and 9 guests