mirror of https://github.com/axmolengine/axmol.git
issue #3457
1. replace UIAction NULL to nullptr. 2. modify class variable name.
This commit is contained in:
parent
cfbbb7889b
commit
774e3d8536
|
@ -88,11 +88,11 @@ ActionInterval* ActionFrame::getAction(float fDuration,ActionFrame* srcFrame)
|
||||||
return this->getAction(fDuration);
|
return this->getAction(fDuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionFrame::setEasingParameter(std::vector<float> parameter)
|
void ActionFrame::setEasingParameter(std::vector<float>& parameter)
|
||||||
{
|
{
|
||||||
_Parameter.clear();
|
_Parameter.clear();
|
||||||
|
|
||||||
for ( unsigned int i = 0; i<parameter.size(); i++)
|
for (size_t i = 0; i<parameter.size(); i++)
|
||||||
{
|
{
|
||||||
_Parameter.push_back(parameter[i]);
|
_Parameter.push_back(parameter[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,7 @@ public:
|
||||||
*@parame parameter the parameter for frame ease
|
*@parame parameter the parameter for frame ease
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
virtual void setEasingParameter(std::vector<float> parameter);
|
virtual void setEasingParameter(std::vector<float>& parameter);
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Gets the Easing Action of ActionFrame.
|
* Gets the Easing Action of ActionFrame.
|
||||||
|
|
|
@ -29,7 +29,7 @@ using namespace cocos2d;
|
||||||
|
|
||||||
namespace cocostudio {
|
namespace cocostudio {
|
||||||
|
|
||||||
static ActionManagerEx* sharedActionManager = NULL;
|
static ActionManagerEx* sharedActionManager = nullptr;
|
||||||
|
|
||||||
ActionManagerEx* ActionManagerEx::shareManager()
|
ActionManagerEx* ActionManagerEx::shareManager()
|
||||||
{
|
{
|
||||||
|
@ -77,7 +77,7 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char*
|
||||||
auto iterator = _pActionDic.find(jsonName);
|
auto iterator = _pActionDic.find(jsonName);
|
||||||
if (iterator == _pActionDic.end())
|
if (iterator == _pActionDic.end())
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
auto actionList = iterator->second;
|
auto actionList = iterator->second;
|
||||||
for (int i = 0; i < actionList.size(); i++)
|
for (int i = 0; i < actionList.size(); i++)
|
||||||
|
@ -88,7 +88,7 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char*
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName)
|
ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName)
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
void releaseActions();
|
void releaseActions();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::map<std::string, cocos2d::Vector<ActionObject*>> _pActionDic;
|
std::unordered_map<std::string, cocos2d::Vector<ActionObject*>> _pActionDic;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,9 @@ ActionNode::ActionNode()
|
||||||
, _destFrameIndex(0)
|
, _destFrameIndex(0)
|
||||||
, _fUnitTime(0.1f)
|
, _fUnitTime(0.1f)
|
||||||
, _actionTag(0)
|
, _actionTag(0)
|
||||||
, _actionSpawn(NULL)
|
, _actionSpawn(nullptr)
|
||||||
, _action(NULL)
|
, _action(nullptr)
|
||||||
, _object(NULL)
|
, _object(nullptr)
|
||||||
, _frameArray(NULL)
|
|
||||||
, _frameArrayNum(0)
|
, _frameArrayNum(0)
|
||||||
{
|
{
|
||||||
_frameArrayNum = (int)kKeyframeMax;
|
_frameArrayNum = (int)kKeyframeMax;
|
||||||
|
@ -53,7 +52,7 @@ ActionNode::ActionNode()
|
||||||
|
|
||||||
ActionNode::~ActionNode()
|
ActionNode::~ActionNode()
|
||||||
{
|
{
|
||||||
if (_action == NULL)
|
if (_action == nullptr)
|
||||||
{
|
{
|
||||||
CC_SAFE_RELEASE_NULL(_actionSpawn);
|
CC_SAFE_RELEASE_NULL(_actionSpawn);
|
||||||
}
|
}
|
||||||
|
@ -140,13 +139,13 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root)
|
||||||
void ActionNode::initActionNodeFromRoot(Object* root)
|
void ActionNode::initActionNodeFromRoot(Object* root)
|
||||||
{
|
{
|
||||||
Node* rootNode = dynamic_cast<Node*>(root);
|
Node* rootNode = dynamic_cast<Node*>(root);
|
||||||
if (rootNode != NULL)
|
if (rootNode != nullptr)
|
||||||
{
|
{
|
||||||
Widget* rootWidget = dynamic_cast<Widget*>(root);
|
Widget* rootWidget = dynamic_cast<Widget*>(root);
|
||||||
if (rootWidget != NULL)
|
if (rootWidget != nullptr)
|
||||||
{
|
{
|
||||||
Widget* widget = UIHelper::seekActionWidgetByActionTag(rootWidget, getActionTag());
|
Widget* widget = UIHelper::seekActionWidgetByActionTag(rootWidget, getActionTag());
|
||||||
if (widget != NULL)
|
if (widget != nullptr)
|
||||||
{
|
{
|
||||||
setObject(widget);
|
setObject(widget);
|
||||||
}
|
}
|
||||||
|
@ -188,24 +187,24 @@ Object* ActionNode::getObject()
|
||||||
Node* ActionNode::getActionNode()
|
Node* ActionNode::getActionNode()
|
||||||
{
|
{
|
||||||
Node* cNode = dynamic_cast<Node*>(_object);
|
Node* cNode = dynamic_cast<Node*>(_object);
|
||||||
if (cNode != NULL)
|
if (cNode != nullptr)
|
||||||
{
|
{
|
||||||
return cNode;
|
return cNode;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Widget* rootWidget = dynamic_cast<Widget*>(_object);
|
Widget* rootWidget = dynamic_cast<Widget*>(_object);
|
||||||
if (rootWidget != NULL)
|
if (rootWidget != nullptr)
|
||||||
{
|
{
|
||||||
return rootWidget;
|
return rootWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionNode::insertFrame(int index, ActionFrame* frame)
|
void ActionNode::insertFrame(int index, ActionFrame* frame)
|
||||||
{
|
{
|
||||||
if (frame == NULL)
|
if (frame == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +218,7 @@ void ActionNode::insertFrame(int index, ActionFrame* frame)
|
||||||
|
|
||||||
void ActionNode::addFrame(ActionFrame* frame)
|
void ActionNode::addFrame(ActionFrame* frame)
|
||||||
{
|
{
|
||||||
if (frame == NULL)
|
if (frame == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -234,7 +233,7 @@ void ActionNode::addFrame(ActionFrame* frame)
|
||||||
|
|
||||||
void ActionNode::deleteFrame(ActionFrame* frame)
|
void ActionNode::deleteFrame(ActionFrame* frame)
|
||||||
{
|
{
|
||||||
if (frame == NULL)
|
if (frame == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -256,9 +255,9 @@ void ActionNode::clearAllFrame()
|
||||||
|
|
||||||
Spawn * ActionNode::refreshActionProperty()
|
Spawn * ActionNode::refreshActionProperty()
|
||||||
{
|
{
|
||||||
if ( _object == NULL )
|
if ( _object == nullptr )
|
||||||
{
|
{
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Vector<FiniteTimeAction*> cSpawnArray;
|
Vector<FiniteTimeAction*> cSpawnArray;
|
||||||
|
|
||||||
|
@ -283,18 +282,18 @@ Spawn * ActionNode::refreshActionProperty()
|
||||||
auto srcFrame = cArray.at(i-1);
|
auto srcFrame = cArray.at(i-1);
|
||||||
float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime();
|
float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime();
|
||||||
Action* cAction = frame->getAction(duration);
|
Action* cAction = frame->getAction(duration);
|
||||||
if(cAction != NULL)
|
if(cAction != nullptr)
|
||||||
cSequenceArray.pushBack(static_cast<FiniteTimeAction*>(cAction));
|
cSequenceArray.pushBack(static_cast<FiniteTimeAction*>(cAction));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Sequence* cSequence = Sequence::create(cSequenceArray);
|
Sequence* cSequence = Sequence::create(cSequenceArray);
|
||||||
if (cSequence != NULL)
|
if (cSequence != nullptr)
|
||||||
{
|
{
|
||||||
cSpawnArray.pushBack(cSequence);
|
cSpawnArray.pushBack(cSequence);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_action == NULL)
|
if (_action == nullptr)
|
||||||
{
|
{
|
||||||
CC_SAFE_RELEASE_NULL(_actionSpawn);
|
CC_SAFE_RELEASE_NULL(_actionSpawn);
|
||||||
}
|
}
|
||||||
|
@ -310,17 +309,17 @@ Spawn * ActionNode::refreshActionProperty()
|
||||||
|
|
||||||
void ActionNode::playAction()
|
void ActionNode::playAction()
|
||||||
{
|
{
|
||||||
if ( _object == NULL || _actionSpawn == NULL)
|
if ( _object == nullptr || _actionSpawn == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_action!=NULL)
|
if (_action!=nullptr)
|
||||||
{
|
{
|
||||||
_action->release();
|
_action->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
_action = Sequence::create(_actionSpawn, NULL);
|
_action = Sequence::create(_actionSpawn, nullptr);
|
||||||
_action->retain();
|
_action->retain();
|
||||||
|
|
||||||
this->runAction();
|
this->runAction();
|
||||||
|
@ -330,7 +329,7 @@ void ActionNode::playAction()
|
||||||
void ActionNode::runAction()
|
void ActionNode::runAction()
|
||||||
{
|
{
|
||||||
Node* cNode = this->getActionNode();
|
Node* cNode = this->getActionNode();
|
||||||
if (cNode != NULL && _action != NULL)
|
if (cNode != nullptr && _action != nullptr)
|
||||||
{
|
{
|
||||||
cNode->runAction(_action);
|
cNode->runAction(_action);
|
||||||
}
|
}
|
||||||
|
@ -339,7 +338,7 @@ void ActionNode::runAction()
|
||||||
void ActionNode::stopAction()
|
void ActionNode::stopAction()
|
||||||
{
|
{
|
||||||
Node* cNode = this->getActionNode();
|
Node* cNode = this->getActionNode();
|
||||||
if (cNode != NULL && _action != NULL)
|
if (cNode != nullptr && _action != nullptr)
|
||||||
{
|
{
|
||||||
cNode->stopAction(_action);
|
cNode->stopAction(_action);
|
||||||
}
|
}
|
||||||
|
@ -403,8 +402,8 @@ bool ActionNode::updateActionToTimeLine(float fTime)
|
||||||
{
|
{
|
||||||
bool bFindFrame = false;
|
bool bFindFrame = false;
|
||||||
|
|
||||||
ActionFrame* srcFrame = NULL;
|
ActionFrame* srcFrame = nullptr;
|
||||||
// ActionFrame* destFrame = NULL;
|
// ActionFrame* destFrame = nullptr;
|
||||||
|
|
||||||
for (int n = 0; n < _frameArrayNum; n++)
|
for (int n = 0; n < _frameArrayNum; n++)
|
||||||
{
|
{
|
||||||
|
@ -420,7 +419,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
|
||||||
|
|
||||||
if (frame->getFrameIndex()*getUnitTime() == fTime)
|
if (frame->getFrameIndex()*getUnitTime() == fTime)
|
||||||
{
|
{
|
||||||
this->easingToFrame(1.0f,1.0f,NULL,frame);
|
this->easingToFrame(1.0f,1.0f,nullptr,frame);
|
||||||
bFindFrame = true;
|
bFindFrame = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -428,7 +427,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
this->easingToFrame(1.0f,1.0f,NULL,frame);
|
this->easingToFrame(1.0f,1.0f,nullptr,frame);
|
||||||
bFindFrame = false;
|
bFindFrame = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -436,7 +435,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
|
||||||
srcFrame = cArray.at(i-1);
|
srcFrame = cArray.at(i-1);
|
||||||
float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex())*getUnitTime();
|
float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex())*getUnitTime();
|
||||||
float delaytime = fTime - srcFrame->getFrameIndex()*getUnitTime();
|
float delaytime = fTime - srcFrame->getFrameIndex()*getUnitTime();
|
||||||
this->easingToFrame(duration,1.0f,NULL,srcFrame);
|
this->easingToFrame(duration,1.0f,nullptr,srcFrame);
|
||||||
//float easingTime = ActionFrameEasing::bounceTime(delaytime);
|
//float easingTime = ActionFrameEasing::bounceTime(delaytime);
|
||||||
this->easingToFrame(duration,delaytime/duration,srcFrame,frame);
|
this->easingToFrame(duration,delaytime/duration,srcFrame,frame);
|
||||||
bFindFrame = true;
|
bFindFrame = true;
|
||||||
|
@ -452,7 +451,7 @@ void ActionNode::easingToFrame(float duration,float delayTime,ActionFrame* srcFr
|
||||||
{
|
{
|
||||||
Action* cAction = destFrame->getAction(duration,srcFrame);
|
Action* cAction = destFrame->getAction(duration,srcFrame);
|
||||||
Node* cNode = this->getActionNode();
|
Node* cNode = this->getActionNode();
|
||||||
if (cAction == NULL || cNode == NULL)
|
if (cAction == nullptr || cNode == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,15 +30,14 @@ using namespace cocos2d;
|
||||||
namespace cocostudio {
|
namespace cocostudio {
|
||||||
|
|
||||||
ActionObject::ActionObject()
|
ActionObject::ActionObject()
|
||||||
: _actionNodeList(NULL)
|
: _name("")
|
||||||
, _name("")
|
|
||||||
, _loop(false)
|
, _loop(false)
|
||||||
, _bPause(false)
|
, _bPause(false)
|
||||||
, _bPlaying(false)
|
, _bPlaying(false)
|
||||||
, _fUnitTime(0.1f)
|
, _fUnitTime(0.1f)
|
||||||
, _currentTime(0.0f)
|
, _currentTime(0.0f)
|
||||||
, _pScheduler(NULL)
|
, _pScheduler(nullptr)
|
||||||
, _CallBack(NULL)
|
, _CallBack(nullptr)
|
||||||
, _fTotalTime(0.0f)
|
, _fTotalTime(0.0f)
|
||||||
{
|
{
|
||||||
_pScheduler = Director::getInstance()->getScheduler();
|
_pScheduler = Director::getInstance()->getScheduler();
|
||||||
|
@ -127,7 +126,7 @@ void ActionObject::initWithDictionary(const rapidjson::Value& dic, Object* root)
|
||||||
|
|
||||||
void ActionObject::addActionNode(ActionNode* node)
|
void ActionObject::addActionNode(ActionNode* node)
|
||||||
{
|
{
|
||||||
if (node == NULL)
|
if (node == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,7 @@ void ActionObject::addActionNode(ActionNode* node)
|
||||||
}
|
}
|
||||||
void ActionObject::removeActionNode(ActionNode* node)
|
void ActionObject::removeActionNode(ActionNode* node)
|
||||||
{
|
{
|
||||||
if (node == NULL)
|
if (node == nullptr)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -219,7 +218,7 @@ void ActionObject::simulationActionUpdate(float dt)
|
||||||
|
|
||||||
if (isEnd)
|
if (isEnd)
|
||||||
{
|
{
|
||||||
if (_CallBack != NULL)
|
if (_CallBack != nullptr)
|
||||||
{
|
{
|
||||||
_CallBack->execute();
|
_CallBack->execute();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,6 @@ using namespace cocos2d;
|
||||||
namespace cocostudio {
|
namespace cocostudio {
|
||||||
|
|
||||||
ComAttribute::ComAttribute(void)
|
ComAttribute::ComAttribute(void)
|
||||||
: _dict(NULL)
|
|
||||||
{
|
{
|
||||||
_name = "ComAttribute";
|
_name = "ComAttribute";
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ bool ArmatureActionState::init()
|
||||||
{
|
{
|
||||||
Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag);
|
Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag);
|
||||||
CC_BREAK_IF(pNode == nullptr);
|
CC_BREAK_IF(pNode == nullptr);
|
||||||
ComRender *pRender = (ComRender*)(pNode->getComponent(_ComName.c_str()));
|
ComRender *pRender = (ComRender*)(pNode->getComponent(_comName.c_str()));
|
||||||
CC_BREAK_IF(pRender == nullptr);
|
CC_BREAK_IF(pRender == nullptr);
|
||||||
Armature *pAr = (Armature *)(pRender->getNode());
|
Armature *pAr = (Armature *)(pRender->getNode());
|
||||||
CC_BREAK_IF(pAr == nullptr);
|
CC_BREAK_IF(pAr == nullptr);
|
||||||
|
@ -109,7 +109,7 @@ void ArmatureActionState::serialize(const rapidjson::Value &val)
|
||||||
}
|
}
|
||||||
else if (key == "componentName")
|
else if (key == "componentName")
|
||||||
{
|
{
|
||||||
_ComName = DICTOOL->getStringValue_json(subDict, "value");
|
_comName = DICTOOL->getStringValue_json(subDict, "value");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (key == "AnimationName")
|
else if (key == "AnimationName")
|
||||||
|
@ -131,7 +131,7 @@ void ArmatureActionState::removeAll()
|
||||||
{
|
{
|
||||||
Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag);
|
Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag);
|
||||||
CC_BREAK_IF(pNode == nullptr);
|
CC_BREAK_IF(pNode == nullptr);
|
||||||
ComRender *pRender = (ComRender*)(pNode->getComponent(_ComName.c_str()));
|
ComRender *pRender = (ComRender*)(pNode->getComponent(_comName.c_str()));
|
||||||
CC_BREAK_IF(pRender == nullptr);
|
CC_BREAK_IF(pRender == nullptr);
|
||||||
Armature *pAr = (Armature *)(pRender->getNode());
|
Armature *pAr = (Armature *)(pRender->getNode());
|
||||||
CC_BREAK_IF(pAr == nullptr);
|
CC_BREAK_IF(pAr == nullptr);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
|
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
|
||||||
private:
|
private:
|
||||||
int _nTag;
|
int _nTag;
|
||||||
std::string _ComName;
|
std::string _comName;
|
||||||
std::string _aniname;
|
std::string _aniname;
|
||||||
int _nState;
|
int _nState;
|
||||||
bool _bSuc;
|
bool _bSuc;
|
||||||
|
|
Loading…
Reference in New Issue