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

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



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
    static cocos2d::Scene* scene();
    virtual bool init();
    virtual void onEnter();
    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();
    return scene;

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

void GameManager::onEnter()

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:


Please check, it may help you.