(S) How do I set object angle towards second touch?

  • Hey, I have this ball which I drag with one finger and I want it to set it's angle towards the second touch when it's being pressed.

    This is the code I use:

    nth touch (1) is touching --> Ball - set angle towards position (Touch.X, Touch.Y)

    Problem is, it's setting the angle towards the first touch.

    So, how do I set it's angle towards my second touch?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • https://www.scirra.com/manual/119/touch

    Touch.Xat("1"), Touch.Yat("1")

  • scirra.com/manual/119/touch

    Touch.Xat("1"), Touch.Yat("1")

    I've not had the pleasure of trying this but could you explain why it's

    Touch.Xat("1") ? This seems to indicate that the "1" is a string rather than an integer.

    I was thinking it'd be Touch(1).X or something.

  • Oops you're right, there are no quotes.

    [quote:9meuzx4b]X

    Y

    XAt(index)

    YAt(index)

    XForID(id)

    YForID(id)

    Return the current position of a touch in layout co-ordinates. It changes to reflect scrolling and scaling. However, if an individual layer has been scrolled, scaled or rotated, these expressions do not take that in to account - for that case, use the layer versions below. The At expressions can return the position of any touch given its zero-based index, and the ForID expressions return the position of a touch with a specific ID.

  • Oops you're right, there are no quotes.

    [quote:3v19xi17]X

    Y

    XAt(index)

    YAt(index)

    XForID(id)

    YForID(id)

    Return the current position of a touch in layout co-ordinates. It changes to reflect scrolling and scaling. However, if an individual layer has been scrolled, scaled or rotated, these expressions do not take that in to account - for that case, use the layer versions below. The At expressions can return the position of any touch given its zero-based index, and the ForID expressions return the position of a touch with a specific ID.

    Great, thank you!

  • Oops you're right, there are no quotes.

    Theoretical question:

    If I have a game with the statement:

    Is inTouch | Set OBJECT to Touch(0).X,Touch(0).Y

    And another one with:

    Is inTouch | Set ANOTHER_OBJECT to Touch(1).X,Touch(1).Y

    If I take the first touch off , wouldn't my second touch get reassigned to Touch(0)?

    I'm imagining OBJECT would suddenly appear in the position of ANOTHER_OBJECT.

    But I have no device to test this with as of right now.

    Can you confirm this?

  • Correct. But you can add conditions to specify on nth touch released to account for various situations.

  • MPPlantOfficial

    you can also use TouchID to keep track of which touch should apply to which object.

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