Game Development Community

iOS 8 messed up the display

by Andrew Deters · in Torque 2D Beginner · 10/09/2014 (11:28 pm) · 9 replies

Its hard to describe the issue so I took screen shots.
http://imgur.com/a/0WaUQ

#1
10/10/2014 (6:17 am)
Looks like portrait/landscape flag is reversed for iOS 8. Apple - always have to screw something up....
#2
10/10/2014 (4:19 pm)
I don't know where to begin to fix it. If it's an engine thing I don't want to mess anything up.
#3
10/10/2014 (10:51 pm)
"Mess anything up?" Make a branch, fiddle to your heart's content, if it breaks, delete the branch and make a new one. Don't be afraid to experiment - experimentation is a great way to learn.
#4
10/11/2014 (12:20 pm)
I wouldn't know where to beginning. I was hoping someone who knows the new Torque better could help me.
#5
10/11/2014 (1:13 pm)
Likely will need to make changes in engine/source/platformiOS/iOSWindow.mm

Seems to be a common problem from searching. It appears Apple has changed how screen orientation works. There is no longer actual view 'rotation' going on. Instead, apps have to change bounds to fit in the new orientation (if I understand correctly).

Here's the issue and fix in openFrameworks, although it looks like they may be having trouble with it still: github.com/openframeworks/openFrameworks/issues/3158

From that issue there's also the related transcript from WWDC 2014 about this: asciiwwdc.com/2014/sessions/214

I don't have any apple devices or a mac, so someone who has a few different devices with different iOS versions would really help.
#6
10/11/2014 (2:58 pm)
I have 3 iOS devices, and have only updated one to iOS 8. I have only started checking out Torque 2D this last week, but I will see if I can get it working.
#7
10/11/2014 (3:52 pm)
[SOLVED] It was not that hard to fix, but the code of the above example is not quite the same for Torque. Here is the answer for the Torque 2D engine if anyone else needs to know.

In iOSWindow.mm find

bool setScreenOrientation(bool portrait, bool upsidedown)
{
    bool success = false;

    CGPoint point;
    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;
    }


    [platState.ctx centerOnPoint:point];

    if (portrait)
    {//normal upright
        if (upsidedown)
        {//button on top
            [platState.ctx rotateToAngle:M_PI + (M_PI / 2.0)];//rotate to 90 degrees
            platState.application.statusBarOrientation = UIInterfaceOrientationPortraitUpsideDown;
            success = true;
        } else
        {//button on bottom
            [platState.ctx rotateToAngle:(M_PI / 2.0)];//rotate to 270 degrees
            platState.application.statusBarOrientation = UIInterfaceOrientationPortrait;
            success = true;
        }
    } else
    {//landscape/ sideways
        if (upsidedown)
        {//button on left
            [platState.ctx rotateToAngle:0];//rotate to -180 (0) degrees
            platState.application.statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
            success = true;
        } else
        {//button on right
            [platState.ctx rotateToAngle:(M_PI)];//rotate to 180 degrees
            platState.application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
            success = true;
        }
    }
    return success;
}

And change it to

bool setScreenOrientation(bool portrait, bool upsidedown)
{
    bool success = false;

    CGPoint point;
    
    // Is the iOS version less than 8?
    if( [[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending )
    {
    
        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;
        }


        [platState.ctx centerOnPoint:point];

        if (portrait)
        {//normal upright
            if (upsidedown)
            {//button on top
                [platState.ctx rotateToAngle:M_PI + (M_PI / 2.0)];//rotate to 90 degrees
                platState.application.statusBarOrientation = UIInterfaceOrientationPortraitUpsideDown;
                success = true;
            } else
            {//button on bottom
                [platState.ctx rotateToAngle:(M_PI / 2.0)];//rotate to 270 degrees
                platState.application.statusBarOrientation = UIInterfaceOrientationPortrait;
                success = true;
            }
        } else
        {//landscape/ sideways
            if (upsidedown)
            {//button on left
                [platState.ctx rotateToAngle:0];//rotate to -180 (0) degrees
                platState.application.statusBarOrientation = UIInterfaceOrientationLandscapeLeft;
                success = true;
            } else
            {//button on right
                [platState.ctx rotateToAngle:(M_PI)];//rotate to 180 degrees
                platState.application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
                success = true;
            }
        }
    }
    //Set the screen for iOS 8 and latter
    else
    {
        point.x = platState.windowSize.x / 2;
        point.y = platState.windowSize.y / 2;
    }

    return success;
}

Also I did not see any issues with the rotation animation. I will update if any other related issues show up.
#8
10/11/2014 (4:09 pm)
Good find and fix guys. Thanks Andrew. Feel free to submit this as a pull request against the development branch and we'll get it merged in.
#9
10/11/2014 (5:57 pm)
Pull request made I think.