1. replace UIAction NULL to nullptr.
2. modify  class variable  name.
This commit is contained in:
chengstory 2013-12-26 23:40:50 +08:00
parent cfbbb7889b
commit 774e3d8536
9 changed files with 46 additions and 49 deletions

View File

@ -88,11 +88,11 @@ ActionInterval* ActionFrame::getAction(float fDuration,ActionFrame* srcFrame)
return this->getAction(fDuration);
}
void ActionFrame::setEasingParameter(std::vector<float> parameter)
void ActionFrame::setEasingParameter(std::vector<float>& parameter)
{
_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]);
}

View File

@ -188,7 +188,7 @@ public:
*@parame parameter the parameter for frame ease
*
*/
virtual void setEasingParameter(std::vector<float> parameter);
virtual void setEasingParameter(std::vector<float>& parameter);
protected:
/**
* Gets the Easing Action of ActionFrame.

View File

@ -29,7 +29,7 @@ using namespace cocos2d;
namespace cocostudio {
static ActionManagerEx* sharedActionManager = NULL;
static ActionManagerEx* sharedActionManager = nullptr;
ActionManagerEx* ActionManagerEx::shareManager()
{
@ -77,7 +77,7 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char*
auto iterator = _pActionDic.find(jsonName);
if (iterator == _pActionDic.end())
{
return NULL;
return nullptr;
}
auto actionList = iterator->second;
for (int i = 0; i < actionList.size(); i++)
@ -88,7 +88,7 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char*
return action;
}
}
return NULL;
return nullptr;
}
ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName)

View File

@ -104,7 +104,7 @@ public:
void releaseActions();
protected:
std::map<std::string, cocos2d::Vector<ActionObject*>> _pActionDic;
std::unordered_map<std::string, cocos2d::Vector<ActionObject*>> _pActionDic;
};
}

View File

@ -38,10 +38,9 @@ ActionNode::ActionNode()
, _destFrameIndex(0)
, _fUnitTime(0.1f)
, _actionTag(0)
, _actionSpawn(NULL)
, _action(NULL)
, _object(NULL)
, _frameArray(NULL)
, _actionSpawn(nullptr)
, _action(nullptr)
, _object(nullptr)
, _frameArrayNum(0)
{
_frameArrayNum = (int)kKeyframeMax;
@ -53,7 +52,7 @@ ActionNode::ActionNode()
ActionNode::~ActionNode()
{
if (_action == NULL)
if (_action == nullptr)
{
CC_SAFE_RELEASE_NULL(_actionSpawn);
}
@ -140,13 +139,13 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic,Object* root)
void ActionNode::initActionNodeFromRoot(Object* root)
{
Node* rootNode = dynamic_cast<Node*>(root);
if (rootNode != NULL)
if (rootNode != nullptr)
{
Widget* rootWidget = dynamic_cast<Widget*>(root);
if (rootWidget != NULL)
if (rootWidget != nullptr)
{
Widget* widget = UIHelper::seekActionWidgetByActionTag(rootWidget, getActionTag());
if (widget != NULL)
if (widget != nullptr)
{
setObject(widget);
}
@ -188,24 +187,24 @@ Object* ActionNode::getObject()
Node* ActionNode::getActionNode()
{
Node* cNode = dynamic_cast<Node*>(_object);
if (cNode != NULL)
if (cNode != nullptr)
{
return cNode;
}
else
{
Widget* rootWidget = dynamic_cast<Widget*>(_object);
if (rootWidget != NULL)
if (rootWidget != nullptr)
{
return rootWidget;
}
}
return NULL;
return nullptr;
}
void ActionNode::insertFrame(int index, ActionFrame* frame)
{
if (frame == NULL)
if (frame == nullptr)
{
return;
}
@ -219,7 +218,7 @@ void ActionNode::insertFrame(int index, ActionFrame* frame)
void ActionNode::addFrame(ActionFrame* frame)
{
if (frame == NULL)
if (frame == nullptr)
{
return;
}
@ -234,7 +233,7 @@ void ActionNode::addFrame(ActionFrame* frame)
void ActionNode::deleteFrame(ActionFrame* frame)
{
if (frame == NULL)
if (frame == nullptr)
{
return;
}
@ -256,9 +255,9 @@ void ActionNode::clearAllFrame()
Spawn * ActionNode::refreshActionProperty()
{
if ( _object == NULL )
if ( _object == nullptr )
{
return NULL;
return nullptr;
}
Vector<FiniteTimeAction*> cSpawnArray;
@ -283,18 +282,18 @@ Spawn * ActionNode::refreshActionProperty()
auto srcFrame = cArray.at(i-1);
float duration = (frame->getFrameIndex() - srcFrame->getFrameIndex()) * getUnitTime();
Action* cAction = frame->getAction(duration);
if(cAction != NULL)
if(cAction != nullptr)
cSequenceArray.pushBack(static_cast<FiniteTimeAction*>(cAction));
}
}
Sequence* cSequence = Sequence::create(cSequenceArray);
if (cSequence != NULL)
if (cSequence != nullptr)
{
cSpawnArray.pushBack(cSequence);
}
}
if (_action == NULL)
if (_action == nullptr)
{
CC_SAFE_RELEASE_NULL(_actionSpawn);
}
@ -310,17 +309,17 @@ Spawn * ActionNode::refreshActionProperty()
void ActionNode::playAction()
{
if ( _object == NULL || _actionSpawn == NULL)
if ( _object == nullptr || _actionSpawn == nullptr)
{
return;
}
if (_action!=NULL)
if (_action!=nullptr)
{
_action->release();
}
_action = Sequence::create(_actionSpawn, NULL);
_action = Sequence::create(_actionSpawn, nullptr);
_action->retain();
this->runAction();
@ -330,7 +329,7 @@ void ActionNode::playAction()
void ActionNode::runAction()
{
Node* cNode = this->getActionNode();
if (cNode != NULL && _action != NULL)
if (cNode != nullptr && _action != nullptr)
{
cNode->runAction(_action);
}
@ -339,7 +338,7 @@ void ActionNode::runAction()
void ActionNode::stopAction()
{
Node* cNode = this->getActionNode();
if (cNode != NULL && _action != NULL)
if (cNode != nullptr && _action != nullptr)
{
cNode->stopAction(_action);
}
@ -403,8 +402,8 @@ bool ActionNode::updateActionToTimeLine(float fTime)
{
bool bFindFrame = false;
ActionFrame* srcFrame = NULL;
// ActionFrame* destFrame = NULL;
ActionFrame* srcFrame = nullptr;
// ActionFrame* destFrame = nullptr;
for (int n = 0; n < _frameArrayNum; n++)
{
@ -420,7 +419,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
if (frame->getFrameIndex()*getUnitTime() == fTime)
{
this->easingToFrame(1.0f,1.0f,NULL,frame);
this->easingToFrame(1.0f,1.0f,nullptr,frame);
bFindFrame = true;
break;
}
@ -428,7 +427,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
{
if (i == 0)
{
this->easingToFrame(1.0f,1.0f,NULL,frame);
this->easingToFrame(1.0f,1.0f,nullptr,frame);
bFindFrame = false;
}
else
@ -436,7 +435,7 @@ bool ActionNode::updateActionToTimeLine(float fTime)
srcFrame = cArray.at(i-1);
float duration = (frame->getFrameIndex() - 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);
this->easingToFrame(duration,delaytime/duration,srcFrame,frame);
bFindFrame = true;
@ -452,7 +451,7 @@ void ActionNode::easingToFrame(float duration,float delayTime,ActionFrame* srcFr
{
Action* cAction = destFrame->getAction(duration,srcFrame);
Node* cNode = this->getActionNode();
if (cAction == NULL || cNode == NULL)
if (cAction == nullptr || cNode == nullptr)
{
return;
}

View File

@ -30,15 +30,14 @@ using namespace cocos2d;
namespace cocostudio {
ActionObject::ActionObject()
: _actionNodeList(NULL)
, _name("")
: _name("")
, _loop(false)
, _bPause(false)
, _bPlaying(false)
, _fUnitTime(0.1f)
, _currentTime(0.0f)
, _pScheduler(NULL)
, _CallBack(NULL)
, _pScheduler(nullptr)
, _CallBack(nullptr)
, _fTotalTime(0.0f)
{
_pScheduler = Director::getInstance()->getScheduler();
@ -127,7 +126,7 @@ void ActionObject::initWithDictionary(const rapidjson::Value& dic, Object* root)
void ActionObject::addActionNode(ActionNode* node)
{
if (node == NULL)
if (node == nullptr)
{
return;
}
@ -136,7 +135,7 @@ void ActionObject::addActionNode(ActionNode* node)
}
void ActionObject::removeActionNode(ActionNode* node)
{
if (node == NULL)
if (node == nullptr)
{
return;
}
@ -219,7 +218,7 @@ void ActionObject::simulationActionUpdate(float dt)
if (isEnd)
{
if (_CallBack != NULL)
if (_CallBack != nullptr)
{
_CallBack->execute();
}

View File

@ -28,7 +28,6 @@ using namespace cocos2d;
namespace cocostudio {
ComAttribute::ComAttribute(void)
: _dict(NULL)
{
_name = "ComAttribute";
}

View File

@ -80,7 +80,7 @@ bool ArmatureActionState::init()
{
Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag);
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);
Armature *pAr = (Armature *)(pRender->getNode());
CC_BREAK_IF(pAr == nullptr);
@ -109,7 +109,7 @@ void ArmatureActionState::serialize(const rapidjson::Value &val)
}
else if (key == "componentName")
{
_ComName = DICTOOL->getStringValue_json(subDict, "value");
_comName = DICTOOL->getStringValue_json(subDict, "value");
continue;
}
else if (key == "AnimationName")
@ -131,7 +131,7 @@ void ArmatureActionState::removeAll()
{
Node *pNode = SceneReader::getInstance()->getNodeByTag(_nTag);
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);
Armature *pAr = (Armature *)(pRender->getNode());
CC_BREAK_IF(pAr == nullptr);

View File

@ -39,7 +39,7 @@ public:
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
private:
int _nTag;
std::string _ComName;
std::string _comName;
std::string _aniname;
int _nState;
bool _bSuc;