2013-12-26 01:17:04 +08:00
|
|
|
|
|
|
|
#include "acts.h"
|
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
using namespace cocostudio;
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(PlayMusic)
|
|
|
|
PlayMusic::PlayMusic(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
:_tag(-1)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PlayMusic::~PlayMusic(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PlayMusic::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayMusic::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
|
|
|
ComAudio *audio = (ComAudio*)(node->getComponent(_comName.c_str()));
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(audio == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
if (_type == 0)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
audio->playBackgroundMusic();
|
|
|
|
}
|
2014-01-03 01:14:12 +08:00
|
|
|
else if (_type == 1)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
audio->playEffect();
|
|
|
|
}
|
|
|
|
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayMusic::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "componentName")
|
|
|
|
{
|
|
|
|
_comName = DICTOOL->getStringValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "type")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_type = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayMusic::removeAll()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TMoveTo)
|
|
|
|
TMoveTo::TMoveTo(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
:_tag(-1)
|
|
|
|
,_duration(0.0f)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TMoveTo::~TMoveTo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TMoveTo::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMoveTo::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionTo = MoveTo::create(_duration, _pos);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionTo == nullptr);
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionTo);
|
2013-12-26 01:17:04 +08:00
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMoveTo::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "x")
|
|
|
|
{
|
|
|
|
_pos.x = DICTOOL->getIntValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "y")
|
|
|
|
{
|
|
|
|
_pos.y = DICTOOL->getIntValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMoveTo::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TMoveBy)
|
|
|
|
TMoveBy::TMoveBy(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
:_tag(-1)
|
|
|
|
,_duration(0.0f)
|
|
|
|
,_reverse(false)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TMoveBy::~TMoveBy(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TMoveBy::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMoveBy::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionBy = MoveBy::create(_duration, _pos);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionBy == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
if (_reverse == true)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
ActionInterval* actionByBack = actionBy->reverse();
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction( CCSequence::create(actionBy, actionByBack, nullptr));
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionBy);
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMoveBy::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "x")
|
|
|
|
{
|
|
|
|
_pos.x = DICTOOL->getIntValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "y")
|
|
|
|
{
|
|
|
|
_pos.y = DICTOOL->getIntValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "IsReverse")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value"));
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TMoveBy::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TRotateTo)
|
|
|
|
TRotateTo::TRotateTo(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
: _tag(-1)
|
|
|
|
, _duration(0.0f)
|
|
|
|
, _deltaAngle(0.0f)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TRotateTo::~TRotateTo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRotateTo::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRotateTo::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionTo = RotateTo::create(_duration, _deltaAngle);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionTo == nullptr);
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionTo);
|
2013-12-26 01:17:04 +08:00
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRotateTo::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "DeltaAngle")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_deltaAngle = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRotateTo::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TRotateBy)
|
|
|
|
TRotateBy::TRotateBy(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
: _tag(-1)
|
|
|
|
, _duration(0.0f)
|
|
|
|
, _deltaAngle(0.0f)
|
|
|
|
, _reverse(false)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TRotateBy::~TRotateBy(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TRotateBy::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRotateBy::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionBy = RotateBy::create(_duration, _deltaAngle);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionBy == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
if (_reverse == true)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
ActionInterval* actionByBack = actionBy->reverse();
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction( Sequence::create(actionBy, actionByBack, nullptr));
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionBy);
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRotateBy::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "DeltaAngle")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_deltaAngle = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "IsReverse")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_reverse = (int)(DICTOOL->getIntValue_json(subDict, "value"));
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TRotateBy::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TScaleTo)
|
|
|
|
TScaleTo::TScaleTo(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
: _tag(-1)
|
|
|
|
, _duration(0.0f)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TScaleTo::~TScaleTo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TScaleTo::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TScaleTo::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionTo = ScaleTo::create(_duration, _scale.x, _scale.y);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionTo == nullptr);
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionTo);
|
2013-12-26 01:17:04 +08:00
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TScaleTo::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "ScaleX")
|
|
|
|
{
|
|
|
|
_scale.x = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "ScaleY")
|
|
|
|
{
|
|
|
|
_scale.y = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TScaleTo::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TScaleBy)
|
|
|
|
TScaleBy::TScaleBy(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
: _tag(-1)
|
|
|
|
, _duration(0.0f)
|
|
|
|
, _reverse(false)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TScaleBy::~TScaleBy(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TScaleBy::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TScaleBy::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionBy = ScaleBy::create(_duration, _scale.x, _scale.y);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionBy == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
if (_reverse == true)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
ActionInterval* actionByBack = actionBy->reverse();
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(Sequence::create(actionBy, actionByBack, nullptr));
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionBy);
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TScaleBy::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "ScaleX")
|
|
|
|
{
|
|
|
|
_scale.x = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "ScaleY")
|
|
|
|
{
|
|
|
|
_scale.y = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "IsReverse")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value"));
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TScaleBy::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TSkewTo)
|
|
|
|
TSkewTo::TSkewTo(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
: _tag(-1)
|
|
|
|
, _duration(0.0f)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TSkewTo::~TSkewTo(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TSkewTo::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSkewTo::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionTo = SkewTo::create(_duration, _skew.x, _skew.y);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionTo == nullptr);
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionTo);
|
2013-12-26 01:17:04 +08:00
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSkewTo::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "SkewX")
|
|
|
|
{
|
|
|
|
_skew.x = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "SkewY")
|
|
|
|
{
|
|
|
|
_skew.y = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSkewTo::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TSkewBy)
|
|
|
|
TSkewBy::TSkewBy(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
: _tag(-1)
|
|
|
|
, _duration(0.0f)
|
|
|
|
, _reverse(false)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TSkewBy::~TSkewBy(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TSkewBy::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSkewBy::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
ActionInterval* actionBy = SkewBy::create(_duration, _skew.x, _skew.y);
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(actionBy == nullptr);
|
2014-01-03 01:14:12 +08:00
|
|
|
if (_reverse == true)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
ActionInterval* actionByBack = actionBy->reverse();
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(Sequence::create(actionBy, actionByBack, nullptr));
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
node->runAction(actionBy);
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSkewBy::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_duration = DICTOOL->getFloatValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "SKewX")
|
|
|
|
{
|
|
|
|
_skew.x = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "SKewY")
|
|
|
|
{
|
|
|
|
_skew.y = DICTOOL->getFloatValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "IsReverse")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_reverse = (bool)(DICTOOL->getIntValue_json(subDict, "value"));
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TSkewBy::removeAll()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
node->getActionManager()->removeAllActions();
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(TriggerState)
|
|
|
|
TriggerState::TriggerState(void)
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
_id = -1;
|
|
|
|
_state = 0;
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
TriggerState::~TriggerState(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool TriggerState::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TriggerState::done()
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
TriggerObj *obj = TriggerMng::getInstance()->getTriggerObj(_id);
|
2013-12-26 01:17:04 +08:00
|
|
|
if (obj != nullptr)
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
if (_state == 0)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
2013-12-30 20:57:46 +08:00
|
|
|
obj->setEnabled(false);
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
2014-01-03 01:14:12 +08:00
|
|
|
else if (_state == 1)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
2013-12-30 20:57:46 +08:00
|
|
|
obj->setEnabled(true);
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
2014-01-03 01:14:12 +08:00
|
|
|
else if (_state == 2)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
TriggerMng::getInstance()->removeTriggerObj(_id);
|
2013-12-26 01:17:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void TriggerState::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "ID")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_id = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "State")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_state = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TriggerState::removeAll()
|
|
|
|
{
|
|
|
|
CCLOG("TriggerState::removeAll");
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPLEMENT_CLASS_INFO(ArmaturePlayAction)
|
|
|
|
ArmaturePlayAction::ArmaturePlayAction(void)
|
2014-01-03 01:14:12 +08:00
|
|
|
: _tag(-1)
|
2013-12-26 01:17:04 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ArmaturePlayAction::~ArmaturePlayAction(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ArmaturePlayAction::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArmaturePlayAction::done()
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2014-01-03 01:42:14 +08:00
|
|
|
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
|
|
|
|
CC_BREAK_IF(node == nullptr);
|
|
|
|
ComRender *pRender = (ComRender*)(node->getComponent(_ComName.c_str()));
|
2013-12-26 01:17:04 +08:00
|
|
|
CC_BREAK_IF(pRender == nullptr);
|
|
|
|
Armature *pAr = (Armature *)(pRender->getNode());
|
|
|
|
CC_BREAK_IF(pAr == nullptr);
|
|
|
|
pAr->getAnimation()->play(_aniname.c_str());
|
|
|
|
} while (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArmaturePlayAction::serialize(const rapidjson::Value &val)
|
|
|
|
{
|
|
|
|
int count = DICTOOL->getArrayCount_json(val, "dataitems");
|
|
|
|
for (int i = 0; i < count; ++i)
|
|
|
|
{
|
|
|
|
const rapidjson::Value &subDict = DICTOOL->getSubDictionary_json(val, "dataitems", i);
|
|
|
|
std::string key = DICTOOL->getStringValue_json(subDict, "key");
|
|
|
|
if (key == "Tag")
|
|
|
|
{
|
2014-01-03 01:14:12 +08:00
|
|
|
_tag = DICTOOL->getIntValue_json(subDict, "value");
|
2013-12-26 01:17:04 +08:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "componentName")
|
|
|
|
{
|
|
|
|
_ComName = DICTOOL->getStringValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (key == "AnimationName")
|
|
|
|
{
|
|
|
|
_aniname = DICTOOL->getStringValue_json(subDict, "value");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArmaturePlayAction::removeAll()
|
|
|
|
{
|
|
|
|
CCLOG("ArmaturePlayAction::removeAll");
|
|
|
|
}
|
|
|
|
|
|
|
|
|