Changing origins when mirroring sprites? How?

0 favourites
  • 3 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • 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,

    Leaston

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Nimtrix, that worked perfectly!!!!! Thank you so much for putting me out of my misery <img src="smileys/smiley1.gif" border="0" align="middle" /> I didn't realise I could use variable names in the 'value' box. RTFM! <img src="smileys/smiley17.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)