Game Development Community

iT2D 1.5 Release - Universal App doesnt work in Portrait mode

by Craig Jorgensen · in iTorque 2D · 10/15/2011 (9:40 pm) · 24 replies

Ive been banging my head against a wall trying to figure out why i just couldn't get my iTGB 1.5 prev2 projects to work in iTGB 1.5 final on iPhone4. Did some simple tests by creating new projects in 1.5 final and found that if you set it to Portrait mode it does not work on iPhone4 at all, you just get a black screen. Works fine if you switch to landscape mode though.

Very easy to reproduce, just do the following
Load iTGB 1.5, select Create Project->Ipad
Goto Project set as Ipad, set as Portrait, press Apply
Goto Create->Add Image->choose Backdrop.jpg from feature demo
Drag Backdrop imagemap to canvas
Resize to 768x1024
Move to pos 0, 0
Add to datablocks
Press Play->iPhone, shows all good
Press Play->iPad, shows all good
Save, exit iTGB

for me, i changed iOS target to 4.1, as my iPhone is running v4.1, but i dont think this has anything to do with the prob, as landscape mode works fine.

load xcode and build->run to iPhone4

App splash screen comes up, then screen flickers white then just goes black.

If you load iTGB and change it to landscape mode and resize the image on the canvas appropriately, then recompile and deploy to iPhone4, it comes up fine.

Ive been waiting for iTGB 1.5 for the universal app support before releasing my game, but my game is designed for portrait mode, so currently 1.5 doesnt work at all for me. Not to mention also the issue with mounts being broken in 1.5.

Hopefully this issue can be resolved fairly quickly, otherwise my only option will be to release with iT2D preview 2.

Cheers
Craig
Page «Previous 1 2
#1
10/16/2011 (7:41 am)
@Craig - As soon as I wake up a little more, I will try to reproduce the problem. Can you e-mail me the console log from Xcode and a sample project with the problem?
#2
10/16/2011 (8:50 am)
@Craig - Never mind. I managed to reproduce it on my end. I'm debugging this as we speak. As soon as I find the cause, I will post here and work on getting a hot fix uploaded.

Let me know if you make any other discoveries.
#3
10/16/2011 (9:21 am)
I've isolated the problem in source code. I'm working on a solution now.
#4
10/17/2011 (6:12 am)
The problem has to do with the resolution being set to double if the engine detects it is running on an iPhone 4. The fact that it works on landscape, but not in portrait, is baffling. When I hard set the resolution to 960x640, everything renders correctly. However, the actual window is incorrect.

At any rate, I'm close to the solution.
#5
10/17/2011 (7:52 am)
Grr. Just as I thought. The camera is fine. The resolution the window is set up is just fine. However, the window is rotated off screen (!!!). If you enable the two rotation settings in the project tab, then start rotating (simulator or device), you will see it flash in quickly.

I know where this is happening. I should have a fix shortly
#6
10/17/2011 (11:34 am)
Located the core problem, which is a set of hard-coded numbers being used for rotation. I'm putting together a simple calculation that will work for both landscape and portrait.
#7
10/17/2011 (2:15 pm)
not sure if it's the same but I found a similar issue in my own retina implementation; solved here

Torque Minimal Template -- Part 4. Retina Display
#8
10/17/2011 (3:24 pm)
Quick fix:

1. Open engine/source/platformiphone/iPhoneWindow.mm

2. Jump to the setScreenOrientation function

3. Replace this:

if( platState.portrait ) 
	{
		point.x = platState.windowSize.x / 2; 
		point.y = platState.windowSize.y / 2;
	} 
	else
	{
		point.x = platState.windowSize.y / 2;
		point.y = platState.windowSize.x / 2; 
	}

4. With this:

if( platState.portrait ) 
{
        if([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
        {
            point.x = 320;
            point.y = 0;
        }
        else
        {
            point.x = platState.windowSize.x / 2; 
            point.y = platState.windowSize.y / 2;
        }
} 
else
{
	point.x = platState.windowSize.y / 2;
	point.y = platState.windowSize.x / 2; 
}

Recompile and run. Everything should be in the right place. Thanks Pedro! Now I need to fix the dynamic rotation bug I discovered. Both fixes will be added to a new installer (hopefully uploaded tomorrow).
#9
10/17/2011 (7:21 pm)
you're welcome. glad I can help somehow.
#10
10/18/2011 (3:10 am)
@Michael - thanks for getting to the bottom of this quickly. You mentioned a new installer coming very soon with this issue fixed, will the mounting bug also be resolved in that too, as that seems to be a pretty glaring issue that would affect anyone trying to mount objects in the iT2d GUI.

See www.garagegames.com/community/forums/viewthread/128030
#11
10/20/2011 (6:37 am)
@Michael - i may have found another issue with universal app support with multiple scenewindows (eg a gui style overlay) where the second scene window isnt resizing onto iphone4 correctly. Ill look into it closer tomorrow, just thought id mention it incase you want to delay your patch a few days (incase its something that needs fixing).
#12
10/20/2011 (8:08 pm)
I'm running into a similar problem on iPad2, only in landscape mode. In LandscapeRight everything displays fine, but touch input is limited to a small area (slightly less than 1/4) in the lower left of the screen. When the screen rotates to LandscapeLeft the lower left of the game renders in the upper right corner of the screen. The same area where input worked in LandscapeRight mode.

@Michael - Is this that dynamic rotation bug you mentioned that you were looking into? Or is this something else?

I was hoping to release a Universal update next week, but this bug is blocking me. Has anyone else run into this and figured out a workaround?
#13
10/21/2011 (4:47 am)
@Michael - i have been playing around more with having multiple t2dSceneWindows. The first window (sceneWindow2d) displays fine but the second one's size is wrong. Its quite possible im doing something wrong with how i setup multiple scene windows, so if thats the case please point me in the right direction. I also tried updating the second scene windows extent and minextend fields to match the first after the Canvas.setContent(mainScreenGui) is called. This seems to fix the problem when running the app as iPhone or iPad on windows. However when i run on my actual iPhone4, the second windows sizing is completely wrong. Unfortunately my iOS Simulator has stopped working properly, not sure why yet but i am unable to test anything in the simulator at the moment, so i havent been able to try iPhone or iPad, only iPhone4 on my actual device.

Here is the mainscreen.gui, gameMenuWindow is the second t2dSceneWindow i refered to. I want it to be exactly the same as sceneWindow2d in size and position for overlaying a HUD for example.
-----------------------------------------------
%guiContent = new GuiControl(mainScreenGui) {
canSaveDynamicFields = "0";
PlatformTarget = "UNIVERSAL";
isContainer = "1";
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
Position = "0 0";
Extent = "1024 768";
MinExtent = "480 320";
canSave = "1";
Visible = "1";
hovertime = "1000";

new t2dSceneWindow(sceneWindow2D) {
canSaveDynamicFields = "0";
PlatformTarget = "UNIVERSAL";
isContainer = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
Position = "0 0";
Extent = "1024 768";
MinExtent = "480 320";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiDefaultProfile";
hovertime = "1000";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "1";
};

new t2dSceneWindow(gameMenuWindow) {
canSaveDynamicFields = "0";
PlatformTarget = "UNIVERSAL";
isContainer = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "width";
VertSizing = "height";
Position = "0 0";
Extent = "1024 768";
MinExtent = "480 320";
canSave = "1";
Visible = "1";
tooltipprofile = "GuiDefaultProfile";
hovertime = "1000";
lockMouse = "0";
useWindowMouseEvents = "1";
useObjectMouseEvents = "1";
};
};

Another strange thing i noticed was that inverting the extents when in portrait mode for the second gameMenuWindow only seems to make it appear closer to being correct. eg changing extent = "480 320" to extent = "320 480" (not done in the example above).

I have created a simple sample app to demonstrate the issue.
www.mediafire.com/?od0lx1e8bageg22
In this example i have set it up as portrait, in the designer everythign is designed at 480x320 res. The emptylevel level file which gets loaded into sceneWindow2d is a background from the feature demo. The gameMenu level file which gets loaded into the gameMenuWindow is another image from the feature demo which should effectively appear like a rectangle around the entire screen (just inside the extents). You will see what it is supposed to look like if you run it in windows. If you then sync the app to an iPhone4 and run it, the rectangular frame effectively appears to have doubled in size, so only the top left quarter is visible.

Any help with this would be much appreciated, hopefully its just something obvious that im missing, otherwise its something else to be fixed.

Thanks,
Craig
#14
10/21/2011 (7:32 am)
@Craig - The problem, which is a lack of forethought on my end, is that the universal app system dynamically changes the extents of sceneWindow2D and t2dSceneGraph. This happens in script and only looks for sceneWindow2D (a t2dSceneWindow). What needs to happen is for the system to propagate what the code does to sceneWindow2D across all interfaces. I'll be adding that into the patch.
#15
10/21/2011 (7:33 am)
@Adam - I think the problem you are having is with the interface file (xib) itself. Make sure it is upgraded to the latest version with all scaling and display set to universal.
#16
10/21/2011 (12:43 pm)
Alright, we are going to start on a 1.5.1 patch. I will most likely upload a zip file labeled "1.5.1 preview", which will contain the fixed code. It will not be an installer and it will not be QA tested. It's a chance to verify the fixes work for you all.

Shortly after that, we will put it through a small QA cycle to verify the fixes and make sure I didn't break anything else.
#17
10/21/2011 (6:19 pm)
@Michael - Thanks, i had a feeling the problem might have been something like that. I look forward to testing out the patch. How will we get the patch, will you post a link in the forums or will it appear in our account downloads section?
#18
10/26/2011 (2:54 am)
@Michael - Re the other scenewindows not being resized by universal app support, is there a work around i can use to fix this in script or code until the patch is available? I tried setting the extents manually in the StartGame function after the Canvas.setContent(mainScreenGui), but i guess its being overridden later than that. Can you suggest a place to try override it so i can continue testing my app on my iPhone4.
#19
10/28/2011 (6:23 am)
@Craig - Can you post the code you are using to set the extents?
#20
10/29/2011 (6:59 pm)
@Michael - I found that you have to override the extents after loadlevel is called (and everytime its subsequently called, even when its called on a different t2dscenewindow).
Page «Previous 1 2