How to force orientation between portrait and landscape?

Hey
I have an app where I need to force the orientation in the app between different menus in the app. So when the user press the xButton I want to force the app to landscape orientation and when the user exits that screen I want to force it back to portrait.

I might be really stupid but I can't find any solution to this in the forums nor the API.

The Fishies sample code has an example of handled different orientations based on rotation, but could be adapted.

That said depending on how many scenes your app has and complexity it may be easier to simply make the screen APPEAR to be in portrait mode by displaying elements sideways.

Peach :)

Hey Peach
I don't see in that code how the source code itself changes the orientation but I can see how you change objects when the user changes the orientation. In this case I want to switch orientation for the user in code.

I am dumb or just don't understand?

You aren't dumb, you just don't understand - which is fine :)

The fishies example listens for an orientation change and handles it - but you could tie the same rotation/position adjustments of all display objects to a button.

There are more basic ways of looking at this, like this;

1
2
3
4
5
6
7
8
9
10
11
12
display.setStatusBar( display.HiddenStatusBar )
 
localGroup = display.newGroup()
 
local myText = display.newText("This is my Text", 100, 10, native.systemFont, 16)
localGroup:insert( myText )
 
local function goLandscape()
        myText.rotation = -90
        myText.x, myText.y = 10, 200
end
--goLandscape() --Uncomment to see difference
views:2024 update:2012/2/12 11:34:30
corona forums © 2003-2011