title: How to calibrate UIAccelerometer?
body: <p>I am trying to calibrate my <code>UIAccelerometer</code> from ViewA but my Game view is ViewB. <em>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.</em></p>
  
  <p>So in ViewA would I do something like so?:</p>
  
  <pre><code>float accelX = (acceleration.x - [[NSUserDefaults standardUserDefaults] floatForKey:@"value1"]);
  [[NSUserDefaults standardUserDefaults] setFloat:accelX forKey:@"value1"];
  </code></pre>
  
  <p>Then in my Game class would I do this in my UIAccelerometer delegate method?:</p>
  
  <pre><code>float accelX = (acceleration.x - [[NSUserDefaults standardUserDefaults] floatForKey:@"X-Calibrate"]);
  //Low Pass Filter
  rollingX = (accelX * kFilteringFactor) + (rollingX * (1.0 - kFilteringFactor));
      AccelPoint.x += (rollingX*50);
  </code></pre>
  
  <p>Then I would do something like:</p>
  
  <pre><code>mySprite.position = ccp(accelX, yValue);
  </code></pre>
  
  <p>Am I doing anything wrong?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit</strong>: New code for ViewB, will I still need some form of friction now?</p>
  
  <pre><code>    rollingX = (acceleration.x * kFilteringFactor) + (rollingX * (1.0 - kFilteringFactor));     
  
  AccelPoint.x += (rollingX*50);
  </code></pre>
  
  <p>Then after that code I would set the position of my object.</p>