Game Development Community

Handling .gui and .t2d assets for both iPhone and iPad

by Justin Mosiman · in iTorque 2D · 12/10/2010 (2:38 am) · 3 replies

Hi all,

For those of you who are making both an iPhone and an iPad version of your game, how are you handling your .gui and .t2d level files? I can get the game running fine on the iPad, it's just that the .gui files look like they are running on an iPhone. The objects from the .t2d file are sized correctly for the iPad (screenshot on the top). I then thought that I could automatically scale the .gui files up for the iPad and everything would run well. I added the following code to GuiControl::addObject just as a quick check:
RectI iPadBounds = ctrl->getBounds();
iPadBounds.extent.x *= 2.1333;
iPadBounds.point.x *= 2.1333;
iPadBounds.extent.y *= 2.4;
iPadBounds.point.y *= 2.4;
ctrl->setBounds(iPadBounds);

However, with this, the objects from the .gui file scale correctly, but the objects from the .t2d file have also increased in size (screen shot on the bottom).

www.opsive.com/iTGB/resolutiondiff.png

I didn't think the objects in the .t2d file were this integrated with the objects in the .gui files. With this in mind, how is everybody else handling the multiple resolutions for these files? Am I approaching it correctly?

#1
12/10/2010 (3:16 am)
In theory, your code would work if it weren't for the fact that t2dSceneWindow is a child class of GuiControl. The camera, t2dSceneObjects, etc, will all be affected by your scaling. If you are looking to continue your modifications based on your original theory, I would implement some kind of check to determine what device you are running on and scale according to that...but not globally on GuiControl.
#2
12/10/2010 (8:44 pm)
Sorry can't help Justin, we just went with separate apps for iPad and iPhone.
#3
12/11/2010 (6:12 pm)
Thanks Michael, I didn't realize t2dSceneWindow was a child of GuiControl. I added a field to GuiControl which says whether or not to scale the content based on the device. Now it scales perfectly!