JadedTuna
Aug 22, 2014 - 10:57
How can I find out device orientation? Should I use scene.gravity() to get gravity and then try to transform it into orientation?
How can I find out device orientation? Should I use scene.gravity() to get gravity and then try to transform it into orientation?
Run this and then tap the X to close the scene... The results will be printed on the console.
import scene
class MyScene(scene.Scene):
def __init__(self):
scene.run(self)
def setup(self):
# This will be called before the first frame is drawn.
print(self.bounds, self.isLandscape(), self.scale(), scene.get_screen_scale())
def scale(self):
_, _, x, y = self.bounds
landscape = self.isLandscape()
x /= 1024 if landscape else 768
y /= 768 if landscape else 1024
return scene.Point(x, y)
def isLandscape(self):
return self.bounds.w > self.bounds.h
MyScene()