iT2D 1.4 RC1 - onMouseDragged doesn't work on iDevices
by Johnny Vo · in iTorque 2D · 07/07/2010 (11:38 am) · 14 replies
Build: 1.4 RC1
Platform: OS X 10.6.4, iDevices, Xcode 4.0
Target: iDevices
Description:
onMouseDragged functionality does not work on the device. It works fine in the editor.
Platform: OS X 10.6.4, iDevices, Xcode 4.0
Target: iDevices
Description:
onMouseDragged functionality does not work on the device. It works fine in the editor.
About the author
Enlevel - Programmer. Games released with iT2D: Are You Quick Enough?, Coloring 4 Kids, Twistum
#2
07/07/2010 (12:04 pm)
function playerClass::onMouseDragged(%this, %modifier, %worldPosition, %mouseClicks)
{
echo("here");
player.setPosition(%worldPosition);
}
#3
07/07/2010 (12:17 pm)
Do you have UseMouseEvents = "1"; turned on for the object?
#4
07/07/2010 (2:06 pm)
I do. It works in the editor, just not on the device.
#5
07/07/2010 (2:46 pm)
Do you have multi-touch enabled as one of the device settings?
#6
The multitouch setting doesn't seem to stick on the editor. If i check it and then restart the editor, it becomes unchecked.
07/07/2010 (3:10 pm)
I tried it with multi-touch enabled and disabled. Both options still has the onMouseDragged not working on the device. The multitouch setting doesn't seem to stick on the editor. If i check it and then restart the editor, it becomes unchecked.
#7
07/07/2010 (8:38 pm)
Make sure when you check the setting to click Apply AND save the project. I'll double check this in the morning for you and reply as soon as I get results.
#8
Johnny - I only use oniPhoneTouchDown, touchMove and touchUp on the hardware. I exec a different controls script file if $device $= "iphone". That way you can handle multiple touches and overlapping scenewindows. It adds complexity to the code, but it also gives you proper touch functionality.
Also - see this resource for proper multi-touch tracking.
07/07/2010 (8:53 pm)
I thought the mouse functions were unsupported on the device as of 1.4? MouseDown certainly doesn't work either because it is called on every touch move.Johnny - I only use oniPhoneTouchDown, touchMove and touchUp on the hardware. I exec a different controls script file if $device $= "iphone". That way you can handle multiple touches and overlapping scenewindows. It adds complexity to the code, but it also gives you proper touch functionality.
Also - see this resource for proper multi-touch tracking.
#9
It is unfortunate that they can't keep the original mouse functions, from TGB, and make the the iPhone touch aspect totally transparent to the programmer. I don't see why that isn't the case, as it must be easy to do. I modified my own code (with some custom C++ code) so that onMouseDragged and oniPhoneTouchMove ultimately call the same C++ code, so that I know I am calling the same functions whether I run my game in the editor or on the device. Why GG chose to separate them is totally beyond me, and is not consistent with my own logical approach to the way software should work.
With every new iteration of iTGB, we seem to be diverting further away from the original TGB, which I think is a mistake. What happened to this marketing statement:
"Torque 2D for the iPhone supports the full TGB set of features, so you can prototype your iPhone game in Torque 2D on PC or Mac, then optimize it for deployment to the iPhone using Torque 2D"
Anyone who has ported from TGB to iTGB knows that the above statement is BS, and is becoming more and more BS with every new iteration of the software. Sad....
07/08/2010 (12:13 am)
onMouseDragged doesn't work in 1.3 either, and I remember there were numerous threads about this at the time, but I've been using a workaround based on the oniPhoneTouchMove function. I suspect the same is true on 1.4 also. It is unfortunate that they can't keep the original mouse functions, from TGB, and make the the iPhone touch aspect totally transparent to the programmer. I don't see why that isn't the case, as it must be easy to do. I modified my own code (with some custom C++ code) so that onMouseDragged and oniPhoneTouchMove ultimately call the same C++ code, so that I know I am calling the same functions whether I run my game in the editor or on the device. Why GG chose to separate them is totally beyond me, and is not consistent with my own logical approach to the way software should work.
With every new iteration of iTGB, we seem to be diverting further away from the original TGB, which I think is a mistake. What happened to this marketing statement:
"Torque 2D for the iPhone supports the full TGB set of features, so you can prototype your iPhone game in Torque 2D on PC or Mac, then optimize it for deployment to the iPhone using Torque 2D"
Anyone who has ported from TGB to iTGB knows that the above statement is BS, and is becoming more and more BS with every new iteration of the software. Sad....
#10
I agree with you Mark. If an engine suddenly works differently at least document it properly. Testing beta software is no fun and really time consuming.
07/08/2010 (1:41 am)
Thanks Mark, and Conor. Will take a look at the alternative solutions.I agree with you Mark. If an engine suddenly works differently at least document it properly. Testing beta software is no fun and really time consuming.
#11
BTW, just do a search for onMouseDragged and you'll see a lot of posts about it from a few months back when 1.3.1 was released. The workarounds are pretty straightforward, once you know about them.
07/08/2010 (8:03 pm)
Johnny, I agree, I'm sticking with 1.3.1 for now as I've figured out the workarounds and I feel comfortable working with that version now. It's a bit frustrating becase the engine itself works great, and there are only a few small gotchas that are easy to work around, once you know about them. The problem is it can take hours or days to find those gotchas. If GG provided a simple doc describing the main changes between versions, and admitted the things that are broken or the things that have been removed or whatever, I would be more willing to beta test the latest version for them. But, time is money, and I can't afford any excess time right now...BTW, just do a search for onMouseDragged and you'll see a lot of posts about it from a few months back when 1.3.1 was released. The workarounds are pretty straightforward, once you know about them.
#12
07/08/2010 (8:22 pm)
Thanks Mark. You just saved me a lot of time.
#13
http://www.torquepowered.com/community/forums/viewthread/109527
I ended up porting it to C++ to make it faster, because my game required fast framerates, but the solution works as and it might be ok in script for your. It's for your new Coloring for kids game right? For the iPad presumably? The scripted version will probably work fine for that. Also, in my case, I only needed to use this for one object so I was able to get rid of the for-loop and I only check for certain screen coordinates. The version that Joe posted is a more general solution, but it works great!
Hope this will work for your game also.
07/08/2010 (8:36 pm)
No problem. I specifically used this solution posted here:http://www.torquepowered.com/community/forums/viewthread/109527
I ended up porting it to C++ to make it faster, because my game required fast framerates, but the solution works as and it might be ok in script for your. It's for your new Coloring for kids game right? For the iPad presumably? The scripted version will probably work fine for that. Also, in my case, I only needed to use this for one object so I was able to get rid of the for-loop and I only check for certain screen coordinates. The version that Joe posted is a more general solution, but it works great!
Hope this will work for your game also.
#14
I'm using 1.4 for two games right now: the coloring 4 kids port to ipad and a new action game.
Oh I love your breakout port to the iphone. I really want to make a breakout game because of the great start your code will give me.
I just want to make games and not worry about engine work arounds :). Thanks and will keep you guys updated.
07/08/2010 (10:28 pm)
Mark! The link you gave worked for me. Thanks for the performance tips. I love performance tips.I'm using 1.4 for two games right now: the coloring 4 kids port to ipad and a new action game.
Oh I love your breakout port to the iphone. I really want to make a breakout game because of the great start your code will give me.
I just want to make games and not worry about engine work arounds :). Thanks and will keep you guys updated.
Community Manager Michael Perry
ZombieShortbus