Needed: Definitive direction for handling mouse events
by Brian Szatkowski · in iTorque 2D · 03/31/2010 (9:49 pm) · 7 replies
Hi All;
I have spent several hours now scouring back and forth through the forums looking for a definitive solution to handling mouse events in T2Di/iTGB 1.3.1. Some threads pointed to a 1.2 solution, some stated that everything was dandy and that the workarounds from 1.2 were added to 1.3.1, and still others stated that, in order to get things to work, the solutions ported from 1.2 to 1.3.1 need to be removed to make mouse events work. What gives?
I'm reading threads from a year-and-a-half ago about the developers stating that a multi-touch example was imminent. Instead, we have an example that allows us to click on one of two arrows to make an object move. The iPhone-related documentation that was embedded with the TGB documentation has been removed and replaced with three PDFs with so many typos and mis-referenced data that it is obvious they were thrown together.
All of the stickied content makes reference to old iTGB->XCode schemas and examples that no longer exist.
All of this makes for a frustrating user experience.
From what I could gather from the endless loop of mouse-specific threads in iTGB, the following setup should work. I am seeing undesirable results.
It appears, according to the console log in XCode, that the oniPhoneTouchDown callback is being called every tick, showing me a tweening effect of mouse coordinates. It's as if the call is being treated as a startDrag event as opposed to a simple mouseDown.
No offense is meant to those of you who have undoubtedly made an effort to address (and explain) solutions in detail. It's an annoying fact that this needs to be continually addressed, and I hate asking, but when the solution isn't intuitive, or evident in lackluster documentation, there is nowhere else to go but the community.
Any insight is greatly appreciated--a living online repository of up-to-date documentation would be ideal.
Thank you.
I have spent several hours now scouring back and forth through the forums looking for a definitive solution to handling mouse events in T2Di/iTGB 1.3.1. Some threads pointed to a 1.2 solution, some stated that everything was dandy and that the workarounds from 1.2 were added to 1.3.1, and still others stated that, in order to get things to work, the solutions ported from 1.2 to 1.3.1 need to be removed to make mouse events work. What gives?
I'm reading threads from a year-and-a-half ago about the developers stating that a multi-touch example was imminent. Instead, we have an example that allows us to click on one of two arrows to make an object move. The iPhone-related documentation that was embedded with the TGB documentation has been removed and replaced with three PDFs with so many typos and mis-referenced data that it is obvious they were thrown together.
All of the stickied content makes reference to old iTGB->XCode schemas and examples that no longer exist.
All of this makes for a frustrating user experience.
From what I could gather from the endless loop of mouse-specific threads in iTGB, the following setup should work. I am seeing undesirable results.
function oniPhoneTouchDown( %touchCount, %touchX, %touchY)
{
%worldPosition = sceneWindow2D.getWorldPoint( %touchX SPC %touchY);
sceneWindow2D.onMouseDown(0, %worldPosition, %touchCount);
}
function oniPhoneTouchUp( %touchCount, %touchX, %touchY)
{
%worldPosition = sceneWindow2D.getWorldPoint( %touchX SPC %touchY);
sceneWindow2D.onMouseUp(0, %worldPosition, %touchCount);
}It appears, according to the console log in XCode, that the oniPhoneTouchDown callback is being called every tick, showing me a tweening effect of mouse coordinates. It's as if the call is being treated as a startDrag event as opposed to a simple mouseDown.
No offense is meant to those of you who have undoubtedly made an effort to address (and explain) solutions in detail. It's an annoying fact that this needs to be continually addressed, and I hate asking, but when the solution isn't intuitive, or evident in lackluster documentation, there is nowhere else to go but the community.
Any insight is greatly appreciated--a living online repository of up-to-date documentation would be ideal.
Thank you.
About the author
#2
04/01/2010 (6:24 am)
I don't use multitouch, so I just use onMouseDown(%this, %modifier, %worldPosition, %mouseClicks). That part of my game works so far.
#3
Thank you for the prompt feedback. I have verified your statement by commenting out my code inside the callbacks. However, I am still seeing the mouseDown action being repeatedly called while the touch is being held down (without being moved).
Is this considered to be working as intended? If so, what's the rationale? If this topic does exist somewhere in the threads already, I have not found it and would appreciate being pointed in the right direction.
Thank you again for your assistance.
04/01/2010 (7:37 am)
Hi Marc;Thank you for the prompt feedback. I have verified your statement by commenting out my code inside the callbacks. However, I am still seeing the mouseDown action being repeatedly called while the touch is being held down (without being moved).
Is this considered to be working as intended? If so, what's the rationale? If this topic does exist somewhere in the threads already, I have not found it and would appreciate being pointed in the right direction.
Thank you again for your assistance.
#4
the majority of the time, mouse move should happen.
if you only use it on the window and not object, the use of the mouse callbacks, at least out of my view, is very restricted as you gain very little if anything, aside of the costs of converting screen coordinates to world coordinates
04/01/2010 (6:19 pm)
mousedown / mouseup should happen one per touch and per object where you defined this callback on.the majority of the time, mouse move should happen.
if you only use it on the window and not object, the use of the mouse callbacks, at least out of my view, is very restricted as you gain very little if anything, aside of the costs of converting screen coordinates to world coordinates
#5
I apologize for the delay in my reply.
My app design dictates that I capture mouse actions on the window versus individual objects, as the logic of the app determines after the user makes a move to which object the action applies.
Regardless, your input was appreciated and useful. I simply set a flag in my mouseDown/mouseUp calls to prevent repeated mouseDown calls from being registered. Everything is now working by design.
Thank you.
04/08/2010 (6:34 am)
Hi Marc;I apologize for the delay in my reply.
My app design dictates that I capture mouse actions on the window versus individual objects, as the logic of the app determines after the user makes a move to which object the action applies.
Regardless, your input was appreciated and useful. I simply set a flag in my mouseDown/mouseUp calls to prevent repeated mouseDown calls from being registered. Everything is now working by design.
Thank you.
#6
07/30/2010 (3:27 am)
why my oniPhoneTouchDown can not work!
#7
07/31/2010 (5:00 am)
huyan - make sure you have 'multitouch support' checked in the editor in the project panel.
Torque 3D Owner Marc Dreamora Schaerer
Gayasoft
Given the gui has the correct side etc the mouse callbacks will work on their own without the requirement of oniPhoneTouchXxxxx() (though those should be put somewhere in the project even if empty ... and they are by default actually)