Guide for updating your project to iT2D 1.5
by Conor O'Kane · in iTorque 2D · 09/29/2011 (9:11 pm) · 20 replies
iT2D 1.5 has a completely new directory structure, doing away with the /game and /common folders. To bring your iT2D 1.4.1 project into 1.5 you'll need to update some paths to account for this change.
This list might not be complete so I'll add anything else to this post as it's discovered.
Firstly create a new project in iT2D 1.5 and save it, then quit the editor. Copy all your data (levels, particles, tilemaps, images, audio) into the /projectFiles/data folder.
Copy your datablocks.cs from /game/managed to /projectFiles/managed.
If you've edited your mainScreen.gui (for example to add a new sceneWindow) - copy that into /projectfiles/gui.
System scripts which were in /projectFiles/common/scripts are now found in /projectFiles/scripts/system - you shouldn't need to copy these, but you may want to edit defaultPrefs.cs to set your company name and game title, and set your volume levels.
Copy your scripts into the /projectfiles/scripts folder EXCEPT game.cs.
I recommend you open up the new game.cs and take a look in there - it has example functions for handling all the new touch and tilt controls. You'll want to understand these and use them in your new project. Merge any new scripts in your old game.cs into the new game.cs and then re-write your touch and tilt code to use the new system (it sounds like a big deal, but it's well worth it for proper multi-touch and tilt-actionmaps that you can turn on and off).
Now you'll need to update some paths in your existing scripts and level files...
This path change is not required in the managed/datablocks.cs file - everything in there remains the same.
To get particle effects or tilemaps to work, select the particle effect and reload the emitter/tilemap layer in the editor. Then save the scene (just running the game won't save the changes - you must save the scene to overwrite the .t2d file).
This list might not be complete so I'll add anything else to this post as it's discovered.
Firstly create a new project in iT2D 1.5 and save it, then quit the editor. Copy all your data (levels, particles, tilemaps, images, audio) into the /projectFiles/data folder.
Copy your datablocks.cs from /game/managed to /projectFiles/managed.
If you've edited your mainScreen.gui (for example to add a new sceneWindow) - copy that into /projectfiles/gui.
System scripts which were in /projectFiles/common/scripts are now found in /projectFiles/scripts/system - you shouldn't need to copy these, but you may want to edit defaultPrefs.cs to set your company name and game title, and set your volume levels.
Copy your scripts into the /projectfiles/scripts folder EXCEPT game.cs.
I recommend you open up the new game.cs and take a look in there - it has example functions for handling all the new touch and tilt controls. You'll want to understand these and use them in your new project. Merge any new scripts in your old game.cs into the new game.cs and then re-write your touch and tilt code to use the new system (it sounds like a big deal, but it's well worth it for proper multi-touch and tilt-actionmaps that you can turn on and off).
Now you'll need to update some paths in your existing scripts and level files...
Loading levels path changed in game.cs from
sceneWindow2D.loadLevel(expandFileName ("~/data/levels/name.t2d"));
to
sceneWindow2D.loadLevel(expandFileName ("~/../data/levels/name.t2d"));
Level datablocks paths in data/levels/datablocks files changed from
new t2dImageMapDatablock(nameImageMap) {
imageName = "~/data/images/name.png";
to
new t2dImageMapDatablock(nameImageMap) {
imageName = "~/images/name.png";
Tilemap paths (in .t2d files) changed from
new t2dTileLayer(name) {
LayerFile = "~/data/tilemaps/name.lyr";
to
new t2dTileLayer(name) {
LayerFile = "~/tilemaps/name.lyr";
Particle effect paths (in .t2d files) changed from
new t2dParticleEffect(name) {
effectFile = "~/data/particles/name.eff";
to
new t2dParticleEffect(name) {
effectFile = "~/particles/name.eff";
Audio paths in scripts/audioDatablocks.cs changed from
~/data/audio/sound.wav
to
~/../data/audio/sound.wavThis path change is not required in the managed/datablocks.cs file - everything in there remains the same.
To get particle effects or tilemaps to work, select the particle effect and reload the emitter/tilemap layer in the editor. Then save the scene (just running the game won't save the changes - you must save the scene to overwrite the .t2d file).
About the author
www.cokane.com
#2
09/30/2011 (6:40 am)
@Connor - Many thanks! I have stickied this thread and will add to it once I regain my senses.
#3
Ill let you know once i figure out why they've all got screwed up as there may be some additional tweaking required to upgrade to 1.5 final.. either that or something just broken with large scenes. (My other scene is fine, but doesnt have anywhere near as much stuff on it)
09/30/2011 (6:48 am)
Cheers for the upgrade guide Conner, ive just upgraded my iT2D project from preview 2 to the final release, however one of my scenes has become completely screwed, not sure why yet. There is a fair few objects (~70) in the scene and a heap of them have moved to one spot (all on top of each other) and some of the images are not displaying (even though i can see them in the sprite picker and can drop new versions of them into the scene, references to the imagemap look correct). Also finding that most of the screwed objects that aren't displaying also cant be selected in any way except by using the object tree.Ill let you know once i figure out why they've all got screwed up as there may be some additional tweaking required to upgrade to 1.5 final.. either that or something just broken with large scenes. (My other scene is fine, but doesnt have anywhere near as much stuff on it)
#4
09/30/2011 (12:37 pm)
@Craig - Read through the new Universal App Support doc. It explains a lot of what's going on.
#5
It seems quite easy to reproduce the fault.
Can you please try this simple test using the feature demo and tell me if it screws up on your 1.5. Open the main menu scene of the feature demo, select the "MultiTouch" sprite, click "Mount this object to another object" and mount it to the main window that it sits on. All looks fine so far. Click on the main window image and click "Edit this objects link points". You should see that the link point shows in the list on the right, however the little blue box overlaying the position on the sprite has no number inside it. Click "Save" and the "Multitouch" sprite disappears. You cannot get it back or select it on screen. You can use the object tree to select it, but then you cant manipulate it in any way. Only way ive found to get it back is to edit the level file and delete the link point information.
Could you please try the above and let me know if what ive said happens on your copy as well.
10/01/2011 (6:43 am)
@Michael - Thanks, have had a read but Universal App support has nothing to do with the issue im having. As far as i can tell, the mounting system appears to be faulty in the 1.5 final release. I hope im wrong and theres something screwed with my installation of 1.5, but mounted objects definately seem to not work in 1.5. All the objects that were on top of each other or not visible appeared perfectly when i deleted all the link point information in the level file then reloaded it in iT2D 1.5. Whenever i click to view all link points for an object all the little blue squares appear but none of them have numbers.It seems quite easy to reproduce the fault.
Can you please try this simple test using the feature demo and tell me if it screws up on your 1.5. Open the main menu scene of the feature demo, select the "MultiTouch" sprite, click "Mount this object to another object" and mount it to the main window that it sits on. All looks fine so far. Click on the main window image and click "Edit this objects link points". You should see that the link point shows in the list on the right, however the little blue box overlaying the position on the sprite has no number inside it. Click "Save" and the "Multitouch" sprite disappears. You cannot get it back or select it on screen. You can use the object tree to select it, but then you cant manipulate it in any way. Only way ive found to get it back is to edit the level file and delete the link point information.
Could you please try the above and let me know if what ive said happens on your copy as well.
#6
Michael, should we post this in the bug section?
10/01/2011 (10:12 pm)
Craig, I have the same issue with mounting in my project; don't have numbers only boxes, when I re-open the level the mount positions are completely off and some objects aren't visible.Michael, should we post this in the bug section?
#7
10/01/2011 (10:23 pm)
I do all my mounts via script so I wouldn't have noticed this.
#8
10/01/2011 (10:49 pm)
@Conor - Thanks so much for this! It only took me a few minutes to upgrade a project while following this guide.
#9
10/04/2011 (3:05 am)
@Michael - Just wondering if there is any update on the issue myself and Eric Sapp are having with mounting points appearing to be completely broken in 1.5 (see previous messages in this post)
#10
10/04/2011 (8:01 am)
Very useful post, thanks! I need to start digging into the input changes next ;)
#11
I did, and got 90% of it, semi thoroughly, but after going over it again, I get it 100% thoroughly.
Very useful.
Thanks!
10/05/2011 (5:22 am)
@Connor. I did, and got 90% of it, semi thoroughly, but after going over it again, I get it 100% thoroughly.
Very useful.
Thanks!
#12
10/10/2011 (3:51 pm)
Has anyone had an issue with the gui's not loading properly? I am getting boxes where my text characters should be. And some of the images load as blank boxes until changed in code.
#13
10/10/2011 (8:49 pm)
Would I need to do this in order to get the PSK 1.4 Pro to work with the new iT2D? I can't seem to open any of the TGB project files or demo levels from the PSK.
#14
Do you have a few lines of code you could post as an example? I couldn't find anything in the docs, or other threads on how to do it via script
ultimately, I want to create text in script, then mount to an existing object.
10/16/2011 (8:37 pm)
@connerQuote:I do all my mounts via script so I wouldn't have noticed this.
Do you have a few lines of code you could post as an example? I couldn't find anything in the docs, or other threads on how to do it via script
ultimately, I want to create text in script, then mount to an existing object.
#15
Scroll down to
Some examples from my games:
10/16/2011 (10:36 pm)
Ray - docs.garagegames.com/it2d/official/content/documentation/Reference/t2dSceneObjec...Scroll down to
mount(t2dSceneObject object,[float offsetX=0],[float offsetY=0],[float mountForce=0],[bool trackRotation?=true],[bool sendToMount?=true],[bool ownedByMount?=true],[bool inheritAttributes?=true])
Some examples from my games:
// mounting an image in the game's menu menuGirlRed.mount(menuGirlRed.moveTarget, 0, 0, $menuMountForce, false, true, false, false); // mounting a menu button to a moving frame menuButtonStart.mount($moveTargetMenu1, $moveTargetMenu1.getLocalPoint(menuButtonStart.getPosition()), $menuMountForce, false, false, false, false); // mounting a muzzle-flash animation to an aircraft sprite // this one shows how to mount to a linkpoint %this.muzzleFlash1.mount(%this, %this.getLocalPoint(%this.getLinkPoint(1)), 0, true, true, false, false);
#16
Thanks for the examples!
I did try to use the search function in the official online docs, on the word 'mount', and only t2dSceneWindow and t2dSceneGraph came back. Next time I will look at the more generic objects to see if the properties I am looking for are there.
I am slowly getting the hang of this, thanks to the forums and resources available!
10/18/2011 (12:41 pm)
@ConnerThanks for the examples!
I did try to use the search function in the official online docs, on the word 'mount', and only t2dSceneWindow and t2dSceneGraph came back. Next time I will look at the more generic objects to see if the properties I am looking for are there.
I am slowly getting the hang of this, thanks to the forums and resources available!
#17
11/08/2011 (2:07 am)
This might help someone. I know it's implied above, but at first I didn't spot that in 1.5 the onMouse family of functions have been replaced by onTouch family.
#18
However, I also tried loading my tilemaps and sprites, then saving them like you said. It does not seem to work. Does this process work when porting from T2D?
Thanks!
02/17/2013 (11:26 pm)
Conor, I used your instructions to get most of my stuff running from T2D 1.7.6 to iT2D 1.5.However, I also tried loading my tilemaps and sprites, then saving them like you said. It does not seem to work. Does this process work when porting from T2D?
Thanks!
#19
Your sprites and animated sprites should all work though.
02/17/2013 (11:34 pm)
Charlie - unfortunately tilemaps and particles made in T2D aren't compatible with iT2D. You'll have to make them again in the iT2D editor. Your sprites and animated sprites should all work though.
#20
I see you are up Sunday night working on your next iPad game. :)
02/18/2013 (12:01 am)
OK. Thanks. An import/export tool based on chunks of source. Hmm...I see you are up Sunday night working on your next iPad game. :)
Conor O'Kane
cokane.com
On iOS hardware:
function ingameTouchDown( %touchNums, %touchX, %touchY ) { %numTouches = getWordCount( %touchNums ); for(%count = 0; %count < %numTouches; %count++) { %curTouch = getWord( %touchNums, %count ); %curX = getWord( %touchX, %count ); %curY = getWord( %touchY , %count ); %screenPosition = %curX SPC %curY; %worldPosition = sceneWindow2D.getWorldPoint(%screenPosition); if (%curTouch == 0) // first touch // you might want different results for subsequent touches { %scenegraph = player1.getSceneGraph(); // you could have more than one sceneGraph %pickList = %scenegraph.pickPoint(%worldPosition); // this returns a list of all objects at this worldposition // you could also use pickRadius for a larger 'touch' area %objCount = getWordCount(%pickList); // how many objects were at this location? for (%i = 0; %i < %objCount; %i++) { // Now look at all the objects just touched // and see if any of them are important. // If the user has touched multiple overlapping objects // you need to decide how to handle this. %pick = getWord(%pickList, %i); if (%pick.isPlayer) { // this is where your player touch script goes } else if (%pick.class $= "enemyClass") // another way to check what you've touched is by class { // this is where your enemy touch script goes } } } } }On Mac or Windows:
function t2dSceneWindow::onTouchDown(%this, %touchID, %worldPosition) {The rest of the code is the similar, use the worldposition to create a picklist and check what you've picked. With the mouse you'll only get 1 touch at a time, but at least you can use the same scripts for desktop or iOS hardware, which makes testing a lot easier.
It's basically the same for touchMove and touchUp.
You can now bind touch events to actionMaps so you can have separate touch functions for in-game or at the menu screens.