[RESOLVED] Orientation changes not working on Mac Sim and device?

I’ve noticed that a version of the code below works in the Windows sim but not in the Mac sim or device with GFX 2.0. The code is stripped down to the basics, but should remove/re-load the image so it’s always facing up. 

[lua]

function onOrientationChange( event )

    local currentOrientation = event.type

    if object then

       display.remove(object)

       object = display.newImage(“object.png”,display.contentCenterX,display.contentCenterY)

    end

end

Runtime:addEventListener( “orientation”,onOrientationChange )

[/lua]

Build settings looks like this…

[lua]

      orientation =

      {

            default = “landscapeRight”,

            content = “landscapeRight”,

            supported =

            {

                “landscapeRight”, “landscapeLeft”,“portrait”, “portraitUpsideDown”, 

            },

[/lua]

Am I missing something or is this a bug?

@no2games  I tested the orientation logic on the Mac simulator and everything seems to be working correctly in build 2013.2007. I added a simple print statement in the orientation function and also tested the orientation sample app and verified the functionality.

Thanks for looking into this, and I tried 2007 and I’m seeing the same issue… I tried to troubleshoot it a bit more, and think something’s gone wrong in the onOrientationChange event itself. Basically this code:

[lua]

local object = display.newRect(0,0,display.contentWidth,display.contentHeight)

function onOrientationChange( event )

    local currentOrientation = event.type

    if object then

       display.remove(object)

       object = display.newRect(0,0,display.contentWidth,display.contentHeight)

    end

end

Runtime:addEventListener( “orientation”,onOrientationChange )

[/lua]

Should make a box that gets removed and re-created in the upper left hand corner on an onOrientationChange. On the win sim it does, and looks like this after two right turns:

On the mac sim, it doesn’t remove/recreate the object and looks like this after two right turns:

Apple’s iOS simulator handles this test case fine, but the more complicated you get creating objects in the onOrientationChange event, the more likely you are to get visual issues/differences between the two sims. The non gfx 2.0 build  2013.1230 handles this test case fine as well (but the rect covers the whole screen, which is what would be expected.)  

Below is a link to the entire project:

https://dl.dropboxusercontent.com/u/15851867/orientation-test.zip

We looked into this and the issue is not with Graphics 2.0. In fact it’s been around since build 971 (maybe before). What is happening is your build.settings file has a ‘content = “landscapeRight”’ field. This fixes the content (stage) of the screen in landscapeRight orientation. That is what you see on the Mac simulator when you rotate the skin and content follows the skin. This was added a long time ago for iOS devices (locked orientation). It turns out this code is Mac/iOS specific code and is not in the Windows simulator. It also looks like it no longer works on iOS devices either. I can see that it does add a special flag to the iOS plist bundle, but doesn’t do anything on the device (or Xcode simulator).

The bottom line is we need to remove this “feature” from the Mac simulator since it’s really not doing anything.

Thanks for posting the bug and supplying the test project.

Thanks for looking into this. I must of had some legacy code in there with the content = "landscapeRight in the build settings.

@no2games  I tested the orientation logic on the Mac simulator and everything seems to be working correctly in build 2013.2007. I added a simple print statement in the orientation function and also tested the orientation sample app and verified the functionality.

Thanks for looking into this, and I tried 2007 and I’m seeing the same issue… I tried to troubleshoot it a bit more, and think something’s gone wrong in the onOrientationChange event itself. Basically this code:

[lua]

local object = display.newRect(0,0,display.contentWidth,display.contentHeight)

function onOrientationChange( event )

    local currentOrientation = event.type

    if object then

       display.remove(object)

       object = display.newRect(0,0,display.contentWidth,display.contentHeight)

    end

end

Runtime:addEventListener( “orientation”,onOrientationChange )

[/lua]

Should make a box that gets removed and re-created in the upper left hand corner on an onOrientationChange. On the win sim it does, and looks like this after two right turns:

On the mac sim, it doesn’t remove/recreate the object and looks like this after two right turns:

Apple’s iOS simulator handles this test case fine, but the more complicated you get creating objects in the onOrientationChange event, the more likely you are to get visual issues/differences between the two sims. The non gfx 2.0 build  2013.1230 handles this test case fine as well (but the rect covers the whole screen, which is what would be expected.)  

Below is a link to the entire project:

https://dl.dropboxusercontent.com/u/15851867/orientation-test.zip

We looked into this and the issue is not with Graphics 2.0. In fact it’s been around since build 971 (maybe before). What is happening is your build.settings file has a ‘content = “landscapeRight”’ field. This fixes the content (stage) of the screen in landscapeRight orientation. That is what you see on the Mac simulator when you rotate the skin and content follows the skin. This was added a long time ago for iOS devices (locked orientation). It turns out this code is Mac/iOS specific code and is not in the Windows simulator. It also looks like it no longer works on iOS devices either. I can see that it does add a special flag to the iOS plist bundle, but doesn’t do anything on the device (or Xcode simulator).

The bottom line is we need to remove this “feature” from the Mac simulator since it’s really not doing anything.

Thanks for posting the bug and supplying the test project.

Thanks for looking into this. I must of had some legacy code in there with the content = "landscapeRight in the build settings.