Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Adding this code will use iOS auto Orientation (UPDATE) - Gideros Forum

Adding this code will use iOS auto Orientation (UPDATE)

MillerszoneMillerszone Member
edited October 2011 in General questions
What this code will do is automatically rotate screen via iOS built in Orientation.
This is better than using Stage:setOrientation(orientation) because Stage:setOrientation(orientation) doesn't
rotate the Multi-taskbar, native popups, dialogs like the game center popup.

This is why I like to build my project on a local computer rather than a server like Corona. You have a lot more control.

O.K, add the code below to your AppNameViewController.mm. You will find the AppNameViewController.mm after
you export you project, it's in the Classes folder.
NOTE: AppNameViewController.mm will have a different name at the beginning. Just look for *******ViewController.mm

I added the code to the very bottom of the AppNameViewController.mm file, before the @end
I only tested on the iPad. It supports all orientations, you can set it to support whatever orientation you want.
After adding code to file, then save and build your project with Xcode.

This is for Landscape, change settings to use portrait mode.
NOTE: set these files to read only or you will have to keep replacing when rebuilding.

Add this code to Info.plist.
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
--
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// return YES; to support all orientations. return NO; for no orientation.
 
// this is for portrait mode only
// return UIInterfaceOrientationIsPortrait(interfaceOrientation);
 
// this is for landscape mode onlyreturn UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

Comments

  • atilimatilim Maintainer
    Setting the project files readonly is good idea :)

    With the next version, the export option will have "export only asset files". So that you can safely export the project again and keep your modified project files untouched.
  • @atilim
    Can you include this code into the template so that you do not need to replace each time you rebuild?
  • atilimatilim Maintainer
    Agree. You can set the project files read only (as suggested by @Millerszone) while waiting for the next version :)
  • gorkemgorkem Maintainer
    You mean next version will have an "export assets only" tick in export dialog right? :) Great!
  • MillerszoneMillerszone Member
    edited October 2011
    I'm having a problem with landscape orientation on the iPad using this code
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // this is for portrait mode only
    // return UIInterfaceOrientationIsPortrait(interfaceOrientation);
     
    // this is for landscape mode onlyreturn UIInterfaceOrientationIsLandscape(interfaceOrientation);
    }
    When I start my app on the iPad the Default-Landscape.png displays correctly, then this code will run:
    local splashscreen = Bitmap.new(Texture.new("Images/splashscreen.png"))
    and the image below displays incorrectly:
    image
    This image is a landscape image.

    It has something to do with (BOOL)shouldAutorotateToInterfaceOrientation running in
    Landscape mode. Now if I run (BOOL)shouldAutorotateToInterfaceOrientation in
    Portrait, the splash displays o.k, but then when I rotate the iPad to Portrait position
    it display horizontally.

    I know this has nothing to do with Gideros code, because everything is fine if I don't
    use (BOOL)shouldAutorotateToInterfaceOrientation function, but I thought someone might know what could be wrong.

    Thank you.
  • atilimatilim Maintainer
    edited October 2011
    I'm glad you catch this issue. :)

    When there's no autorotation (Portrait mode) the resolution of iPad is 768x1024. When you enable autorotation and the application moves to Landscape mode, the resolution changes to 1024x768 but Gideros still thinks the resolution is 768x1024.

    This issue will be fixed with the next version.

    Please disable autorotation temporarily and work with Landscape mode until we release the next version.

    Thank you again :)
  • I'm glad the problem has something to do with Gideros. I thought I was doing
    something wrong. I spent all day trying to fix the problem.

    I was going to change gdr_initialize((EAGLView *)self.view, 768, 1024, false); to
    1024, 768 in the ViewController.mm. and go from there, but I'll wait for the fix.

    Thank you very much for replying. I was going crazy trying to fix. :-??
  • atilimatilim Maintainer
    edited October 2011
    Changing ViewController.mm (to 1024, 768) is also very good idea. :) (I hope you can continue coding your game without problem while waiting for the next version)
  • MillerszoneMillerszone Member
    edited October 2011
    I'm probably going convert my game "Hit the Deck Baseball" for Android using
    Gideros. It uses a lot of animation, so MovieClip will help a lot. I'm also using my
    own Highscore code which uses net commands and php code on the server. It looks Gideros
    Has all the functions I need to make it work with Android. Ill be using Game Center for iOS apps.
    I'm also using a custom keyboard, hopefully Gideros will use the native keyboard in a future release.

    All my testing so far has been with iOS. I'll start testing Android next. I know a lot of
    people are disappointment with Corona Android performance and compatibility problems, but I guess with all the different Android devices, it's going to happen.




  • atilimatilim Maintainer
    That sounds great! :) (Virtual keyboard support is on our roadmap and it has high priority)

    One of our Android test device is a low-end device and we do performance tests on it. Usually the resulting performance is better than iPhone 3G. In the future, most probably, we meet performance problems on different Android devices but up to now we're happy and hopeful.

    Thank you.
Sign In or Register to comment.