Results 1 to 4 of 4

Thread: Handling orientation change (android)

  1. #1

    Default Handling orientation change (android)

    I'm trying to implement orientation changing while in an app and it's not going so well. For a while it was actually easier than I expected, the 3d stuff isn't hard to do (makes sense, only the camera needs to be changed) but the 2d GUI stuff is a different matter.
    Probably the biggest thing is the screensize doesn't change even though OnScreenSizeChange() is triggered and that's what I use to handle everything. If you start up in portrait, the screen size will be eg 480*772 (28 missing pixels are for the android status bar), then when you change to landscape, it will still be 480*772 instead of 800*452. If you start up in landscape, resolution is 800*452 and stays that way even in portrait mode. All this time OnScreenSizeChange triggers as expected runs the code I put in to patch things. I've been trying to work with this, recreating 2d elements with the new parameters, and have been able to get acceptable results in the way graphics are scaled, but I just noticed touch coordinates are completely wrong so I finally decided to post here... I'd like for this to be a bit more straight forward

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    Hi, sorry for the slow reply. My own games haven't required handling orientation change during gameplay (locked in landscape) so I'm not surprised there are problems with that. Sorry about that.

    It's tricky working with those screen things, and really requires a lot of LogMsg()'s to figure out what's happening. I suspect I'm not even sending orientation change info from the Java side to the C++ side, that's the first thing to check.

    Anyway, if you do get it working, please send a patch...
    Seth A. Robinson
    Robinson Technologies

  3. #3

    Default

    If you're not doing orientation change, Android does and it triggers the screen resize stuff that you have set up. AppResize in AndroidUtils.cpp would handle the screensize change, but you've set it behind an if (!GetBaseApp()->IsInitted()) check so it only runs once when starting up. I took the line SetupScreenInfo out of that check, and changed it to use the new w and h values instead of GetScreenSize() calls. It also takes an orientation variable but I don't think it is used and/or necessary. (ofcourse you do need to know what the orientation is to make changes to your interface but knowing the resolution is enough)
    Anyway after doing this it just works. Maybe this does surprise you

    I don't know how to submit a patch, and there's a ton of other changes/additions I made that you don't want. It's just one line to change though.


    edit: just found an issue, changing orientation while the screen is off does not send the change to the app. Can probably fix that in OnEnterForeground.

    edit: one more thing. EntitySetScaleBySize behaves rather oddly if you do it more than once. Not a big deal (I can just recreate the entity) but you might want to know.
    Last edited by karelc; 11-16-2011 at 01:39 PM.

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,343

    Default

    (just noticed this, so replying a bit late..)

    Thanks! I'll make the change you suggested the next time I'm doing some android builds!
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. Change for CL_GUIManager
    By logixoul in forum Official ClanLib SDK Forums
    Replies: 3
    Last Post: 05-26-2010, 06:58 PM
  2. Handling zip archives as resources
    By Sherack Nhar in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 11-11-2006, 12:49 AM
  3. How do I change controls?
    By in forum Dink Smallwood HD
    Replies: 8
    Last Post: 08-13-2006, 11:24 PM
  4. Question about what is a change
    By in forum Other RTsoft Games
    Replies: 1
    Last Post: 10-15-2002, 11:24 PM
  5. no screen change for mowing
    By in forum Other RTsoft Games
    Replies: 0
    Last Post: 09-10-2002, 07:01 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •