So I’m struggling a bit. In a mini-game I’m using the accelerometer to control the character in a landscape orientation. Obviously depending on whether it’s landscapeLeft or landscapeRight I need to toggle between adding yGravity positively or negatively to move the character in the correct direction.
I set a variable (orienVal) when the stage is opened and use this to modify the corresponding character motion:
if event.type == "landscapeRight" then
orienVal = -1
elseif event.type == "landscapeLeft" then
orienVal = 1
end
if \_G.box2["profile"].environment == "simulator" then
print("SIMULATOR")
aclrVal = event.xGravity
else
print("DEVICE")
aclrVal = event.yGravity
end
motionX = 20 \* (orienVal\*aclrVal)
However I’ve noticed on numerous occasions this fails because the orientation is being recognised as faceUp. Not entirely sure how to handle this, as a simple else in the above condition will have to make the assumption that it’s either landscapeLeft or landscapeRight - which obviously can be a wrong assumption to make.
The only solution I can think is to restrict the orientation to one landscape setting, but I don’t believe this is ideal.
Many thanks for any opinions. [import]uid: 33275 topic_id: 36076 reply_id: 336076[/import]