I am trying to calibrate my UIAccelerometer
from ViewA but my Game view is ViewB. So pretty much what I want to achieve is lets say the user is playing on their side, I want my game to act like if they were playing while sitting up in a normal position.
So in ViewA would I do something like so?:
float accelX = (acceleration.x - [[NSUserDefaults standardUserDefaults] floatForKey:@"value1"]);
[[NSUserDefaults standardUserDefaults] setFloat:accelX forKey:@"value1"];
Then in my Game class would I do this in my UIAccelerometer delegate method?:
float accelX = (acceleration.x - [[NSUserDefaults standardUserDefaults] floatForKey:@"X-Calibrate"]);
//Low Pass Filter
rollingX = (accelX * kFilteringFactor) + (rollingX * (1.0 - kFilteringFactor));
AccelPoint.x += (rollingX*50);
Then I would do something like:
mySprite.position = ccp(accelX, yValue);
Am I doing anything wrong?
Thanks!
Edit: New code for ViewB, will I still need some form of friction now?
rollingX = (acceleration.x * kFilteringFactor) + (rollingX * (1.0 - kFilteringFactor));
AccelPoint.x += (rollingX*50);
Then after that code I would set the position of my object.