HipByte / motion-game

Cross-platform game engine for RubyMotion
BSD 2-Clause "Simplified" License
63 stars 18 forks source link

How to set orientation #6

Closed amirrajan closed 8 years ago

amirrajan commented 8 years ago

Random code snippet that took me a minute to figure out:

In config/ios.rb

Motion::Project::App.setup do |app|
  # Use `rake ios:config' to see complete project settings.
  app.info_plist['UISupportedInterfaceOrientations']  = ['UIInterfaceOrientationPortrait']
end

In previous apps I've done

  app.interface_orientations = [:portrait]

which didn't work for this project.

jjaffeux commented 8 years ago

I think this is related to this line : https://github.com/HipByte/motion-game/blob/master/lib/motion-game/ios.rb#L13

I have slow internet atm I will check next week

amirrajan commented 8 years ago

I looked at the source and saw that too (which is how I figured out that's what you needed to use).

lrz commented 8 years ago

Maybe it didn't work because of the previously-set orientation in the default config file? (I assumed that by default MG projects should be in landscape, maybe I'm wrong here and we could remove this).

amirrajan commented 8 years ago

No, I think most people will want landscape to be the default.

bmichotte commented 8 years ago

btw, but, it's more a RubyMotion concern, I think, something like

app.supported_orientations = [:landscape, :portrait]

Could be awesome to replace app.info_plist['UISupportedInterfaceOrientations'] on iOS and

app.manifest.child('application').child('activity') do |main_activity|
    main_activity['android:screenOrientation'] = 'portrait'
  end

on Android

hugoerg56 commented 8 years ago

in ios I just set:

Motion::Project::App.setup do |app|
  app.name = 'testapp'
  app.interface_orientations = [:portrait] 
  app.info_plist['UISupportedInterfaceOrientations'] = ['UIInterfaceOrientationPortrait']
end

That way works for my.