DJMoffinz 2022-09-04 03:37
i’m making some similar gui to the gfx designer and placing a sprite at the touch position then checking whether it intersects with the button sprite. I only want the button to do what it’s meant to do when the touch is released. looking through the code for the gfx designer would take an eternity, and trying to understand it would take longer.
was8bit 2022-09-04 04:37 (Edited)
So I use ITOUCH that can be set to different #’s to define the state of touch... 0 = no touch and all touch states are clear... awaiting a touch... any other settings I may use depends on how complicated i need touch control to be
So, i would ask myself the following questions for your situation...
1) if the initial touch first hits empty space, so does that invalidate the touch... meaning if user touches empty space, then slides their finger towards any button, do I make touch ignore whatever buttons user may slide touch to... and user must release their touch to reset ITOUCH to 0 and start over
IF TOUCH AND ITOUCH=0 THEN
has the code that determines what, if anything, gets touched...
2) once I allow touch to “touch” a button, I often set ITOUCH to a # that indicates what it touched... so do I change the button’s graphic to show it is touched
Then I have a separate check for...
IF NOT TOUCH AND ITOUCH<>0
has the code that realizes a touch of some kind, either ineligible or correctly touched, and these need processed... so here is where you do whatever the presses button does, reset the graphic,
... and when all touched stuff has been processed, the last thing you do is reset ITOUCH back to 0 so it is ready to await another touch :)
was8bit 2022-09-04 04:46
I would say this... build your code in as small as possible at a time with lots of TRACE statements to verify everyhing in real time as you test your touch controls.... this can be the HARDEST thing to debug and you write a ton of code expecting it all to work as you predict... and instead it behaves very strangely and you haven’t a clue why? ;)
was8bit 2022-09-04 04:52
Timo adds additional complexity.. the code knows if you started your touch inside or outside the drawing box... if started on the inside, it detects if you slide your finger outside the drawing box.. at that point the code forbids any buttons to be pressed or the draw box to be drawn in... you have to release your finger to reset your touch settings...
was8bit 2022-09-04 04:58 (Edited)
My method works well for a tap on one button at a time as it doesn’t process the touch until the user releases their finger...
If you look at my Yahtzee tic-tac-toe game, I combine SLIDE control for the hand to select a block to play on, but you still have to tap the PLAY button to actually play on that block ;)
was8bit 2022-09-04 05:05
Here I combine DRAG and DROP
was8bit 2022-09-04 05:08
Here I have a compound touch.. that is, FIRST touch then SECOND touch... before anything happens...
was8bit 2022-09-04 05:09
So, you can create and plan for #settings that work for you and are meaningful and helpful in whatever you are wanting to do :)
nathanielbabiak 2022-09-04 09:06 (Edited)
The Gfx designer uses Timo's touch zones GUI library. It's not hard to use, but if you need help check out the chart I posted at the bottom.
SP4CEBAR 2022-09-11 14:49
You could make a global variable and set it to -1 whenever TAP is on, and set it to zero whenever the variable is on and NOT(TOUCH)