Game Development Community

iTGB 1.2 BUG: onMouseUp not called when sliding finger/mouse off

by BeyondtheTech · in iTorque 2D · 06/01/2009 (5:47 am) · 45 replies

I have a game where I put an action button on the bottom of the screen with two behaviors for onMouseUp and onMouseDown. When I tap on the button, it works great as a modifier or toggle, but if I slide my finger up off the button or onto a nearby button, it still remains locked in the onMouseDown mode. If I slide my finger down off the screen (and obviously off the digitizer), the onMouseUp does finally get called.

I call this the "Shift key" effect, reminiscent of doing keyboard entry on a touchscreen Windows Mobile device. But, I'd rather not have it, as it would probably confuse the user, especially if they're frantically tapping the screen.

Any workaround or fix, script or source code-wise, to get this resolved?
#21
03/26/2010 (12:58 am)
then you aren't correctly dragging it (move the button on every single move event) as it can not leave the button if the button movement is in sync with the touch drag movement
#22
10/28/2011 (8:32 am)
I got the same problem, before i try the suggested fix i want to know if this is fixed in itgb 1.5 ?
#23
10/30/2011 (2:13 pm)
@Hilbert

In short: If you modify the touchesMove and touchesDown functions in game.cs, you can get the desired effect.

My story (abridged) :

For the platform T2D tutorial: tdn.garagegames.com/wiki/TGB/Tutorials/Platformer

I placed four sprites on the screen for a controller,and used the 'Generic Button' behavior included in the featuredemo. I had the issue described, 100% of the time when I touched the button, and slid my finger off of it before releasing.

Now, the button class is driven by multitouch events from the aforementioned functions in game.cs. Now my platformer demo only has that 'sticky button' issue about 1% of the time. (still working on it)

To get the job done, I wound up having to use a combination of this thread's links, with documentation searches, TorqueScript documentation reference look-ups, research in the forums, all the tutorials, the feature demo, and some of my existing tutorials where I vaguely remembered snippets of functionality.

If anyone was following the Zombie Jam, I was working on multitouch the entire time the gg folks were working on the game (both days) before I finally 'got it'.



#24
11/03/2011 (4:57 am)
@Ray

Thanks for the reply! I think i can make a workaround in game.cs but i would rather keep that functionality in my objects.

Is there maybe a gg dev who knows how to solve this issue?
#25
11/08/2011 (2:55 am)
I made a dirty fix for this in game.cs :

I use the global touch functions. I put the touch id's in a global variable on touchdown if a button is touched. And set them to -1 on touchup.
So now i can check if my touch was on one of my buttons, then i just put a check in the touchmove function to see if i'm still moving over my button, or if i moved of it, if so then i do some calls to stop my player movement and set the global touch id to -1.

It's a really dirty fix, but it works for now, still waiting for a proper fix, but at least i can test for now.
#26
11/14/2011 (11:54 pm)
I thought had fixed this.... But i only have 1 problem, my buttons are on the side of the screen. Everything works just fine except when i touch my button and then quickly slide off the screen to the left/right. There is a little space between my buttons and the side of the screen but my touch move doesn't get registered here. I didn't notice this until i put my game on my ipod which has less physical space between my button and the side of the screen.
The fix i first made detects when i'm moving my finger over a button and also detects when i'm moving off of the button, but apparently this doesn't always work.
So back to the drawing board.... Anybody got any suggestions?
#27
12/05/2011 (11:26 am)
I have the same problem.




I find it quite hard to believe a software package like iT2D lacks such a basic ability.
Even the demos have this problems.

Quite ugly.
#28
12/05/2011 (11:57 pm)
Too bad you have the same problem... I hope this will be fixed in the update for itgb 1.5. Maybe we can figure out a way around this problem although I don't see one yet... Maybe a garagegames dev knows a workaround?
#29
12/06/2011 (7:15 am)
I'll see what I can do about rectifying this.
#30
12/06/2011 (11:17 pm)
Thanks for looking into it!
#31
12/10/2011 (8:54 am)
Any news?
#32
12/10/2011 (12:20 pm)
I have a feeling I can't postpone learning ObjC ... but i'm to damn busy, was hoping scripting would be sufficient for a whole game.
#33
12/13/2011 (4:56 pm)
I can't publish my game because of this bug. Is anyone working on this?
#34
12/13/2011 (9:30 pm)
@Juan - This won't fix the problem 100% but you can use onmouseleave.
#35
12/13/2011 (11:34 pm)
@Johnny - I tried to use onmouseleave but that only works on the pc/mac, it doesn't work on ios.
#36
12/14/2011 (7:35 am)
I've tried using onMouseDown to actually execute my action. It works, but buttons still remain pressed sometimes.

Maybe I can include some "go back to normal state" code in my onMouseDown function.

It's not the way I would like it to work... but I have to get this done.
#37
12/14/2011 (12:01 pm)
@hilbert - I see... I believe it works in itgb 1.3 (I use it in Are You Quick Enough clock level) but looks like not in itgb 1.5. That is why I haven't upgraded to 1.5... it's really frustrating - backward compatibility with old versions is terrible.

One thing you guys could try (sorry don't have any code right now), there's a pickPoint function that takes in a world position and returns a list of objects. You could run a loop to check if your finger is still on the item.
#38
12/16/2011 (3:27 pm)
I've kind of "solved" it modifying the source code.

Now "onAction()" gets called in onMouseDown function instead of onMouseUp.

Button doesn't change to "down" state anymore, and onMouseUp function is empty as it is useless now.

It's not a good solution, I know... just a "hurry up" fix.



#39
12/16/2011 (8:02 pm)
Have you checked to see if touchesCancelled:withEvent: is called? I know in 1.4 i had issues with touch up not happening sometimes and it was because the touches were cancelled by the OS. Im guessing sliding off the side might do that. in 1.4 the touchesCancelled:withEvent: Obj C function was implemented wrong (I am not sure in 1.5) so you have to fix the typo and expose it to script. For the game I was working on I setup an array in the different touches methods so that I could just poll if multitouch was down or not. Anyway, I would check the touchesCancelled:withEvent: function and see if it helps.
#40
12/18/2011 (5:51 am)
I'm really sick of these bugs wasting my time. I actually spend more time dealing with iTGB issues or looking for some documentation, rather than developing my game.

Thanks for the help guys, but I think I'm not the one that should fix this.