Theoretically you can implement a low pass filter to get the gravity component and base your decision on it.
-- get accelerometer valueslocal x, y = accelerometer:getAcceleration()-- apply low pass filter
self.fx = x * self.filter + self.fx *(1 - self.filter)
self.fy = y * self.filter + self.fy *(1 - self.filter)
Then can't remember from the top of my head, but you can check for absolute values which is higher x or y to determine is it portrait or landscape and then is it positive or negative to see if it's landscape left or landscape right
uh.. I see. Let me try to find a good solution to it.
I suggest two solutions: 1. dispatch the device rotation event, we can calculator the value ourselfs. 2. rotate the value of accelerometer according to oritation in the api.
Is there any progress on this? When using autorotate values are negated if upside down, but this info is not passed on to the lua environment, so no way to correct behaviour. Do the rotate events get pushed to lua layer in any way?
I did some test with Application:getOrientation() and it seems Application:getOrientation() only returns what is set, and not the real "active" orientation of the device.... I guess I will have to analyse the other accel values to understand the orientation myself I was only using y, and now I will have to consider x, and z to see which orientation the device is in and then correct the y values accordingly for interaction....
it seems Application:getOrientation() only returns what is set, and not the real "active" orientation of the device....
yup 1jetly
hijacking thread now
long time ago i had made one game which uses accelerometer that works fine when device is in faceup mode (i dont know whether android has faceup and facedown but still for explanation) but when it come in facedown mode (play while sleeping on bed) it doesnt work i had lived that as it was but just wanted to know whether there is any solid solution for this or not
Comments
@ar2rsawseen may not yet.
https://sites.google.com/site/xraystudiogame
1. dispatch the device rotation event, we can calculator the value ourselfs.
2. rotate the value of accelerometer according to oritation in the api.
https://sites.google.com/site/xraystudiogame
When using autorotate values are negated if upside down, but this info is not passed on to the lua environment, so no way to correct behaviour.
Do the rotate events get pushed to lua layer in any way?
and it seems Application:getOrientation() only returns what is set, and not the real "active" orientation of the device....
I guess I will have to analyse the other accel values to understand the orientation myself
I was only using y, and now I will have to consider x, and z to see which orientation the device is in and then correct the y values accordingly for interaction....
yup 1jetly
hijacking thread now
long time ago i had made one game which uses accelerometer that works fine when device is in faceup mode (i dont know whether android has faceup and facedown but still for explanation) but when it come in facedown mode (play while sleeping on bed) it doesnt work i had lived that as it was but just wanted to know whether there is any solid solution for this or not
Likes: ramose