I don’t understand how to use the accelerometer , please I need some help
- in MyLayer::init(), call this~~>setIsAccelerometerEnabled;
# implement MyLayer::didAccelerate in you layer
Sample code in tests/AccelerometerTest/AccelerometerTest.cpp
<pre>
void AccelerometerTest::didAccelerate
{
CCDirector* pDir = CCDirector::sharedDirector;
CCSize winSize = pDir~~>getWinSize();
/*FIXME: Testing on the Nexus S sometimes m_pBall is NULL /
if {
return;
}
CCSize ballSize = m_pBall~~>getContentSize;
CCPoint ptNow = m_pBall~~>getPosition;
CCPoint ptTemp = pDir~~>convertToUI;
ptTemp.x += pAccelerationValue~~>x 9.81f;
ptTemp.y = pAccelerationValue>y * 9.81f;
CCPoint ptNext = pDir~~>convertToGL;
FIX_POS, );
FIX_POS, );
m_pBall~~>setPosition(ptNext);
}
Thank you very much