[cocos2d v3.0 alpha0][Win7] OnAcceleration() not being called?

Hi,

I am hitting an issue that looks like onAcceleration() was never being called. I have set setAccelerometerEnabled to true. I pasted my code below. Can anyone please take a look? Thank you very much!

class GameManager : public cocos2d::Layer
{
public:
    static cocos2d::Scene* scene();
    virtual bool init();
    virtual void onEnter();
    CREATE_FUNC(GameManager);
    virtual void onAcceleration(cocos2d::Acceleration* acc, cocos2d::Event* event) override;
};

Scene* GameManager::scene()
{
    // 'scene' is an autorelease object
    auto scene = Scene::create();
    auto *gameManagerlayer = GameManager::create();
    scene->addChild(gameManagerlayer);
    return scene;
}

bool GameManager::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    return true;
}

void GameManager::onEnter()
{
    Layer::onEnter();
    setAccelerometerEnabled(true);
}

void GameManager::onAcceleration(Acceleration* acc, Event* event)
{
    // put a break point here, and never being hit
    ... code
}

Try overriding this method.

void GameManager::didAccelerate(Acceleration* acceleration)

Thanks for reply, Bunty! I am using cocos2d v3.0 alpha0. In this version, didAccelerate() has been depreciated. The alternative is onAccelaration().

    /** @deprecated Please override onAcceleration */
    CC_DEPRECATED_ATTRIBUTE virtual void didAccelerate(Acceleration* accelerationValue) final {};

    virtual void onAcceleration(Acceleration* acc, Event* event);

I have the same problem on iOS, setAccelerometerEnabled(true) does not have any effects

void onAcceleration(cocos2d::Acceleration *pAccelerationValue) is not called on the layer at any time

Hi Alexey,

You might forget to enable the accelerometer by using following line of code:

this->setAccelerometerEnabled(true);

Please check, it may help you.