Merge pull request #3647 from dumganhar/bug422-fix

issue #2087: [dispatcher] Fixing BugTest/Bug422 crashes.[ci skip]
This commit is contained in:
James Chen 2013-09-17 02:18:09 -07:00
commit 8bb2c3979e
12 changed files with 124 additions and 449 deletions

View File

@ -58,11 +58,17 @@ private:
NS_CC_BEGIN
EventDispatcher::EventListenerItem::~EventListenerItem()
{
CC_SAFE_RELEASE(this->node);
}
EventDispatcher::EventDispatcher()
: _inDispatch(0)
, _listeners(nullptr)
, _isEnabled(true)
{
_toAddedListeners.reserve(50);
}
EventDispatcher::~EventDispatcher()
@ -82,25 +88,33 @@ void EventDispatcher::addEventListenerWithItem(EventListenerItem* item)
_listeners = new std::map<std::string, std::vector<EventListenerItem*>*>();
}
std::vector<EventListenerItem*>* listenerList = nullptr;
auto itr = _listeners->find(item->listener->type);
if (itr == _listeners->end())
if (_inDispatch == 0)
{
listenerList = new std::vector<EventListenerItem*>();
listenerList->reserve(100);
_listeners->insert(std::make_pair(item->listener->type, listenerList));
std::vector<EventListenerItem*>* listenerList = nullptr;
auto itr = _listeners->find(item->listener->type);
if (itr == _listeners->end())
{
listenerList = new std::vector<EventListenerItem*>();
listenerList->reserve(100);
_listeners->insert(std::make_pair(item->listener->type, listenerList));
}
else
{
listenerList = itr->second;
}
listenerList->insert(listenerList->begin(), item);
}
else
{
listenerList = itr->second;
_toAddedListeners.push_back(item);
}
listenerList->insert(listenerList->begin(), item);
}
void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* listener, Node* node)
{
CCASSERT(listener && node, "Invalid parameters.");
CCASSERT(!listener->_isRegistered, "The listener has been registered.");
if (!listener->checkAvaiable())
@ -108,6 +122,7 @@ void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* list
auto item = new EventListenerItem();
item->node = node;
item->node->retain();
item->fixedPriority = 0;
item->listener = listener;
item->listener->retain();
@ -120,6 +135,7 @@ void EventDispatcher::addEventListenerWithSceneGraphPriority(EventListener* list
void EventDispatcher::addEventListenerWithFixedPriority(EventListener* listener, int fixedPriority)
{
CCASSERT(listener, "Invalid parameters.");
CCASSERT(!listener->_isRegistered, "The listener has been registered.");
CCASSERT(fixedPriority != 0, "0 priority is forbidden for fixed priority since it's used for scene graph based priority.");
@ -141,6 +157,8 @@ void EventDispatcher::removeEventListener(EventListener* listener)
if (_listeners == nullptr || listener == nullptr)
return;
bool isFound = false;
for (auto iter = _listeners->begin(); iter != _listeners->end();)
{
for (auto itemIter = iter->second->begin(); itemIter != iter->second->end(); ++itemIter)
@ -158,6 +176,7 @@ void EventDispatcher::removeEventListener(EventListener* listener)
(*itemIter)->listener = nullptr;
}
isFound = true;
break;
}
}
@ -172,6 +191,9 @@ void EventDispatcher::removeEventListener(EventListener* listener)
{
++iter;
}
if (isFound)
break;
}
if (_listeners->empty())
@ -193,6 +215,9 @@ void EventDispatcher::setPriorityWithSceneGraph(EventListener* listener, Node* n
if (item->listener == listener)
{
item->fixedPriority = 0;
CC_SAFE_RETAIN(node);
CC_SAFE_RELEASE(item->node);
item->node = node;
return;
}
@ -216,7 +241,7 @@ void EventDispatcher::setPriorityWithFixedValue(EventListener* listener, int fix
if (item->node != nullptr)
{
item->node->dissociateEventListener(listener);
item->node = nullptr;
CC_SAFE_RELEASE_NULL(item->node);
}
return;
}
@ -259,7 +284,7 @@ void EventDispatcher::dispatchEvent(Event* event, bool toSortListeners)
}
}
removeUnregisteredListeners();
updateListenerItems();
}
void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
@ -331,7 +356,7 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
if (touchEventListener->onTouchBegan)
{
isClaimed = touchEventListener->onTouchBegan(*touchesIter, event);
if (isClaimed)
if (isClaimed && item->listener)
{
touchEventListener->_claimedTouches.push_back(*touchesIter);
}
@ -355,14 +380,20 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
{
touchEventListener->onTouchEnded(*touchesIter, event);
}
touchEventListener->_claimedTouches.erase(removedIter);
if (item->listener)
{
touchEventListener->_claimedTouches.erase(removedIter);
}
break;
case TouchEvent::EventCode::CANCELLED:
if (touchEventListener->onTouchCancelled)
{
touchEventListener->onTouchCancelled(*touchesIter, event);
}
touchEventListener->_claimedTouches.erase(removedIter);
if (item->listener)
{
touchEventListener->_claimedTouches.erase(removedIter);
}
break;
default:
CCASSERT(false, "The eventcode is invalid.");
@ -373,13 +404,13 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
// If the event was stopped, return directly.
if (event->isStopped())
{
removeUnregisteredListeners();
updateListenerItems();
return;
}
CCASSERT((*touchesIter)->getID() == (*mutableTouchesIter)->getID(), "");
if (isClaimed && touchEventListener->_needSwallow)
if (isClaimed && item->listener && touchEventListener->_needSwallow)
{
if (isNeedsMutableSet)
{
@ -444,16 +475,16 @@ void EventDispatcher::dispatchTouchEvent(TouchEvent* event)
// If the event was stopped, return directly.
if (event->isStopped())
{
removeUnregisteredListeners();
updateListenerItems();
return;
}
}
}
removeUnregisteredListeners();
updateListenerItems();
}
void EventDispatcher::removeUnregisteredListeners()
void EventDispatcher::updateListenerItems()
{
if (!_listeners)
return;
@ -461,17 +492,19 @@ void EventDispatcher::removeUnregisteredListeners()
auto listenerItemIter = _listeners->begin();
while (listenerItemIter != _listeners->end())
{
auto removeIterBegin = std::remove_if(listenerItemIter->second->begin(), listenerItemIter->second->end(), [](const EventListenerItem* item){
return item->listener == nullptr;
});
for (auto iter = removeIterBegin; iter != listenerItemIter->second->end(); ++iter)
for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end();)
{
delete (*iter);
if ((*iter)->listener == nullptr)
{
delete (*iter);
iter = listenerItemIter->second->erase(iter);
}
else
{
++iter;
}
}
listenerItemIter->second->erase(removeIterBegin, listenerItemIter->second->end());
if (listenerItemIter->second->empty())
{
delete listenerItemIter->second;
@ -483,6 +516,29 @@ void EventDispatcher::removeUnregisteredListeners()
}
}
if (!_toAddedListeners.empty())
{
std::vector<EventListenerItem*>* listenerList = nullptr;
for (auto& item : _toAddedListeners)
{
auto itr = _listeners->find(item->listener->type);
if (itr == _listeners->end())
{
listenerList = new std::vector<EventListenerItem*>();
listenerList->reserve(100);
_listeners->insert(std::make_pair(item->listener->type, listenerList));
}
else
{
listenerList = itr->second;
}
listenerList->push_back(item);
}
_toAddedListeners.clear();
}
if (_listeners->empty())
{
delete _listeners;
@ -563,14 +619,22 @@ void EventDispatcher::removeListenersForEventType(const std::string& eventType)
for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter)
{
(*iter)->listener->release();
delete (*iter);
if (_inDispatch)
{
(*iter)->listener = nullptr;
}
else
{
delete (*iter);
}
}
listenerItemIter->second->clear();
delete listenerItemIter->second;
_listeners->erase(listenerItemIter);
if (!_inDispatch)
{
listenerItemIter->second->clear();
delete listenerItemIter->second;
_listeners->erase(listenerItemIter);
}
}
}
@ -584,16 +648,28 @@ void EventDispatcher::removeAllListeners()
for (auto iter = listenerItemIter->second->begin(); iter != listenerItemIter->second->end(); ++iter)
{
(*iter)->listener->release();
delete (*iter);
if (_inDispatch)
{
(*iter)->listener = nullptr;
}
else
{
delete (*iter);
}
}
listenerItemIter->second->clear();
delete listenerItemIter->second;
if (!_inDispatch)
{
listenerItemIter->second->clear();
delete listenerItemIter->second;
}
}
delete _listeners;
_listeners = nullptr;
if (!_inDispatch)
{
delete _listeners;
_listeners = nullptr;
}
}
void EventDispatcher::setEnabled(bool isEnabled)

View File

@ -110,6 +110,7 @@ private:
int fixedPriority; // The higher the number, the higher the priority
Node* node; // Weak reference.
EventListener* listener;
~EventListenerItem();
};
/** Constructor of EventDispatcher */
@ -127,15 +128,19 @@ private:
/** Sorts the listeners of specified type by priority */
void sortAllEventListenerItemsForType(const std::string& eventType);
/** Removes all listeners that have been unregistered. */
void removeUnregisteredListeners();
/** Updates all listener items
* 1) Removes all listener items that have been marked as 'removed' when dispatching event.
* 2) Adds all listener items that have been marked as 'added' when dispatching event.
*/
void updateListenerItems();
private:
/**
* Listeners map.
*/
std::map<std::string, std::vector<EventListenerItem*>*>* _listeners;
std::vector<EventListenerItem*> _toAddedListeners;
int _inDispatch;
bool _isEnabled;
};

View File

@ -909,7 +909,6 @@ CC_DEPRECATED_ATTRIBUTE typedef ParticleSystem::PositionType tPositionType;
#define kCCLabelAutomaticWidth kLabelAutomaticWidth
CC_DEPRECATED_ATTRIBUTE const int kCCMenuHandlerPriority = Menu::HANDLER_PRIORITY;
CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateWaiting = Menu::State::WAITING;
CC_DEPRECATED_ATTRIBUTE const Menu::State kCCMenuStateTrackingTouch = Menu::State::TRACKING_TOUCH;

View File

@ -50,11 +50,6 @@ NS_CC_BEGIN
class CC_DLL Menu : public LayerRGBA
{
public:
enum
{
HANDLER_PRIORITY = -128,
};
enum class State
{
WAITING,

View File

@ -1,51 +0,0 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCACCELEROMETER_DELEGATE_H__
#define __CCACCELEROMETER_DELEGATE_H__
#include "platform/CCCommon.h"
NS_CC_BEGIN
/**
@brief The device accelerometer reports values for each axis in units of g-force
*/
class Acceleration
{
public:
double x;
double y;
double z;
double timestamp;
/**
* @js NA
* @lua NA
*/
Acceleration(): x(0), y(0), z(0), timestamp(0) {}
};
NS_CC_END
#endif

View File

@ -1,58 +0,0 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __PLATFORM_ANDROID_CCACCELEROMETER_H__
#define __PLATFORM_ANDROID_CCACCELEROMETER_H__
#include "platform/CCCommon.h"
#include "platform/CCAccelerometerDelegate.h"
#include <functional>
namespace cocos2d {
class Accelerometer
{
public:
/**
* @js ctor
*/
Accelerometer();
/**
* @js NA
* @lua NA
*/
~Accelerometer();
void setDelegate(std::function<void(Acceleration*)> function);
void setAccelerometerInterval(float interval);
void update(float x, float y, float z, long sensorTimeStamp);
private:
std::function<void(Acceleration*)> _function;
Acceleration _accelerationValue;
};
}//namespace cocos2d
#endif

View File

@ -1,39 +0,0 @@
/*
* Accelerometer.h
*
* Created on: Aug 9, 2011
* Author: laschweinski
*/
#ifndef CCACCELEROMETER_H_
#define CCACCELEROMETER_H_
#include "platform/CCAccelerometerDelegate.h"
#include <functional>
namespace cocos2d {
class Accelerometer
{
public:
/**
* @js ctor
*/
Accelerometer(){}
/**
* @js NA
* @lua NA
*/
~Accelerometer(){}
static Accelerometer* sharedAccelerometer() { return NULL; };
void removeDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void addDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
};
}//namespace cocos2d
#endif /* CCACCELEROMETER_H_ */

View File

@ -1,52 +0,0 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __PLATFORM_IPHONE_CCACCELEROMETER_H__
#define __PLATFORM_IPHONE_CCACCELEROMETER_H__
#include <functional>
#include "platform/CCAccelerometerDelegate.h"
NS_CC_BEGIN
class Accelerometer
{
public:
/**
* @js ctor
*/
Accelerometer();
/**
* @js NA
* @lua NA
*/
~Accelerometer();
void setDelegate(std::function<void(Acceleration*)> function);
void setAccelerometerInterval(float interval);
};
NS_CC_END
#endif

View File

@ -1,39 +0,0 @@
/*
* Accelerometer.h
*
* Created on: Aug 9, 2011
* Author: laschweinski
*/
#ifndef CCACCELEROMETER_H_
#define CCACCELEROMETER_H_
#include "platform/CCAccelerometerDelegate.h"
#include <functional>
namespace cocos2d {
class Accelerometer
{
public:
/**
* @js ctor
*/
Accelerometer(){}
/**
* @js NA
* @lua NA
*/
~Accelerometer(){}
static Accelerometer* sharedAccelerometer() { return NULL; };
void removeDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void addDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
};
}//namespace cocos2d
#endif /* CCACCELEROMETER_H_ */

View File

@ -1,49 +0,0 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __PLATFORM_MAC_CCACCELEROMETER_H__
#define __PLATFORM_MAC_CCACCELEROMETER_H__
#include <functional>
#include "platform/CCAccelerometerDelegate.h"
NS_CC_BEGIN
class CC_DLL Accelerometer
{
public:
Accelerometer() {}
/**
* @js NA
* @lua NA
*/
~Accelerometer() {}
void setDelegate(std::function<void(Acceleration*)> function) { CC_UNUSED_PARAM(function); }
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
};
NS_CC_END
#endif

View File

@ -1,56 +0,0 @@
/****************************************************************************
Copyright (c) 2013 The Chromium Authors
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CCACCELEROMETER_H__
#define __CCACCELEROMETER_H__
#include "platform/CCAccelerometerDelegate.h"
#include <functional>
namespace cocos2d {
class Accelerometer
{
public:
/**
* @js ctor
*/
Accelerometer(){}
/**
* @js NA
* @lua NA
*/
~Accelerometer(){}
static Accelerometer* sharedAccelerometer() { return NULL; };
void removeDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void addDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setDelegate(std::function<void(Acceleration*)> function) {CC_UNUSED_PARAM(function);};
void setAccelerometerInterval(float interval) {CC_UNUSED_PARAM(interval);};
};
}
#endif /* __CCACCELEROMETER_H__ */

View File

@ -1,56 +0,0 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __PLATFORM_WIN32_UIACCELEROMETER_H__
#define __PLATFORM_WIN32_UIACCELEROMETER_H__
#include "platform/CCAccelerometerDelegate.h"
#include <functional>
NS_CC_BEGIN
class CC_DLL Accelerometer
{
public:
/**
* @js ctor
*/
Accelerometer();
/**
* @js NA
* @lua NA
*/
~Accelerometer();
void setDelegate(std::function<void(Acceleration*)> function);
void setAccelerometerInterval(float interval);
void update( double x,double y,double z,double timestamp );
private:
Acceleration _accelerationValue;
std::function<void(Acceleration*)> _function;
};
NS_CC_END
#endif