Select a specific part of an object to touch?

0 favourites
  • 6 posts
From the Asset Store
A set of retro 16-Bit Neon UI elements to make your menus pop!
  • Hey there people. Quick question. I have an image that the player can touch. I want it to react differently depending on where the object is touched.

    Example: If the player touches the left of the object it moves right. If it touches the right of the object it moves left. The object in this case being a ball.

    Is this possible without pinning 2 other game objects to the original one?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Assuming your origin is in the middle of the object, adding a condition would work..

    on object touched

    system compare two values: touch.x < object.x

    • object move left
  • Ah yes that worked thank you very much.

  • This could maybe work better:

    On object touch/collision/overlapping:

    System -> Compare two values (touch.x < object.x + (object.Width / 2))

    Or

    System -> Compare two values (touch.x > object.x - (object.Width / 2))

    ---Object -> Simulate control -> Left

    Difference being, LittleStain's code would work if you clicked to the left of the object, not actually clicking the left side of the object if the .x wasn't measured from the middle, for example, if you had shifted the default image point. LittleStain please correct me if I'm wrong but I thought X and Y were measured from the left edge of the object.

  • Yeah I took his code and done something similar to what you described. I just said if it is x-10 do one thing x+10 do the other and I have something else for if you click in the middle, this seems to work pretty well.

    Thanks for your helps peoples.

  • Ah cool, no worries; happy to help. Good luck with the rest of your developing, .

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