Notifications tab on the side of the screen for a portrait mode game

Discussion in 'Public Game Developers Forum' started by makaGeorge, Jun 8, 2012.

  1. makaGeorge

    makaGeorge Well-Known Member

    Apr 27, 2012
    57
    0
    0
    Hi,

    I've just noticed something weird that I might use to my advantage in the game I'm currently working on...

    I use return (interfaceOrientation == UIInterfaceOrientationPortrait); in the shouldAutorotateToInterfaceOrientation: method from my main viewcontroller to force the screen to lock to portrait mode.

    When I start my game with the iPad already in portrait mode, the notifications tab appears on the top of the screen, where it can get in the way of the player playing the game in that side of the screen, but when I start the game in landscape mode, it stays on the long side of the screen, where it can't bother anyone.

    I thought when I'd lock the screen to portrait mode it would affect the whole system, but it seems to affect only my application. It'd be nice if I could first make sure the screen is set to landscape mode for the whole system and then lock it to portrait mode for my app, this way the notifications tab would always stay on one side of the screen...

    Any help would be appreciated...
     
  2. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    you should really let the OS know the orientation. There is an undocumented (as far as I can tell) trick that Apple use to get greater accuracy. Apple tweak the touch coordinate to be several pixels up from where it's actually touched.

    If you don't tell the OS you will find the touch accuracy is out in some direction or other depending on the real life orientation.

    It's easy to prove it does this. Take a drawing app (sketchbook pro for example) and put it flat on a table. Draw a horizontal line and see what part of your finger the line comes from. Now spin the device 180 degrees (which of course turns it upsidedown without changing gravity, it's on a flat surface), now try drawing a line and it comes from a point clearly lower on your finger.

    All iOS apps use this offset, everyone is used to it, you can't fight it, your touch accuracy will feel wrong if you don't tell the OS the orientation.
     
  3. makaGeorge

    makaGeorge Well-Known Member

    Apr 27, 2012
    57
    0
    0
    thanks. I didn't think about that, but it's not much of an issue in my case as my game uses large control areas instead of visible controls...

    But, let me see if I understand... Do you mean that the way I'm locking the screen to portrait mode is not the correct way to do it? Should I do something else to inform the system about it?
     
  4. GlennX

    GlennX Well-Known Member

    May 10, 2009
    761
    0
    0
    UK
    It would be much easier to answer this from my computer so I could refer to source code. There is a function called something like SetStatusBarOrientation or similar. My accelerometer code calls this when it detects a reorientation. I think my code is a little retro, there are newer classes in newer Apple code samples that handle this stuff for you more automatically but under the hood they must be calling the same thing.

    The point is, I thought I could get away without telling the system the orientation as my code handled all of it until I noticed this offset thing. You are correct to point out that this might not be an issue if you only have a few big buttons.
     
  5. makaGeorge

    makaGeorge Well-Known Member

    Apr 27, 2012
    57
    0
    0
    Thanks! Just gave it a try and it works...

    I call it just before the game starts to make sure the notifications tab is not in the way for the player playing on the top of the screen. Exiting to the system can modify this again, so I need to set it back when the game returns to the front...
     

Share This Page