Accelerometer on Android

Previous topic - Next topic

ampos

The accelerometer does not rotate on Android.

On a 480x800 screen (vertical), with the device in vertical position, X=-1, Y=0 and on iPhone X=0, Y=-1

Not tested (yet) on 800x480 (horizontal)

Kitty Hello

every manufacturer build them in differently. Jejoice!

Crivens

Yeah my cheapo Chinese import tends to show apps upside down for example. I guess the best bet is to allow some sort of setup by the user to orientate their device by actually telling you which way it is up.

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

ampos

Amazing. So there is no way to know the correct orientation of the device?

I have been just 3 days with my Android tablet, and just tested Angry Birds, but it is in the correct orientation...

Crivens

Yeah but they probably coded it to the most common orientation. I bet if I ran it on mine it would be the other way around. Or not. It depends on the app to be honest. Hard to tell really without 2 devices in your hand (yours might be horizontal left and mine might be horizontal right). Perhaps the ones that work better have a better method of working it all out as not all apps on mine appear upside down. It actually is better to use my tablet upside down with only minimum hassle (hardware buttons are mainly software buttons on mine minimising to an iPad type hardware layout). And I've seen a fair few comments to this on Amazon.

Perhaps when it starts better programmed apps looks to see the current orientation and assumes you are holding this as you would expect it to run (ie. you are not an idiot or some kind of circus trapeze artist) and then designates that current orientation as "up" and then goes from there if you ever turn the device. Maybe...

Cheers
Current fave quote: Cause you like musicians and I like people with boobs.

spacefractal

if tilt only need to check for rotation and not for the gameplay, GETJOYY() and GETJOYX() might been swapped due rotation. I did not like that glbasic did for extractly that issue. so I did something like this to workaround (which need to been tweeked, but you have the idea (used in a function of course):

Code (glbasic) Select

COUNTER=COUNTER+1
IF COUNTER>100 THEN COUNTER=85

IF (COUNTER=17 OR direct=1)
IF ORIN>-1 AND GETORIENTATION()<>ORIN
SETORIENTATION ORIN
GOTO rescheck
ENDIF
ENDIF
IF MOD(COUNTER, 15)<>5 THEN RETURN

IF GETORIENTATION()=0
y=GETJOYY(0)*100
x=GETJOYX(0)*100
ELSEIF GETORIENTATION()=1
y=-GETJOYX(0)*100
x=GETJOYY(0)*100
ELSEIF GETORIENTATION()=2
y=-GETJOYY(0)*100
x=-GETJOYX(0)*100
ELSE
y=GETJOYX(0)*100
x=-GETJOYY(0)*100
ENDIF

IF (y>60 OR KEY(17)=1) AND ORIN<>2
ORIN=2; COUNTER=0;
ELSEIF (y<-60 OR KEY(31)=1) AND ORIN<>0
ORIN=0; COUNTER=0;
ELSEIF (x>60 OR KEY(32)=1) AND ORIN<>3
ORIN=3; COUNTER=0;
ELSEIF (x<-60 OR KEY(30)=1) AND ORIN<>1
ORIN=1; COUNTER=0;
ENDIF
RETURN

rescheck:
LOCAL oldScreenWidth=ScreenWidth
LOCAL oldScreenHeight=ScreenHeight
GETSCREENSIZE ScreenWidth, ScreenHeight

LOCAL OLDPORTRAIT=PORTRAIT
IF ScreenWidth>ScreenHeight
PORTRAIT=0
ELSE
PORTRAIT=1
ENDIF
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/