Game Development Community

a few woes

by rennie moffat · in iTorque 2D · 06/17/2010 (9:30 am) · 181 replies

Hi there, anyone who has been following me this week understands my situation. I built, stupidly, my app in TGB, not iTGB, anyhow, essentially I have simply been transferring all I did into iTGB however I have run into two problems.


1. when I run my game it crashes.

2. my player animation (idling) is of the same size (object is 32x32) however in TGB the actual sprite, at least what was visible was only a quarter of that size. It sat, very quietly in the middle, in other words it did not take up the whole 32x32 space. In iTGB however the object is still 32x32 but the animation is bloated. It is stretched out to fill the entire space. I am not sure why, any suggestions?

edit; cont from pt2.
I have just noticed, as I say, my level, opened up, everything appears to be fine. all objects, positions, sizes are correct. However, when I drag in those same elements into the editor fresh, they are a good 20% larger. I think this may have something to do with resolution, but in the level.t2d's I see no "resolution" or something like that to adjust.


3. Images are not being called.
I have redone every image i needed, created animations, etc. Saved then reloaded my game. All images are gone. They still exist in the folder "game/data/images" but are not called into the editor.

3 cont.
I just created a whole new project and loaded in one image, thinking one of my files may have corrupted the project, but the same thing happened. The message i get is...
Quote:
Invalid Project Data
This project contains 1 invalid datablock. This is likely because a referenced image file was deleted from the project directory.

How can this be? I created the image, simply calling into the editor, pulled it onto the level editor, saved, then reloaded the game just to test.







If anyone can help me out with these pressing issues I would greatly appreciate it.

Thanks.




About the author

My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.

#101
06/22/2010 (11:43 am)
Phew! I'm gonna go and pour myself a beer :)

By default EVERYTHING on the iPhone has physics switched off (might have changed in 1.4?). Therefore, for anything to move etc it must have the UsesPhysics flag set to true.

Hopefully you're over the worse of the TGB->iTGB shenanigans and rest will be plain sailing.
#102
06/22/2010 (11:44 am)
Now thats funny, I said that you need to enable that 2 pages further to front.

On iTGB you must enable physics because the object otherwise does not use any physics at all.
Thats for performance reasons, because physics are pretty costly and you really don't want to enable it on objects that definitely need it.

you can do it at runtime too through SetUsesPhysics(...) btw
#103
06/22/2010 (11:50 am)
but I don't get it, I am not using physics. at least on the TGB side. Anything that moves on the iPhone, does it use Physics?


And mmmmmman, If I could I would email you a keg.
Thank you so much Scott, I really appreciate it. I could not have done it with out you. Cheers!




@Marc, yes, I simply did what I thought you meant, set physicsSuppress to false. I did that and it did not work, you never busted out the handy dandy UsesPysics Mark pulled out! Anyhow, still your help was greatly appreciated too, no jealousy now. HAha
#104
06/22/2010 (12:19 pm)
You are using physics, pretty surely :)

MoveTo, Rotate etc are all physical operations, they are not "non physics".

The only way to do it non physical, is doing it manually through altering the position etc in which case also collision won't work right anymore.

Its a thing where most who came over from TGB ran into, so nothing to worry about. Though by now most of the things are documented in the PDF (I would highly recommend to look through them if you haven't yet) unlike back then :)
#105
06/22/2010 (1:16 pm)
sweet dude.

thank you for all your help.


#106
06/22/2010 (5:08 pm)
Rennie, I wasn't targetting you or anyone specific when I mentioned TGB versus iTGB, it was just a general comment. Even the GG staff themseleves try to discourage people from comparing TGB to iTGB, even though their marketing blurb makes everyone think that porting is easy. Porting from TGB to iTGB isn't trivial, that's a fact, and I'm not trying to say that it is, but I am trying to point out is that they are in fact almost the same, and with some effort it wouldn't be impossible to create a more unified system that works for all platforms.

Scott, regarding my breakout code, Dean has been really helpful as he is the one who is hosting the files from his own website. I posted a thread about it, but I think only person has used it, which is disappointing because I was really hoping it would help a lot of new people.
#107
06/22/2010 (5:12 pm)
Marc, I agree. The main things that catch people who move from TGB to iTGB (and I had the same problem myself also), are 1) SetUsesPhysics, and 2) level datablocks. The one that got me was the physics one, because I don't think that was even documented at the time.
#108
06/22/2010 (5:31 pm)
Porting is easy and trivial, but porting means: You understand what you use and you understand what you will use.

If not both does hold, its only easy with "convert" not with "port" where the user is meant to do the conversion of code, scripts and assets. I think thats where some of the problems and struggling comes from.
More and more informations and shared experience on what to look out for though makes that less and less painfull as many of the new people here potentially realized (or not, but the original users can assure you as non source user you didn't stand much of a chance to get anywhere with iTGB 1.0 through 1.2)

that though does not remove the requirement that games must be opted. I've not seen a single TGB applications thats not horribly anti-optimized and stands a chance of more than 10% to not run horrible on the real device.
Among the worst errors that are commonly made, the "create and trash objects all day long" is definitely in the top 3. Pooling is a fundamental thing on the iphone, as object creation and destruction is among the very slowest operations (thats why high trash creation UIKit things like the lists have a special function to request reusable objects like the list entries that go into an internal pool)


At least thanks to 3GS+ generations, we are now at the point where even TGB not only TGB Pro users can move over easily cause the CPUs are now strong enough to handle script based games. Before the clear requirement was "C++ programmer or no go" (though even now there are things you better do through that end).


@Mark: Yupp wasn't documented for a while but the "MoveTo" does not move issue ensured that a new thread was up on page one every week basically ^^
#109
06/22/2010 (5:47 pm)
Marc, you're right that porting to the level that a game runs fast enough on the device requires a lot more effort than just converting a few scripts. I guess what I am talking about is just the initial conversion stage i.e. just getting something to work. Even that part seems to be a struggle for a lot of beginners, which is where my breakout code may help. For me, that was just a starting point for my own game, but obviously, since then, I've optimised a lot of things and moved some of the functions over to C++. But, having said that, my original breakout code, even though it's just a conversion an non-optimised, it's still playable on a 2nd gen iPod touch.

I agree about your comments about C++ also. I purchased a 3rd gen iPod just 2 or 3 weeks ago, but I am really impressed how fast my game runs on that device, and I have actually found that I can do almost everything I need in script and the games still runs fast enough. As we move forward with 4th gen devices and beyond, I think it might be possible to do everything in script.



#110
06/22/2010 (6:30 pm)
Quote:
Marc, I agree. The main things that catch people who move from TGB to iTGB (and I had the same problem myself also), are 1) SetUsesPhysics, and 2) level datablocks. The one that got me was the physics one, because I don't think that was even documented at the time.

agreed with both Marc and Mark. It is easy, once you know what to do. Such simple steps should be made much more obvious. If they (GG) did that, the argument for it being complicated could not be made. I did not find those steps obvious. But now that I know, knowing is half the battle. GI JOoooe.






#111
06/22/2010 (6:44 pm)
Unhappily the iPhone 4 and the iPad have much faster cpus while being much more limited on the GPU (its the 3GS one yet it has to render 4 / 5.2 times the pixels which is where its major bottleneck bumps in) especially when it comes to iTGB that runs with quads + alpha cutouts which is the "wost case scenario" on those devices. Multilayered tilemaps with transparency are a big no go for example
#112
06/22/2010 (6:49 pm)
Rennie, I think a lot of people just give up trying. I've seen a lot of people visit the forums, post a couple of newbie questions that don't get answered and then you never see them again. That's unfortunate because, just like you mentioned, it is quite easy once you know how. There are several fairly trivial gotchas, that are easy to fix, but when someone is totally new those little gotchas are huge problems. I remember the first couple of weeks of trying to use iTGB I couldn't believe all the problems I was facing and I didn't think I'd ever get it working. But, now when I reflect back, I really only had a few minor problems, which were fairly simple to fix (once I knew how).

Anyhow, I'm glad to see that you stuck with it!
#113
06/22/2010 (6:52 pm)
Marc, that's bad news about the GPU. It seems crazy that they upped the number of pixels by a huge amount and then still use the same old GPU. Hopefully when the 4th gen iPod Touch comes out, that one will have a newer version of the A4 with a better GPU.
#114
06/22/2010 (7:02 pm)
We will see if the iphone 4 has an upgrade on that, though I take it as near granted that new gpu = new chip name (A5 or whatever)

Also the iTouch will definitely not get an upgrade to the gpu and cpu. The itouches never got that (not even the 2nd gen itouch which is faster than iphone 3G. there its actually vice versa: the 3G was artificially clocked down for battery reasons)
I think the only reason they happen months later is cause apple is technically not able to produce enough of both to deliver, they are already incapable to create enough iphones and ipads (so I am unsure if we will see itouche upgrades this year at all as apple is still out of stock in various countries for ipad and the iphone 4 will run on nil stock till at least august if not sept due to the global stacked release, both eating the A4s needed for itouch too).

another thing I'm nearly sure we can forget on the itouch end is likely the retina screen. Rumors that the amount of screens is already too low to fill the demand of the iphone 4 (which started to spread already 2 months upfront launch) seem to be right if we go by the backshift of original preorders (even if the amount of interest was higher than planned, apple originally planned to have the european launches shortly after so they had a stock large enough or should have had one) indicates that the yield and stock of screens is not up to the demand and production of the rest.
By now, european countries do not even have dates anymore, switzerland has not even gotten prices yet (as with the ipad), as such I expect the iPhone to not launch here before mid / end of august actually
#115
06/29/2010 (5:09 pm)
Hi there,
I am just adding "UsesPhysics = "1";" to all moving objects in my game. I am doing this by adding them to the emptyLevel_Datablock.cs. This datablock (and correct me if I am wrong) seems to hold all datablocks for all levels. Anyhow, if this is the case, it is a bit of a pain in the but as the same object type or part of a word is repeated over and over many times. I am wondering, is there an easier way to add "UsesPhysics = "1";" to each relevant datablock in a much more efficient way rather than searching thru in my text editor?



Also... The size of the final project should be under 10MB. My question is, is the whole file as in ~/MyProjects/MyGame, is MyGame file, the file that is uploaded? as in, is whatever size that file is will be the size uploaded to iTunes?
#116
06/29/2010 (5:19 pm)
Rennie, the datablocks file name should match the name of your level

e.g. if your level is called "level1.t2d" then your datablocks file for this level is level1_datablocks.cs

WRT to writing the same stuff over and over ... well I define a common datablock and then have my other similar datablocks extend it.

For example of my flying saucers I have this in my datablocks file ...

//
	// Flying Saucer
	///////////////////////////////////////
	new t2dSceneObjectDatablock(BaseFlyingSaucer) {
		class = "FlyingSaucer";
		layer = "12";
	  	usesPhysics = "1";
		graphGroup = $SAUCER::groupNumber;
	        collisionLayers = "1118224";
		collisionGroups = "16";
		collisionPhysicsReceive = "0";
		collisionPhysicsSend = "0";
		collisionActiveReceive = "0";
		collisionActiveSend = "1";
		collisionCallback = "1";
		worldLimitCallback = "1";
		worldLimitMax = "260 160";
		worldLimitMin = "-260 -160";
		worldLimitMode = "NULL";
		maxSpeed = "250.000";
		hitCount = 1;
		size = "32.000 32.000";
	};
	
	
	// Saucer 1
	new t2dSceneObjectDatablock(Saucer1 : BaseFlyingSaucer) {
		animationName = "saucer1animation";
	        linearVelocity = "60.000 00.000";
		maxSpeed = 60;
		hitCount = 1;
		points = 50;
		type = 1;
	};
	
	
	// Saucer 2
	new t2dSceneObjectDatablock(Saucer2 : BaseFlyingSaucer) {
		animationName = "saucer2animation";
	        linearVelocity = "90.000 00.000";
		maxSpeed = 120;
		hitCount = 1;
		points = 75;
		type = 2;
	};
#117
06/29/2010 (5:32 pm)
That is great Scott thanks, you are certainly earning your money. But seriously, I do have a question regarding your answer.


1. "BaseFlyingSaucer" is an object. Can we consider this the "mother clone" so to speak and any object that is named appropriately via the datablock ie. "(Saucer1 : BaseFlyingSaucer)" refers back to "the mother clone" BaseFlyingSaucer?

2. Saucer1, I would just name via the editor, and then via the datablock I would change the name from "(Saucer1)" to "(Saucer1 : BaseFlyingSaucer)"?

3. you have a few things repeated in the sub objects, ie, maxSpeed, hitCOunt etc. is this on purpose?

4. RE: levelName_Datablock.cs, do I simply name a datablock, in the game/data/levels "levelName_DataBlock.cs" and then it is called when that appropriate level is loaded? Or must I link it somehow? I tried ealier, by naming it, and it seemed to turn up empty. I then just added in my relavent datablocks into the emptyLevel_Datablock.cs and got the images loaded.:::?




and 5. but unrelated, would you have any info to the edited in question I asked in post 115?
my quote:
Quote:
Also... The size of the final project should be under 10MB. My question is, is the whole file as in ~/MyProjects/MyGame, is MyGame file, the file that is uploaded? as in, is whatever size that file is will be the size uploaded to iTunes?

also, thanks!



#118
06/29/2010 (10:19 pm)
Rennie, regarding the file size I think it is the size of the final product that is seen on iTunes, after Apple has done whatever it does. From what I have read, the size of the bundled data that the developer uploads to Apple will get expanded slightly, so you will need to be aware of that.

Having said the above, I think the max amount has since been increased to 20 MB, at least that is what I heard. If that is true, 20 MB is a lot and I doubt you'll have any problems meeting those requirements.
#119
06/29/2010 (10:34 pm)
@Rennie

If you need help with the graphics, you can email me all your graphics and I will optimize them for you. dean at deanparker dot com
#120
06/30/2010 (1:07 am)
Rennie, answers inline:


1. "BaseFlyingSaucer" is an object. Can we consider this the "mother clone" so to speak and any object that is named appropriately via the datablock ie. "(Saucer1 : BaseFlyingSaucer)" refers back to "the mother clone" BaseFlyingSaucer?

Yes, it will inherit the attributes from the base (mother) but can override any base values with its own.

2. Saucer1, I would just name via the editor, and then via the datablock I would change the name from "(Saucer1)" to "(Saucer1 : BaseFlyingSaucer)"?

I don't use the editor for this sort of stuff at all. I think there is a field there somewhere for this? This is where you would put BaseFlyingSaucer. You can try it and see if you get the same format in your datablocks file when you save from the editor.

3. you have a few things repeated in the sub objects, ie, maxSpeed, hitCOunt etc. is this on purpose?

They are overriding with different values, well, I could have left hitCount out of the child datablock as that is in the base, but you will notice that they have different max speeds for example.

4. RE: levelName_Datablock.cs, do I simply name a datablock, in the game/data/levels "levelName_DataBlock.cs" and then it is called when that appropriate level is loaded? Or must I link it somehow? I tried ealier, by naming it, and it seemed to turn up empty. I then just added in my relavent datablocks into the emptyLevel_Datablock.cs and got the images loaded.:::?

My understanding is that it automatically searches for the datablocks file by keying off the level name using the format <levelName>_datablocks.cs. Must be in the datablocks folder as well.