[resolved] Mouse stuck on upper left corner
by L M · in iTorque 2D · 10/06/2009 (1:43 pm) · 11 replies
Hi, I just purchased Torque 2D for the Iphone and after a few hours of trying to get it to work on the device, I've finally managed to launch a blank application with one sprite that should move to the mouse's click/touch coordinates.
Looks simple no? It works with the TGB editor but on the iPhone device the pointer is just stuck on the upper left corner.
I've searched the forums with various combination of these keywords (mouse,stuck,left,corner,move,touch,device,works) and no one's mentioned it.
Am I missing something? Please help.
function t2dSceneWindow::onMouseDown(%this, %modifier, %worldPosition, %mouseClicks)
{
%mousePos = SceneWindow2D.getMousePosition();
testSprite.moveTo(%mousePos,25,true,true);
}Looks simple no? It works with the TGB editor but on the iPhone device the pointer is just stuck on the upper left corner.
I've searched the forums with various combination of these keywords (mouse,stuck,left,corner,move,touch,device,works) and no one's mentioned it.
Am I missing something? Please help.
#2
It's the mouse itself. It recognizes click/touch events as the sprite would slide to the upper left corner, but that's mainly it. It will not move anywhere else because I cannot move the mouse.
I did not modify the code at all, I just added those 5 lines of code which works just fine on the editor.
I tried it on 1.2 and 1.3 and it's the same behavior. The test application would not deploy on the device for me. It gives me this message when I try deploying on XCode: "Could not inspect the application package"
10/06/2009 (2:39 pm)
Thanks for replying Nate! It's the mouse itself. It recognizes click/touch events as the sprite would slide to the upper left corner, but that's mainly it. It will not move anywhere else because I cannot move the mouse.
I did not modify the code at all, I just added those 5 lines of code which works just fine on the editor.
I tried it on 1.2 and 1.3 and it's the same behavior. The test application would not deploy on the device for me. It gives me this message when I try deploying on XCode: "Could not inspect the application package"
#3
Xcode 3.2. Nothing wrong with the devices because my cocos2d and unity apps work just fine. :(
10/06/2009 (2:52 pm)
I tried it on an iPhone 3G and iPod Touch 2nd Gen. Same results.Xcode 3.2. Nothing wrong with the devices because my cocos2d and unity apps work just fine. :(
#4
Not sure why it would work on the editor and not the device though.
10/06/2009 (3:18 pm)
My guess is that the problem is how you're declaring your function and that t2dSceneWindow::onMouseDown is overriding something important. I don't think you're supposed to add new methods to the base t2dSceneWindow class or at least you should know what you're doing when you do so. When I wanted to trap mouse events over the screen, I generally create a background and watch for mouseDown on that background. This is just a guess though and I'll see if I can reproduce the problem.Not sure why it would work on the editor and not the device though.
#5
10/06/2009 (4:15 pm)
I just created a simple project with your 5 lines of code (in a test.cs file that I exec from game.cs) and I could move the cursor around just fine. The sprite didn't want to move around until I added testSprite.setUsesPhysics(true) but otherwise everything worked fine.
#6
10/06/2009 (4:26 pm)
Thanks Nate, Does it work on the device with iTGB 1.3?
#7
10/06/2009 (5:35 pm)
I don't know, I'm running iTGB 1.2 and I'm reluctant to upgrade as I'm in the finishing stages of a game and I don't want to risk breaking everything at this point.
#8
i am working on Mac if this makes a difference.
10/23/2009 (4:33 am)
I am having the same problems, i can't get the TouchGame tutorial to work in 1.3, i have it on my device - iPhone os3.1 but mouse cursor sits at top left and you can't interact with the screen. it works fine in 1.2, but i need to use 1.3 because i need to use multitouch in the near future?i am working on Mac if this makes a difference.
#9
If you integrate the user resources with 1.2 then you likely have a more solid solution for multitouch than what the 1.3 alpha offers
10/23/2009 (5:28 am)
Multitouch works in 1.3 as bad as in 1.2 if not worse.If you integrate the user resources with 1.2 then you likely have a more solid solution for multitouch than what the 1.3 alpha offers
#10
Open iPhoneInput.mm inside the platformiPhone folder. Look for a function called createMouseMoveEvent.
Let me know if this helps.
10/23/2009 (11:45 am)
The cursor problem is a simple fix. The fix for mouse cursor not moving :
Open iPhoneInput.mm inside the platformiPhone folder. Look for a function called createMouseMoveEvent.
bool createMouseMoveEvent( S32 touchNumber, S32 x, S32 y )
{
ScreenTouchEvent event;
event.xPos = x;
event.yPos = y;
event.action = SI_MAKE;
TouchMoveEvents.push_back( touchEvent( touchNumber, x, y ) );
//Add this missing line below.
Canvas->setCursorPos( Point2I( x, y ) );
Game->postEvent(event);
return true;//return false if we get bad values or something
}Let me know if this helps.
#11
10/23/2009 (3:38 pm)
I can confirm this should fix the issue, as I had made precisely this change a while back after suffering the same problem.
Nate Gertsch
But I've never heard of your particular problem before where the cursor itself it stuck. Does it exhibit this behavior on the test applications as well?