Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / SetOrientationAllowed Rotation Question

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 2nd Jul 2012 23:06
Landscape is defined as rotating left from the default position and Landscape2 is defined as rotating right from the default position.

For an iOS device, the default position is portrait with the home button on the bottom.

In the xCode interface, where you set the orientations allowed (Targets->Summary->(iphone/ipod/ipad) Deployment Info-<Supported Device Orientations), Landscape Left is when you rotate the device so that the home button is on the left. To do that, you rotate the bottom of the device to the left (or the top of the device to the right).

It appears that Apple is considering the orientation direction of the bottom, where the home button is.

I'm not sure which way the Android works. But, when Paul and I were working out the weirdness in reporting on my Android, I assumed that the rotation direction was using the direction the top of the device went when being rotated.

Which way does AppGameKit use the term rotated to mean? Is it from the top or the bottom of the device?

I assume this is a question for all hand held devices.

Cheers,
Ancient Lady
AGK Community Tester
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Jul 2012 00:17 Edited at: 3rd Jul 2012 00:21
I think it varies from platform to platform. The Blackberry Playbook even confuses what it means by Portrait and landscape.

Maybe a small snippet of code that users can download and test on their devices would be a good idea? One that simply reports the orientation onscreen.

I can't submit a report because the AppGameKit Player doesn't like my Android Wildfire, but here's the code which should work...





Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 3rd Jul 2012 07:05 Edited at: 3rd Jul 2012 07:06
Quote: "...On Android...I assumed that the rotation direction was using the direction the top of the device..."

That's the way I have always understood it and that is the way my Android phone (s2) behaves
Quote: "I think it varies from platform to platform."

...On Android, it seems to vary from device to device

I ran a simple test of a couple of "related" devices, the Galaxy S2 and the Galaxy Note - both Samsung.

The values are the returns from GetOrientation() with Landscape normal being assumed to be a quarter turn anti-clockwise (or left - using the top of the device).

The S2 behaves as the documentation suggests, the Note is different in both orientation and amount of rotation in every case.

And this is two Android Devices in the same family, made by the same company
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Jul 2012 17:38
Android devices definitely don't have a standard for it. That's a shame.

I think we may be stuck with needing to do an initial calibration on Android devices for the first AppGameKit app that runs. (Naturally, since the OS update on my Android, it can no longer access the sdm card and I had managed to delete the contents of the AppGameKit directory and cannot restore the calibration file that had been there. And, now my app doesn't handle the startup display correctly!)

The iOS ones definitely should. Since they are only created by one company.

According to the shouldAutorotateToInterfaceOrientation function in UntitledViewController.m, it has assigned the Apple LandscapeLeft (home button on the left) to Orientation 3 (Landscape, rotated left) and LandscapeRight to orientation 4.

That makes it look like it is interpreting the rotation as being based on the direction the bottom of the device goes.

Cheers,
Ancient Lady
AGK Community Tester
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Jul 2012 22:34
I just ran a test using Tier 2 to show orientation.

Orientation 3 was reported for iOS orientation Landscape Right.

So, I made the test a bit more extensive. All tests done with iPad initially in default Portrait orientation.

I set the Xcode orientations allowed and used the SetOrientationAllowed command to match what appeared to be the same orientation. The results:


There appears to be a stablization issue for the landscape modes.

Cheers,
Ancient Lady
AGK Community Tester
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Jul 2012 23:08
The ones where it would wait for you to rotate the device before locking to that rotation are because Apple do not allow the app to initiate a rotation, they will reject the app if it does. The user must rotate the device and the app can only prevent rotation rather than initiate it.

This is good enough for the AppGameKit Player, but when compiling your app in XCode I'd advise replacing the shouldAutoRotateToInterfaceOrientation with your desired YES and NO values and set the default interface orientation so it is never in an invalid state that the app can't change.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 3rd Jul 2012 23:45
I had figured out about how to use shouldAuto... (see issue #342).

And, for the tests where I used only one fixed portrait orientation. The app showed exactly that one at start and would not allow flipping.

The landscape version was not consistent. It would show the initial orientation as the simple test indicated. Then it allows a flip to the other orientation (which is not the one 'allowed'), doesn't report the new orientation in GetOrientation and will not flip back. And, when the app is closed and restarted, it will only display in the 'wrong' orientation. And (in my game) when it flips, the accelerometer values report back as those from the 'correct' but not current orientation.

I think the confusion is in the designation of which way is landscape 1 and landscape 2. In the visual 'Supported Device Orientations' in Xcode, Landscape Left and Landscape Right are orientations 3 and 4, respectively, in the display list. However, when running a test that simply displays what the current reported orientation is, when all are allowed in both Xcode and using the SetOrientationAllowed command, AppGameKit Orientation 3 shows up for iOS Landscape Right. And AppGameKit Orientation 4 shows up of for iOS Landscape Left.

It looks like an indexing issue with 3 and 4 confused between what AppGameKit assumes and what iOS assumes.

If Apple initially rejects my game for forcing an orientation other than the one it starts in, I will argue that I have several apps that they approved that do exactly that (GuessCode, Tripeak HD, Mahjong!! and Minesweeper, for a few). And, that because of the nature of the way my game is played, forcing a single orientation is required.

Cheers,
Ancient Lady
AGK Community Tester
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 4th Jul 2012 03:42
Quote: "If Apple initially rejects my game for forcing an orientation other than the one it starts in, I will argue that I have several apps that they approved that do exactly that"


You can use the Initial Interface Orientation setting to make your app start in a particular orientation, and the shouldAutoRotate to keep it there, but you can't change the orientation from code once you are up and running. So once the AppGameKit Player is running and you call SetOrientationAllowed() there is nothing it can do (that I know of) to force an immediate change. I did read about a hack where someone created a temporary view controller and then deleted it forcing iOS to re-read the shouldAutoRotate function and change accordingly, but I couldn't get it to work.

I'll investigate the orientation 3 and 4 mismatch when I get some time.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 4th Jul 2012 17:47
Paul, thank you. If you need any help with the investigation, let me know and I'll do what I can.

Cheers,
Ancient Lady
AGK Community Tester
Rich Dersheimer
AGK Developer
14
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 5th Jul 2012 06:34
Paul, again I'm confused by what you say Apple will not allow.

If my game is played two-player head-to-head, and there is a button on the screen to flip the screen so the other player can make a move, is this what Apple will disallow?

I used to hate the thought of governments having orbital mind control satellites,
but now I can't really seem to care.
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 5th Jul 2012 12:52
Is there an easy way to detect if the app is running on any kind of iOS device, so the app can hide the user initiated flip code on those devices, so we don't have to make 2 apps, 1 for android, and 1 for iOS?

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Jul 2012 13:56
Quote: "Is there an easy way to detect if the app is running on any kind of iOS device, so the app can hide the user initiated flip code on those devices, so we don't have to make 2 apps, 1 for android, and 1 for iOS?"


You could add it to your settings file, so it's just one change of a text file between deployment to different platforms.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Jul 2012 18:13
Impetus73, within your code you can check for the device with this:


plat$ will be:
'ios' for iOS devices
'win' for windows
'mac' for Mac
'and' for Android

Then, you just do whatever logic is specific to the platform.

Cheers,
Ancient Lady
AGK Community Tester
Impetus73
12
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 5th Jul 2012 19:23
Thanks Ancient Lady! Now I can optimize my apps for the platforms.

----------------
AGK programmer
Did Amiga / AMOS programming in the 90's.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Jul 2012 19:26
Always glad to help.

Happy Programming!

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-05-04 12:50:17
Your offset time is: 2024-05-04 12:50:17