v1.5 Preview 2 Available
by Michael Perry · in iTorque 2D · 07/26/2011 (2:28 pm) · 54 replies

Official Release Blog
How 'Preview Releases' Work for 1.5
As many of you have figured out by now, we've decided to release multiple previews of iTorque 1.5. "Preview Releases" give you a snapshot of where we are in development, and a window into where we are going (hint: Universal App and Retina Display support).That being said, Preview Releases will not be fully documented, and will include bugs. Updated documentation and a full QA cycle to stamp out bugs will not occur until we are ready to release the FINAL version of iTorque 1.5.
Preview 2 Details
The scope and resource availability for Preview 2 was higher than the previous. The focus of this build was to improve the input system for iTorque 2D. Back in March, I created one of my lengthiest threads to date, titled Improved Input and Gestures. Part R&D and part community polling, this thread and my IRC discussions were invaluable to completing the second preview. Theory turned to code in this post.The goal of this preview can be boiled down to the following:
1. Improve usability
2. Remove limitations of current touch tracking
3. Extend input features to provide all basic data provided by the iOS SDK
ActionMap
Gone are the days of "you must use" and "you can't use". oniPhoneTouchDown/Up/Move are gone, as there is not a reason you (the developer) should be limited. Define your functions however you want. In fact, make as many functions as you want, one for each level if you need:
Separate ActionMap declarations:
new ActionMap(menuActionMap); menuActionMap.bind(touchdevice, touchdown, "menuTouchDown"); menuActionMap.bind(touchdevice, touchmove, "menuTouchMove"); menuActionMap.bind(touchdevice, touchup, "menuTouchUp"); new ActionMap(gameActionMap); gameActionMap.bind(touchdevice, touchdown, "gameTouchDown"); gameActionMap.bind(touchdevice, touchmove, "gameTouchMove"); gameActionMap.bind(touchdevice, touchup, "gameTouchUp");
Push and pop
function onMenuStart()
{
menuActionMap.push();
}
function startGame()
{
menuActionMap.pop();
gameActionMap.push();
}Example function parameters
function gameTouchDown(%touchIDs, %touchesX, %touchesY)
{
echo("Entered touch down function");
// How many fingers are down
%numTouches = getWordCount( %touchIDs );
// Loop through each finger and print its coordinates
for(%count = 0; %count < %numTouches; %count++)
{
// Finger ID
%curTouch = getWord( %touchIDs, %count );
// X screen coordinate
%curX = getWord( %touchesX, %count );
// Y screen coordinate
%curY = getWord( %touchesY , %count );
// World position
%worldPos = sceneWindow2D.getWorldPoint(%curX, %curY);
// Print results
echo("Scanning touch " @ curTouch @ " at " @ %worldPos);
}
}Improved Motion System
One of the owners pushed for supporting Gyroscope. This was the catalyst for getting the ActionMap system back on track, as well as improving existing Accelerometer functionality. 1.5 has replaced UIAccelerometer with CoreMotion, which is a lot cleaner and more powerful. Again, the devices are exposed via ActionMap. Because the motion devices are sensitive, examples of how to use a dead zone are provided.
enableGyroscope();
// In landscape, pitching means tilting the device left and right
moveMap.bind(gyroscope, pitch, "D", "-0.1 0.1", "pitchFunction");
// In landscape, rolling is tilting the device toward and away from the user
moveMap.bind(gyroscope, roll, "D", "-0.1 0.1", "rollFunction");
// In landscape, rolling is tilting the device toward and away from the user
moveMap.bind(gyroscope, roll, "D", "-0.1 0.1", "yawFunction");
// Toggle accelerometer processing
enableAccelerometer();
// In landscape, react to gravity when tilting left to right
moveMap.bind(accelerometer, gravityx, "D", "-0.2 0.2", "gravityXFunction");
// In landscape, react to gravity when tilting toward and away from the user
moveMap.bind(accelerometer, gravityy, "D", "-0.2 0.2", "gravityYFunction");onTouch Callbacks
Short and simple (with a lot hidden under the hood), onMouse callbacks have been replaced with onTouch:
// This callback is invoked when the cloud is touched
function Cloud::onTouchDown(%this, %touchID, %worldPos)
{
}
// This callback is invoked when a finger is lifted off the cloud
function Cloud::onTouchUp(%this, %touchID, %worldPos)
{
}
// This callback is invoked when a finger drags across the cloud
function Cloud::onTouchDragged(%this, %touchID, %worldPos)
{
}Fixes
Some extremely annoying bugs cropped up between 1.4.1 and 1.5 Preview 1. While bug fixing is not the goal of these previews, some were detrimental to the focus of this release. In addition to the fixes, the longstanding mystery of particle corruption has been SOLVED!
- GameCenterManager dealloc code switched to release. This should resolve the crash and memory problems related to this module
- ITGB-126 Extra common/commonConfig.xml being created during project creation
- ITGB-142 Minor editor bugs
- - Editor correctly writes and reads preference files from AppData/Roaming/GarageGames
- - Editor correctly loads config settings for projects
- - Editor no longer resizes when opening or creating new projects
- - Opening a project from inside of the editor no longer returns to the main screen. The project actually opens now
- - Level datablocks allow for multi-selection and removal
- ITGB-144 Particle File Corruption
- - Longstanding issue finally explained in this thread: http://www.garagegames.com/community/forums/viewthread/126104
- - Short term solution provided here: http://www.garagegames.com/community/forums/viewthread/126104/1#comment-809786
Known Issues
Even though we are not focusing on bug fixes for the first couple of previews, we are tracking them. This list will shrink and grow during the previews, but we know it's helpful for you have access to this information:
- New Accelerometer and Gyroscope bindings only work on iPod Touch 4th gen and iPhone 4. This was just discovered and a solution is being worked on for the final release
- Not all demos and docs reflect the improved input system. This will be resolved for the final release. For now, you can look at RainyDay or create a project using Empty template. These have the improved input examples
- Broken simulator targets/schemes snuck back in due to a merge error. These will be removed again for the final release
- dealloc used in MoviePlayer code. Should be [self release]. This will be fixed in the final
- iPad rotation issue not fully resolved
- GameCenterTest requires modification to run. You must use your own provision profile and iTunes Connect information
- ITGB-115 Closing the GUI Editor does not close GUIs being edited
- ITGB-116 GuiButtonCtrls are rendered as black in their up state
- ITGB-120 Calling Canvas.popDialog() pop the mainScreenGui on devices and simulator
- ITGB-122 Varied behavior with different Gui Controls
- ITGB-123 Gui Editor Inspector does not auto update when adding a new control
- ITGB-129 iTorque2DGame.app is not added to the projectfiles when a project is created on Windows
- ITGB-131 Load last scene on startup checkbox is being ignored
- ITGB-134 Odd image map behavior
- ITGB-136 Does not remember Layer Management Settings
- ITGB-138 Major distortion when resizing an object that has been rotated
- ITGB-139 Crash when creating a new image map from BMP
- ITGB-141 Orientation change happens at incorrect angles
- ITGB-147 Mount Broken During Copy Paste
- ITGB-148 Minor editor visual issue
- ITGB-149 SourceRect malfunction
- ITGB-152 Undo after Deleting Breaks Mounts
- ITGB-153 Locked objects not excluded with t2dSceneWindow::sendObjectMouseEvent
- ITGB-159 RealMilliseconds/getRealTime bug
About the author
Programmer.
#22
07/29/2011 (6:28 am)
Mich - I added the coremotion.framework to the project and it builds again, however there's no response from the accelerometer. The bound functions don't seem to get called.
#23
07/29/2011 (6:40 am)
I was pretty impressed by how iTorque has been progressing lately, which is one of the main reasons why I picked it up the other day, and of course not to miss out on the great pricing structure! (just in case it goes up anytime soon).
#24
@Paul Jan - What version of iOS are you running on the device? It needs to be 4.0 or higher
@Conor - Can you show me your full code? The ActionMap declaration, the binding and the push?
07/29/2011 (7:53 am)
@sysrat - Add the CoreMotion framework to the project and it should compile@Paul Jan - What version of iOS are you running on the device? It needs to be 4.0 or higher
@Conor - Can you show me your full code? The ActionMap declaration, the binding and the push?
#25
07/29/2011 (7:57 am)
Mich - same scripts as before. See post #4 on page 1.
#26
07/29/2011 (8:02 am)
@Conor - Ah. Try pushing after you bind the commands, not before.
#27
Here's the current script:
game.cs
controls.cs
The echo doesn't appear.
07/29/2011 (8:07 am)
Mich - tried that no luck. Here's the current script:
game.cs
new ActionMap(gameActionMap); enableAccelerometer(); gameActionMap.bind(accelerometer, gravityx, "D", "-0.2 0.2", "tiltX"); gameActionMap.bind(accelerometer, gravityy, "D", "-0.2 0.2", "tiltY"); gameActionMap.bind(touchdevice, touchdown, "pressedScreenInGame"); gameActionMap.push();
controls.cs
function tiltX(%val)
{
echo("Tilt X" SPC %val);
$tiltX = %val;
}The echo doesn't appear.
#28
/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/System/Library/Frameworks/CoreMotion.framework
07/29/2011 (8:11 am)
Does it matter which CoreMotion.framework I'm using? I did a search for that file and found many of them so I figured I should use the latest, which is in:/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.3.3 (8J2)/Symbols/System/Library/Frameworks/CoreMotion.framework
#29
So you have no other warnings or errors in the console log? I'm looking into this now, but it works on all of my builds. I'll investigate this a bit more.
Also, for the sake of a sanity checks, can you confirm RainyDay's accelerometer code does not work?
07/29/2011 (10:21 am)
@Conor - I don't think it matters much, so long as you are adding it through the Xcode interface and it is the most recent framework. The framework has been available in iOS 4 SDKs for a little while now.So you have no other warnings or errors in the console log? I'm looking into this now, but it works on all of my builds. I'll investigate this a bit more.
Also, for the sake of a sanity checks, can you confirm RainyDay's accelerometer code does not work?
#30
iOSMotionManager.mm: Line 225. This will make sure enableAccelerometer() is working
iOSMotionManager.mm: Line 119. This will check to see if the motionHandler is working
actionMap.cc: Line 1350. This will check to see if the InputEvent with the motion flag/data is being processed correctly by the ActionMap system
actionMap.cc: Line 1383 and 1385. This will check to see if the actual script function is being executed
07/29/2011 (10:28 am)
Through Xcode, try placing breakpoints in the following places to make sure the code is being executed:iOSMotionManager.mm: Line 225. This will make sure enableAccelerometer() is working
iOSMotionManager.mm: Line 119. This will check to see if the motionHandler is working
actionMap.cc: Line 1350. This will check to see if the InputEvent with the motion flag/data is being processed correctly by the ActionMap system
actionMap.cc: Line 1383 and 1385. This will check to see if the actual script function is being executed
#31
"Motion Device not supported on this device (check OS)"
This is on an iPod Touch 2nd gen, with iOS 4.2.1
07/29/2011 (9:24 pm)
Mich - The Rainy Day demo builds and runs fine. Dragging the cloud works, but tilting does nothing. There's a message in the console:"Motion Device not supported on this device (check OS)"
This is on an iPod Touch 2nd gen, with iOS 4.2.1
#32
I noticed that in the Rainy Day example the coremotion.framework is added right at the top of the project. I added it into the Frameworks folder - this shouldn't make any difference right?
Does the new actiomap based motion control work for you on a device other than iPhone 4?
07/29/2011 (9:41 pm)
I placed the breakpoints you suggested and none of them are being executed. I also placed a breakpoint in t2dStaticSprite onAdd just to make sure everything was working properly and that one did execute.I noticed that in the Rainy Day example the coremotion.framework is added right at the top of the project. I added it into the Frameworks folder - this shouldn't make any difference right?
Does the new actiomap based motion control work for you on a device other than iPhone 4?
#33
Now the project compiles fine but the echo from default game.cs doesn't appear :(
I think I have the same problem like Conor O'Kane
07/30/2011 (1:07 am)
Quote:
@sysrat - Add the CoreMotion framework to the project and it should compile
Now the project compiles fine but the echo from default game.cs doesn't appear :(
I think I have the same problem like Conor O'Kane
#34
I'm not sure whether this is related, but under Windows I'm not able to "tap" with a mouse click (or drag for that matter) in any of the demos. I wanted to create the prototype on my Windows workstation before having to fire up XCode and the whole environment on OSX which I'm not very familiar with. I guess this is not intended behavior, or is it?
07/30/2011 (1:27 am)
Quote:
The Rainy Day demo builds and runs fine. Dragging the cloud works, but tilting does nothing.
I'm not sure whether this is related, but under Windows I'm not able to "tap" with a mouse click (or drag for that matter) in any of the demos. I wanted to create the prototype on my Windows workstation before having to fire up XCode and the whole environment on OSX which I'm not very familiar with. I guess this is not intended behavior, or is it?
#35
Similarly accelerometer callbacks used to be mapped into the joystick, but now (as of 1.5 preview 2) they're sent to specific accelerometer and gyroscope device callbacks.
So you can prototype in Windows, using onMouse and joystick functions, but bear in mind that you'll have to re-write those to work on the hardware. The easiest way to do this is with a check before you bind your controls:
if ($platform $= "iPhone") // this returns true on any iOS hardware
07/30/2011 (2:26 am)
Konrad - the onMouse functions used to work in iT2D (up to version 1.2), so you could prototype in Windows and the same scripts would work on the device. Those were then replaced with pre-defined oniPhoneTouch functions to allow for multi-touch on the devices. The oniPhoneTouch functions are now being replaced in iT2D 1.5 with the new 'touchdevice' callbacks which can be bound into actionmaps for more flexibility.Similarly accelerometer callbacks used to be mapped into the joystick, but now (as of 1.5 preview 2) they're sent to specific accelerometer and gyroscope device callbacks.
So you can prototype in Windows, using onMouse and joystick functions, but bear in mind that you'll have to re-write those to work on the hardware. The easiest way to do this is with a check before you bind your controls:
if ($platform $= "iPhone") // this returns true on any iOS hardware
#36
07/30/2011 (2:36 am)
That is great info, Conor, thank you very much!
#37
07/30/2011 (5:40 am)
@Conor: If at any point you have options for CoreMotion's framework, you're probably adding it the wrong way. The One True Way should just give you a list of frameworks and dylibs by name, not a file dialog.
#38
Unfortunately the end result is the same - still no tilt response.
07/30/2011 (6:29 am)
Thanks for the cryptic advice Ronny. Fortunately Google is more specific than you and I was able to work out what you're talking about without having to resort to telepathy. I tried adding the framework via the build-phases tab in the target settings. This seems to be the same as adding the framework via right-click/add item but without the chore of locating the folder.Unfortunately the end result is the same - still no tilt response.
#39
@Conor - Ok, so this is the problem: "Motion Device not supported on this device (check OS)". Looking at the code, that only happens in one line:
Check out the all caps comments I place in the above code. deviceMotionAvailable is a property of CMMotionManager, not something I created for iTorque 2D. The iOS SDK is saying your device does not support that capability, which does not make sense.
I did not see anything in the requirement docs about device support, except gyroscope only working on iPhone 4. No where did I see anything about iPod 2nd gen not being supported, but I'm wondering if that's the case. I need to do some digging to figure out what is going on.
Do you have any other devices you can test on? I'm pulling down the build right now to test my 4th gen iPod touch, just to see if I might have accidentally wrote code that locks in the support for iPhone 4 or forgot some logic.
07/30/2011 (7:36 am)
@Konrad - The onTouch callbacks for objects works on Windows, but you will only ever get a single coordinate and ID. The touchdevice code currently only works on iOS, though I have not given up on having that simulate on desktops as well (Windows and OS X). This will be determined by time and manpower.@Conor - Ok, so this is the problem: "Motion Device not supported on this device (check OS)". Looking at the code, that only happens in one line:
- (bool)startDeviceMotion
{
// CHECK TO SEE IF THIS DEVICE SUPPORTS CORE MOTION
if(motionManager.deviceMotionAvailable)
{
if(referenceAttitude == NULL)
referenceAttitude = [motionManager.deviceMotion.attitude retain];
[motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:motionHandler];
}
else
{
// THIS DEVICE DOES NOT SUPPORT CORE MOTION
Con::errorf("Motion Device not supported on this device (check OS)");
return false;
}
return true;
}Check out the all caps comments I place in the above code. deviceMotionAvailable is a property of CMMotionManager, not something I created for iTorque 2D. The iOS SDK is saying your device does not support that capability, which does not make sense.
I did not see anything in the requirement docs about device support, except gyroscope only working on iPhone 4. No where did I see anything about iPod 2nd gen not being supported, but I'm wondering if that's the case. I need to do some digging to figure out what is going on.
Do you have any other devices you can test on? I'm pulling down the build right now to test my 4th gen iPod touch, just to see if I might have accidentally wrote code that locks in the support for iPhone 4 or forgot some logic.
#40
1. Do you get this in the console? "Could not initialized iOSMotionManager!"
2. How many times do you see the message about the motion device not supported? It should be printed twice
07/30/2011 (7:43 am)
Two more questions:1. Do you get this in the console? "Could not initialized iOSMotionManager!"
2. How many times do you see the message about the motion device not supported? It should be printed twice
Torque 3D Owner Ronny Bangsund
Torque Cheerleaders
How's Lion with Xcode 4.2 for this now? I've got 2x Xcode and some OS upgrades to do. Everything appeared while I had no 'net :P