Construct 2 Multi-Touch Controls - New Question

0 favourites
From the Asset Store
Casino? money? who knows? but the target is the same!
  • Hello (assuming there is still anybody on here).

    Looks pretty barren.

    Crickets chirp.

    ...

    ...

    !!!

    Anyway this may be my last post considering how things are going with Construct or maybe I'll still use it for prototyping as things go by who knows.

    As some of you know I'm far from new.

    I pretty much finished a 2D game from scratch, but I have no money for advertising or spiking, so I'm pretty much dead in the water.

    Anyway, as part of finishing a new version of Dark Sun, I was redoing the touch controls and as usual I'm having a devil of a time with something that's supposed to be simple.

    Basically, I need some multi-touch (for the aimer/the red square to work at a minimum as a second touch and not show up on the touch controls).

    Problem is all the touch coding objects and lack of coding examples. You have no idea what overlaps or what is actually needed in what coding schema, so you end up wasting days with "exploratory programming" with someone else's software that was touted as "no programming experience required" in the first place.

    Anyway, I'm enclosing a capx.

    It's pretty messy given all the things I tried, but all the elements should be in there for a fix, if you've figured it out, assuming you're on here o rare Construct 3 user (this is a Construct 2 file btw). I'm not paying for Construct 3 as I still haven't made back the money from the Construct 2 license and I got no help in marketing from the founder other than flames.

    Anyway, at one point, the multi-touch tracking code for the aimer worked, if touched your fingers nicely in sequence, and then took them off in sequence. The TouchID tracking would glitch though if you took away all fingers too fast and suddenly the cursor would wind up in the upper left corner for no apparent reason. That was a fancy version I was trying. I made jury rigged fix which worked for the most part with all fingers released, but it would still glitch occasionally if they were released too fast. How is that for a testimonial.

    Anyway, I realized I did not need all that for the game, so I was trying to switch to a simpler, 2 touch tracking version, to make sure ****the touch controls worked, and the aimer/red cross sprite would not appear on them as 1st or 2nd touch, if another touch was already in place,**** but after wasting 2 days on this algorithm torture, I'm throwing up my hands.

    I did read the only multi-touch tutorial out there by some panda (not the founder), but it's not helpful here as I'm using more controls.

    Anyway, if anybody has trouble following, I'll clean up the capx tomorrow.

    Basically, I had to add a whole bunch of sprites outside the 2 small touch controls (green and blue squares) as the idea was to be able to turn the ship by aiming with one finger on them, WHILE using touch control to move it with another, as opposed to some jerky movement where you have to stop one control to engage another.

    Anyway here's the capx:

    darksunpictures.com/public/touch_tests.zip

    The problem is all the different touch objects, touch start, touch end, in touch, has touch and no clear methodology on how to use them and where there is overlap, too much coding or glitches. It's basically just thrown out there. "Here! You do something with it."

    That's great. That's where I lose my hair with hours of needless "exploratory programming".

    Anyway, there's some crazy unsafe warning here, but believe me the file is completely safe, so you have to save that address and paste separately in a new window.

  • Instead of ranting for 2 pages you should've clearly explained what exactly are you trying to make. It's impossible to understand what's going on in your project.

    You want to move the ship with those blue and green squares (right hand), and aim by touching anywhere on the screen (left hand), correct? Why don't you use a "virtual joystick" or thumbstick? There are plenty of examples on this forum, I made one just yesterday:

    construct.net/en/forum/construct-2/how-do-i-18/how-do-i-multi-control-for-and-139160

  • Maybe you should go back to Kindergarten and learn how to read. I did not ask about any joysticks.

  • Maybe you should lose the attitude and stop being an a-hole to people who are trying to help. You can create perfectly working multi-touch controls in C2/C3, good luck figuring this out on your own.

  • AmpedRobot

    I hear your frustration... making a bulletproof multi-touch interface is definitely a very advanced function in C2 - and that is not C2's fault. It gives you the tools to do it. It is up to you to define what the touches mean to the game.

    Rather than use an array, I like to create a sprite object for each active touch. Then you use those to track where the touch is, what it is touching, what it can do, how to handle over-lapping controls, etc...

    I re-created your project using the bare minimum elements from yours, and my standard multi-touch method. I put in as many comments as I could, so I hope it makes sense. I had to add a couple instance variables to the beacon so only one touch could try to control it at a time...

    any touch that does not start on a control, or is not controlling the beacon is tracked, but ignored. So this version will work with any number of touches.

    you can download my version here: http://www.rieperts.com/games/forum/touch_test.capx

    Update 1: oh, yeah - normally I would have the TouchPoint sprite invisible, but I left it visible so you can see them for testing purposes...

    Update 2: Another thing - I put the controls in a Family, so you can do one test to see if a new touch is meant to update controls, or to try to move the beacon. Any other controls added should also be added to the family...

    alright, last update: I copied the code to move the ship and beacon from your file, but normally I would have the controls on a non-movable HUD layer (Parallax 0,0), and make the layer the ships are on scroll around (rather than moving all the objects individually). To do that I would create a camera object (with Scroll To) on the game layer and move that as necessary... You probably know that - I realize you were just testing touch.

  • AllanR I don't think your version is working correctly. If you touched any of the ControlsFamily squares first, you can't rotate the ship with the second touch. If you started rotating the ship, you can't move it..

    I'm guessing this is how it's supposed to work (open in Chrome):

    doptrix.com/C2/ahmtd

  • dop2000 my first version had that problem, so I moved part of the initialisation code into the "Is In Touch" block (by using the "NewTouch" flag). and that works properly on my computer, iPad and iPhone...

    (the "is overlapping" section didn't work in the "On any Touch Start". That looks like a bug in C2 to me, but is probably because the TouchPoint sprite isn't fully created until the next top level event).

    pretty sure I uploaded the right version... what are you testing on? and does the TouchPoint sprite have a NewTouch boolean instance variable?

  • AllanR Yeah, sorry, must be Firefox - it doesn't like multi-touch. Your project works fine in Chrome. The same can actually be done much easier if you loop through all active touches, in just 6 events.

  • dop2000

    just tried your version, and it seems to works well. Like I said back in my first post, it is up to the game creator to define how the interface works... and what makes sense for the game.

    My method was based on multi-touch requirements that needed different fingers to do specific things. Your shorter version does the job, but has potential drawbacks - if you start moving the beacon with one finger, then start moving the ship with another finger - if that second finger slides off the control it take over controlling the beacon. And if the finger that was controlling the beacon slides over a control it starts moving the ship. That is all fine, if that is what you want...

    Anyway, the OP now has two excellent examples of how to do multi-touch! :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • AllanR OP never explained what he needed. And if you look at his previous posts, you'll probably lose any interest in helping him.

    It's possible to add a couple of additional events into my version to prevent the situation you described - save TouchID of the finger which is touching the movement buttons, and if this ID is no longer touching the buttons, ignore it. Same with the touch controlling the beacon.

  • TouchID should neverEver be used on Mobile dev(every phone handles it differently). Use touchIndex instead.

    To join with the Post Overall Mood: youtube.com/watch

  • SnipG that is excellent advise... I had noticed strange IDs in some cases and worked around that, but I definitely like the idea of using the index instead. I will update my example so that people who download it in the future will not be misled.

  • SnipG Could you elaborate on this? I suppose TouchID can be re-used on some devices (therefore may not be unique). But it's very unlikely that any device will allow having multiple touches with the same TouchID active at the same time. So it still should be a good way to identify and track different touches.

  • I have had all kinds of problems with touchID, just too unreliable. Like xiaomi phones that are getting popular, when you do 2+1 touch, touches just freeze/reset. So i just use TouchIndex or variables.

    You could possible set TouchId to some unique vars, but when on xiamo touchID reset at 3 touches, 4 can be same as 1. Maybe you got some super good workaround, not sure about that.

    So i encourage people not to use TouchID.

  • SnipG We've actually discussed this with you here:

    github.com/Scirra/Construct-3-bugs/issues/1639

    I believe this bug is not really isolated to the TouchID, TouchIndex is affected as well. The problem is that sometimes "touch end" event is not triggered on certain devices, and that particular touch becomes "stuck" and is never cleared. As a result, any new touch will have TouchIndex>=1. You can add events to recognize these "stuck" touches and ignore them.

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