Changing screen orientation

Monkey Targets Forums/Android/Changing screen orientation

Leon Brown(Posted 2014) [#1]
Hi. The app I'm creating requires the ability to change the screen orientation within the app when a button is clicked. I've been looking at trying to do this by changing the activity screenOrientation property, but not had much luck. Does anyone have any suggestions?

Another alternative would be to rotate the app natively within Monkey, maybe using the transform command? I'm not sure how to use this though.


ziggy(Posted 2014) [#2]
Rotate (90) as the first sentence of OnRender should do it?

Edit: See this:

Import mojo

Function Main()
	New Game()
End

Class Game Extends App

	'summary:The OnCreate Method is called when mojo has been initialized and the application has been successfully created.
	Method OnCreate()
	
		'Set how many times per second the game should update and render itself
		SetUpdateRate(60)
	
	End
	
	'summary: This method is automatically called when the application's update timer ticks. 
	Method OnUpdate()
		
	End
	
	'summary: This method is automatically called when the application should render itself, such as when the application first starts, or following an OnUpdate call. 
	Method OnRender()
		Translate(DeviceWidth(), 0)
		Rotate(-90)

		Cls()
		SetColor(255, 255, 255)
		DrawText("Hello world!", 50, 50)
	End

	'summary: This method is called instead of OnRender when the application should render itself, but there are still resources such as images or sounds in the process of being loaded. 
	Method OnLoading()
		
	End
	
End



Leon Brown(Posted 2014) [#3]
Thanks. I tried that originally, but the app shows distorted - like the blank TV signal you get on an analogue TV.

Thanks for the example - I'll look at this now.


Leon Brown(Posted 2014) [#4]
Thanks - that works great. I just need to sort out the screen resizing, which should just be a case of adjusting AutoScale. If I'd have known this this morning, it would have saved me hours ;-).