Locking Orientation

Does anyone know how I would lock orientation once the gameState is a certain state. First, some background, I have an easy, medium, hard, and tilt state using FINITE STATE MACHINES. I want to lock the orientation (whatever it is) when it is in tilt mode because Im using the accelerometer. Can I call conditionals with supported orientation in the setup. HELP :-?

Hi @veeeralp - you can call supportedOrientation() anywhere - in fact I think it is actually better to call it before setup(). The problem is if you call it within draw() for example, it wont lock in to the new orientation until you try and change the orientation of the iPad. I don’t know of a way to try and make this happen programmatically and it is probably bad practise to do so from a user experience perspective.

I just want to lock in tilt mode so that the screen doesn’t rotate every couple of seconds. In all the other modes, the supported orientation would be any. I made compatible in landscape and portrait

yesssss. I got it to work. just put supportedOrientations() where I make my game parameters for different game modes