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

Get help using Construct 2

Post » Fri Apr 28, 2017 2:02 pm

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?
Last edited by TRMG on Fri Apr 28, 2017 5:56 pm, edited 1 time in total.
ImageImageImageImage
B
30
S
9
G
7
Posts: 247
Reputation: 5,606

Post » Fri Apr 28, 2017 2:19 pm

https://www.scirra.com/manual/119/touch

Touch.Xat("1"), Touch.Yat("1")
Mistakes were made.
B
52
S
26
G
110
Posts: 1,620
Reputation: 62,161

Post » Fri Apr 28, 2017 5:21 pm

oosyrag wrote:https://www.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.
Image Image Image
B
31
S
11
G
27
Posts: 748
Reputation: 17,093

Post » Fri Apr 28, 2017 5:39 pm

Oops you're right, there are no quotes.

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.
Mistakes were made.
B
52
S
26
G
110
Posts: 1,620
Reputation: 62,161

Post » Fri Apr 28, 2017 5:56 pm

oosyrag wrote:Oops you're right, there are no quotes.

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!
ImageImageImageImage
B
30
S
9
G
7
Posts: 247
Reputation: 5,606

Post » Fri Apr 28, 2017 7:21 pm

oosyrag wrote: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?
Image Image Image
B
31
S
11
G
27
Posts: 748
Reputation: 17,093

Post » Fri Apr 28, 2017 8:17 pm

Correct. But you can add conditions to specify on nth touch released to account for various situations.
Mistakes were made.
B
52
S
26
G
110
Posts: 1,620
Reputation: 62,161

Post » Sat Apr 29, 2017 3:13 am

@MPPlantOfficial

you can also use TouchID to keep track of which touch should apply to which object.
B
97
S
34
G
20
Posts: 438
Reputation: 17,790


Return to How do I....?

Who is online

Users browsing this forum: jastoh, jbr190 and 35 guests