How do I make dual stick touch controls ?

Get help using Construct 2

Post » Fri Aug 05, 2016 12:08 am

Hey,

I'm trying to make two sticks touch controlled in my game : one for moving the character (only for left and right) and one for shooting 360°. They should be floating. I followed this tutorial :
https://www.scirra.com/tutorials/398/to ... ers/page-4
But it's awfully complex and it's for moving a character, not shooting in a straight line. Could somebody give me a more simple way ?
B
15
S
7
G
2
Posts: 18
Reputation: 2,165

Post » Fri Aug 05, 2016 1:07 am

I've used something like this:
https://www.scirra.com/forum/360-aiming-with-a-gamepad-using-the-right-stick_t87397

Pay attention to the 9th post.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Post » Fri Aug 05, 2016 2:14 am

I'm sorry but isn't this post is about physical controllers ?
I was talking about a virtual controller :)
B
15
S
7
G
2
Posts: 18
Reputation: 2,165

Post » Sun Aug 07, 2016 7:02 pm

Need to bump the topic because I'm starting to pulling my hair out.
I made changes because I couldn't succeed to have dual sticks, so now it's UI-less : the screen is divided in 2, swipe left or right at left side for running, tap, swipe or hold on right side for different actions. But Construct seems to weirdly handle multi-touch. If I start running and then jumping for exemple, it's working, but if I'm jumping, THEN running while keeping finger on right side, the direction is messed up.
I tried making tons of events for handling each touch index, but they seem to override each other, so at the end there's still a move that will be wrong.
Someone have an idea ?
B
15
S
7
G
2
Posts: 18
Reputation: 2,165

Post » Sun Aug 07, 2016 9:29 pm

Have you learned how to track touch ID?
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Sun Aug 07, 2016 9:33 pm

Well, I know the thing with "one touch = one arbitrary ID". Is that sufficient ?

Anyway here's a capx for example. I've tried other settings but this is the most recent one (not commented, sorry !).
https://www.dropbox.com/s/fphdgr0if841dxm/Touch%20test.capx?dl=0
B
15
S
7
G
2
Posts: 18
Reputation: 2,165

Post » Sun Aug 07, 2016 11:56 pm

Haven't looked at your capx yet but what I mean is tracking the touches so they don't affect each other. So you would have on touch ends & Touch ID equals X

I haven't done two joysticks but I have done control pad and buttons, you can see by clicking the ninja picture in the middle of my signature. It took some testing and debugging but it is definitely possible
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Mon Aug 08, 2016 4:11 am

I understand the concept, but what's the application ? Which event do I need to do, is it with variables ?
B
15
S
7
G
2
Posts: 18
Reputation: 2,165

Post » Mon Aug 08, 2016 4:38 am

I can't find the tutorial I used but here is what I did:

Global Variable ControlPadTouchID (forgot to capture in the snip)
Image

I crossed out some unrelated events and highlighted the ones pertaining to ControlPadTouchID

Basically there are three steps:
  1. Anytime a touch starts it checks if it is touching the control pad. If so it changes the variable to the touch's ID
  2. If the variable is not -1 then that touch's location will be tracked to determine which direction to move
  3. Anytime a touch ends there will be a check to see if it was the touch ID stored in the variable. If it isn't then the control pad movement isn't interrupted. If it is then the variable will be set to -1 which stops step 2

Should be able to make another global variable for the other controlpad/joystick and duplicate the events. The touches should be tracked separately and not interfere with each other.
ImageImageImage
B
44
S
26
G
11
Posts: 518
Reputation: 10,502

Post » Mon Aug 08, 2016 5:13 pm

Well, first your events were not really transposable to my layout, but I could make something out of the logic behind it. So for the basic actions (move and jump) it works, I hope it will be the same with the more complex ones (swipe and everything). Thanks a lot ! Too bad that's there's so few tutorials about touch controls :(
B
15
S
7
G
2
Posts: 18
Reputation: 2,165

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 7 guests