I am trying to rotate the application screen based on the device orientation.
I used the SETORIENTATION example from the GLB Help file and I added the GETORIENTATION.
I complied and run the code on my iPhone but the orientation does not change when I turn the device UP, LEFT, RIGHT or DOWN.
Does GETORIENTATION reads the actual iPhone/iPad hardware orientation sensor?
Should I saw some examples in the FORUM that use C++ code, but I am not sure If I need to use it!
Here is the code:
I used the SETORIENTATION example from the GLB Help file and I added the GETORIENTATION.
I complied and run the code on my iPhone but the orientation does not change when I turn the device UP, LEFT, RIGHT or DOWN.
Does GETORIENTATION reads the actual iPhone/iPad hardware orientation sensor?
Should I saw some examples in the FORUM that use C++ code, but I am not sure If I need to use it!
Here is the code:
Code (glbasic) Select
// --------------------------------- //
// Project: Orientation
// Start: Tuesday, February 28, 2012
// IDE Version: 10.237
// SETCURRENTDIR("Media") // go to media files
// Test mode: 320x480
X_OBJSTART 0
X_OBJADDVERTEX 0, 20, 0, 0,0,0xffffff
X_OBJADDVERTEX 0,-20, 10, 0,0,0xff0000
X_OBJADDVERTEX 0,-20,-10, 0,0,0x0000ff
X_OBJNEWGROUP
X_OBJADDVERTEX 0, 20,0, 0,0,0xffffff
X_OBJADDVERTEX 30,-10,0, 0,0,0xff0000
X_OBJADDVERTEX -30,-10,0, 0,0,0x0000ff
X_OBJNEWGROUP
X_OBJADDVERTEX 10.5,-15, 10.5, 0,0,0x00ffff
X_OBJADDVERTEX 10.5, 15, 10.5, 0,0,0x00ffff
X_OBJADDVERTEX -10.5,-15, -10.5, 0,0,0x00ffff
X_OBJADDVERTEX -10.5, 15, -10.5, 0,0,0x00ffff
X_OBJEND
LOADFONT "Media/fonts/APDfont_Blue.bmp",0
SETFONT 0
LOCAL mx%, my%, b1%, b2%
LOCAL irot% = 0
LOCAL accelx%,accely%,accelz%
LOCAL rot%
LOCAL info$ = PLATFORMINFO$("")
WHILE TRUE
accelx = GETJOYX(0)*100
accely = GETJOYY(0)*100
accelz = GETJOYZ(0)*100
rot = GETORIENTATION()
PRINT "X:"+accelx+" Y:"+accely+" Z:"+accelz, 0, 300
SELECT rot
CASE 0
PRINT "TOP ROT:"+rot, 0, 340
irot=0
CASE 1
PRINT "RIGHT ROT:"+rot, 0, 340
irot=1
CASE 2
PRINT "BOTTOM ROT:"+rot, 0, 340
irot=2
CASE 3
PRINT "LEFT ROT:"+rot, 0, 340
irot=3
ENDSELECT
IF info$="WIN32"
IF KEY(2) THEN irot=0
IF KEY(3) THEN irot=1
IF KEY(4) THEN irot=2
IF KEY(5) THEN irot=3
ENDIF
// rotate the screen. Stays locked until you change that!
SETORIENTATION irot
// mouse position on screen (in screen pixels - not device)
MOUSESTATE mx, my, b1, b2
// print where mouse is and rotation index
PRINT "Rot: "+irot+" Mouse: "+FORMAT$(4,0,mx)+ ", "+FORMAT$(4,0,my), 0,0