Help on multiple sprite touches

Get help using Construct 2

Post » Wed Sep 07, 2016 1:01 am

Hey guys
I have been trying to figure this one out but I cant seem so here my situation.
I have 2 sprites on screen that are touch controls. And depending on where I touch on the sprite they change their angle to touch.x + touch.y.
so it setup like: is touching rightctrl: set redctrl angle toward touch.X(redctrl.x) , touch.y(redctrl.y).
now when touching 1st sprite only they behave fine, but as soon as the 2nd one is touched the 1st sprite changes its angle to point at the 2nd sprite
please help me guys iv hit brick wall here.
and thank you in advance
B
18
S
7
Posts: 13
Reputation: 1,235

Post » Wed Sep 07, 2016 2:00 am

Your saying the first touch is messing up your 2nd?

I think you can reference a certain touch. (or possibly the last touch)

I'll take a quick look in C2 if I can make a quick demo for you. (Let me know if I misunderstood)
Eat ALL THE BACON!
B
47
S
17
G
3
Posts: 290
Reputation: 5,070

Post » Wed Sep 07, 2016 2:05 am

Use Touch.TouchIndex to check which tap it is... (0 is the first tap, 1 is the 2nd and so on.)

I was gonna make a demo, but I didn't have my phone handy to test it.
Eat ALL THE BACON!
B
47
S
17
G
3
Posts: 290
Reputation: 5,070

Post » Wed Sep 07, 2016 3:08 am

nmf004 wrote:Hey guys
I have been trying to figure this one out but I cant seem so here my situation.
I have 2 sprites on screen that are touch controls. And depending on where I touch on the sprite they change their angle to touch.x + touch.y.
so it setup like: is touching rightctrl: set redctrl angle toward touch.X(redctrl.x) , touch.y(redctrl.y).
now when touching 1st sprite only they behave fine, but as soon as the 2nd one is touched the 1st sprite changes its angle to point at the 2nd sprite
please help me guys iv hit brick wall here.
and thank you in advance


That sounds like you have two on-screen joysticks and left controller is moving when only the right one is being used. Is that what's happening?

Please post capx, if possible. If not, please post a screenshot of the event sheet.
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Wed Sep 07, 2016 11:13 am

Gmoney you are pretty much on the money but happens to either. only the last joystick touched responds and 1st joy angle towards 2nd touch just like Antares said. I cant figure out how to use the touch id correctly.
here is an example
[/url]https://www.dropbox.com/s/h70wnvwx9hor0ej/touch%20joysticks.capx?dl=0
thanks for the help
B
18
S
7
Posts: 13
Reputation: 1,235

Post » Wed Sep 07, 2016 2:14 pm

Is this what you were looking for? :mrgreen:

https://www.dropbox.com/s/964upy26lu0ip ... .capx?dl=0
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Thu Sep 08, 2016 1:21 am

na it still behaving the same last touched joystick behaves fine but the 1st one touched will angle to last touch. thanks for having a look I'm having a little success using the drag and drop function instead, everyone seems to use that for angle based joysticks
thank you for your help gmoney
B
18
S
7
Posts: 13
Reputation: 1,235

Post » Thu Sep 08, 2016 2:33 am

You're welcome, nmf004.

That's odd.. :? I tested it on my mobile device, but didn't see the first controller being angled to last touch..

Anyway, yes, please try drag and drop function instead. (I wish I could have been more help.)

Oh, and this example has variables to not allow both controllers to be touched at the same time.. I tested it on my device but the result was the same.. :(

https://www.dropbox.com/s/rpfzeg7j4zn0k ... .capx?dl=0
B
11
S
6
G
15
Posts: 256
Reputation: 9,207

Post » Fri Sep 09, 2016 12:12 pm

Figured I would share with everone how I fixed it used the drag and drop and set instance variables to on touch start on object. That way it didn't update the touched and make the 1st joy angle to 2nd touch now just use, set angle of sprite to touch.xforid(instance variable) of your joy
Probly sounds confusing so I provide an example
https://www.dropbox.com/s/h70wnvwx9hor0ej/touch%20joysticks.capx?dl=0
thank you gamoney and Antares for your help you inspired many, many different attempts

btw if you have any issues getting your joysticks to angle in your game, on each of the set angle you have touch.Xforid(redctrl.touchid",layer to get touch position for") < simply change that number to the number of the layer your control's are on
B
18
S
7
Posts: 13
Reputation: 1,235

Post » Fri Sep 09, 2016 1:17 pm

nmf004 wrote:Figured I would share with everone how I fixed it used the drag and drop and set instance variables to on touch start on object. That way it didn't update the touched and make the 1st joy angle to 2nd touch now just use, set angle of sprite to touch.xforid(instance variable) of your joy
Probly sounds confusing so I provide an example
https://www.dropbox.com/s/h70wnvwx9hor0ej/touch%20joysticks.capx?dl=0
thank you gamoney and Antares for your help you inspired many, many different attempts

btw if you have any issues getting your joysticks to angle in your game, on each of the set angle you have touch.Xforid(redctrl.touchid",layer to get touch position for") < simply change that number to the number of the layer your control's are on


You're always welcome, nmf004. I'm glad the issue was resolved. :mrgreen:

Thank you for sharing. I'll remember to use touch.xforid(instance variable) in the future.
B
11
S
6
G
15
Posts: 256
Reputation: 9,207


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests