diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index f4b89159c2..9e4fa9d1de 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -343,8 +343,8 @@ void Layer::onEnter() { auto dispatcher = EventDispatcher::getInstance(); dispatcher->removeEventListener(_accelerationListener); - auto listener = AccelerationEventListener::create(CC_CALLBACK_2(Layer::onAcceleration, this)); - dispatcher->addEventListenerWithSceneGraphPriority(listener, this); + _accelerationListener = AccelerationEventListener::create(CC_CALLBACK_2(Layer::onAcceleration, this)); + dispatcher->addEventListenerWithSceneGraphPriority(_accelerationListener, this); } }