Changing origins when mirroring sprites? How?

Get help using Construct 2

Post » Mon Jun 17, 2013 2:13 pm

Hi,

I've been at this one for a while now and it's driving me potty.

This question is all based on Ashley's "How to make a platform game" tutorial, specifically page 4 (https://www.scirra.com/tutorials/253/how-to-make-a-platform-game/page-4).

If you look at the image of the player sprite part way down the page, you'll see the platform object overlaying the body of the player character. My problem is that using the System/Every Tick event to 'attach' the player sprite to the platform object only works properly until I mirror the image. When the mirroring occurs, the object origins no longer align (they aren't both centered) and the platform object rectangle doesn't cover the sprite image, making collision detection fail.

I can't work out a way of changing the origin number to use when a certain key is pressed or when the character is mirrored. System/Every Tick doesn't give me any actions I can use to make such a decision:
'System/Every tick player set position to playerbox (image point 0)' is how it defaults.
I want something like:
'System/Every tick player set position to playerbox (image point 0 or 1 depending on whether player (sprite) is mirrored).

I'm not asking for a coded solution, but a pointer in the right direction would be much appreciated. The easy solution would be to find a character sprite where the platform object origin doesn't need to change when the sprite is mirrored! But, I don't want to do that unless there's no other option.

Thanks,
LeastonLeaston2013-06-17 14:14:02
B
20
S
7
G
6
Posts: 19
Reputation: 4,947

Post » Mon Jun 17, 2013 4:55 pm

Use a variable, if the player presses the left arrow, set the variable to 0, if he/she presses the right arrow, set it to 1. Now that variable will return which direction the player is facing at all times. Then you can just set the character sprite to pick origin based on the variable.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Mon Jun 17, 2013 6:06 pm

Nimtrix, that worked perfectly!!!!! Thank you so much for putting me out of my misery I didn't realise I could use variable names in the 'value' box. RTFM!
B
20
S
7
G
6
Posts: 19
Reputation: 4,947


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 8 guests