Reloading/restarting a level
by Mr Zurkon · in iTorque 2D · 09/07/2011 (7:50 pm) · 27 replies
I'm trying to have the game/level restart when the player dies, but I've ran into some problems. When I reload the level (using loadLevel), the loop adding the objects no longer finds them:
It's the line:
Are there any articles/tutorials about how to properly reload a game? How do I stop all the loops I have running and ensure a "clean" restart? I have several loops running in game.cs and I need to make sure they stop at restart.
game/scripts/game.cs (1094): Unable to find object: '1170' attempting to call function 'addToScene'
It's the line:
$MySceneGraph.addToScene(%object);that fails.
Are there any articles/tutorials about how to properly reload a game? How do I stop all the loops I have running and ensure a "clean" restart? I have several loops running in game.cs and I need to make sure they stop at restart.
About the author
#22
If you want the better images for retina and would like to save memory on the older devices then you should detect the device type and load the appropriate image.
If you want to support retina and don't care about memory on older devices then Pedro's method is the way to go.
09/09/2011 (3:06 pm)
If you don't plan to detect (support) retina then don't worry about it.If you want the better images for retina and would like to save memory on the older devices then you should detect the device type and load the appropriate image.
If you want to support retina and don't care about memory on older devices then Pedro's method is the way to go.
#23
yes, in retina, a 128x128 pixel size image appears as 64x64 space if you set %obj.setSize( 64, 64 );
in retina the units are 320x480 points; the difference is that on standard displays 1 point equals one pixel, and on retina 1 point equals 2 pixels.
in standard the units are also 320x480, but pixels; so, this means that we just do all our game object positioning in the same 320x480 logical space both for retina and standard; in other words, we don't have to change anything in code for it to work in retina.
so, yes, it's just plug the code into the proper scripts and supply the correct imagery :-)
regarding iPad 768x1024 images the only case that you *must* do a code switch is for backgrounds, where the physical space is different iPhone/iPad. This is done in the resource in a function called loadBackground.
The rest is up to you, if you want for the images to look the same (that is same space) on iPhone vs iPad. For example, you might want to display the buttons bigger as 128x128. In this case you have to do a code switch iPhone/iPad and do %obj.setSize (128, 128) for iPad. Until they come with an iPad3 twice the resolution of course.
@Scott
ah, memory, always an issue. In my case it is not an issue at all, my game uses a background and about 10 128x128 images.
That's why if you see the resource all images are loaded at start. This probably would not work in "Cannibal Cookout" :-), where there is a huge amount of levels (60 something ? ); probably the most amount of levels I saw in a iPhone game. And btw, the graphic artists did a splendid job, the interface is the best I ever saw in iPhone.
@rennie
one detail for the retina, is that you have the do the engine Objective-C changes described in the resource.
09/09/2011 (4:00 pm)
@rennieyes, in retina, a 128x128 pixel size image appears as 64x64 space if you set %obj.setSize( 64, 64 );
in retina the units are 320x480 points; the difference is that on standard displays 1 point equals one pixel, and on retina 1 point equals 2 pixels.
in standard the units are also 320x480, but pixels; so, this means that we just do all our game object positioning in the same 320x480 logical space both for retina and standard; in other words, we don't have to change anything in code for it to work in retina.
so, yes, it's just plug the code into the proper scripts and supply the correct imagery :-)
regarding iPad 768x1024 images the only case that you *must* do a code switch is for backgrounds, where the physical space is different iPhone/iPad. This is done in the resource in a function called loadBackground.
The rest is up to you, if you want for the images to look the same (that is same space) on iPhone vs iPad. For example, you might want to display the buttons bigger as 128x128. In this case you have to do a code switch iPhone/iPad and do %obj.setSize (128, 128) for iPad. Until they come with an iPad3 twice the resolution of course.
@Scott
ah, memory, always an issue. In my case it is not an issue at all, my game uses a background and about 10 128x128 images.
That's why if you see the resource all images are loaded at start. This probably would not work in "Cannibal Cookout" :-), where there is a huge amount of levels (60 something ? ); probably the most amount of levels I saw in a iPhone game. And btw, the graphic artists did a splendid job, the interface is the best I ever saw in iPhone.
@rennie
one detail for the retina, is that you have the do the engine Objective-C changes described in the resource.
#24
09/09/2011 (5:52 pm)
@Pedro, yes, memory is a huge problem for CC, hence me switching to Force 16 bit gfx for the main game scene. The biggest problem is the iPad 1, has to handle the large gfx, yet has the same amount of memory as a 3GS!!
#25
I tried your minimalist template and i got it working nicely. However, when I try to run it on xcode simulator it's missing files.
10/02/2011 (6:24 pm)
@PedroI tried your minimalist template and i got it working nicely. However, when I try to run it on xcode simulator it's missing files.
Initializing chunk mappings... o 'TEXT' maps to TextChunk o 'SCHK' maps to UnknownChunk o 'SCHK' maps to SimChunk Binding server port to default IP Missing file: /Users/zurkon/Library/Application Support/iPhone Simulator/4.3.2/Applications/E03EADFD-05C2-4230-9D67-D3D0055E6817/iTorque2DGame.app/scripts/audio.cs! Missing file: /Users/zurkon/Library/Application Support/iPhone Simulator/4.3.2/Applications/E03EADFD-05C2-4230-9D67-D3D0055E6817/iTorque2DGame.app/scripts/utils.cs! Default BPP Chosen , $pref::iDevice::ScreenDepth was not found. Activating the OpenGL display device..the files it's looking for are actually in those folders. could anyone tell me where these paths are set?
#26
in this page there is a link for the complete project to download
Torque Minimal Template -- Part 5. Levels, sound and ML text
It's a complete Windows only project with executable and the missing above listed files are there; right now I don't recall if I actually tried the project in a Mac and I am travelling without a Mac now, so I cannot check that; but I don't see why it should not work.
my way of working is
1) develop on windows
2) have a version control svn based linux server to commit
3) check out from the Mac and deploy to device
so, this avoids things like copying files all the time, etc; I never had any problems with missing files using this method; occasionally I had to rebuild all the XCode project to update *images* only (probably some script running at start that copies the images).
ah, I think you may have to drag those files to the "resources" folder on the Mac, that should do it
10/02/2011 (10:15 pm)
@Mr Zurkonin this page there is a link for the complete project to download
Torque Minimal Template -- Part 5. Levels, sound and ML text
It's a complete Windows only project with executable and the missing above listed files are there; right now I don't recall if I actually tried the project in a Mac and I am travelling without a Mac now, so I cannot check that; but I don't see why it should not work.
my way of working is
1) develop on windows
2) have a version control svn based linux server to commit
3) check out from the Mac and deploy to device
so, this avoids things like copying files all the time, etc; I never had any problems with missing files using this method; occasionally I had to rebuild all the XCode project to update *images* only (probably some script running at start that copies the images).
ah, I think you may have to drag those files to the "resources" folder on the Mac, that should do it
#27
there is a problem with fonts not being loaded, but it appears to be a general issue.
10/03/2011 (9:27 am)
Moving the files to the app resources worked. It runs now. Thanks!there is a problem with fonts not being loaded, but it appears to be a general issue.
Torque Owner rennie moffat
Renman3000