axmol/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/TriggerCode/acts.cpp

1237 lines
25 KiB
C++
Raw Normal View History

2013-12-26 01:17:04 +08:00
#include "acts.h"
using namespace cocos2d;
using namespace cocostudio;
IMPLEMENT_CLASS_INFO(PlayMusic)
PlayMusic::PlayMusic(void)
:_tag(-1)
2013-12-26 01:17:04 +08:00
{
}
PlayMusic::~PlayMusic(void)
{
}
bool PlayMusic::init()
{
return true;
}
void PlayMusic::done()
{
do
{
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);
if (_type == 0)
2013-12-26 01:17:04 +08:00
{
audio->playBackgroundMusic();
}
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")
{
_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")
{
_type = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
}
}
2014-06-25 11:58:36 +08:00
void PlayMusic::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);//DICTOOL->getIntValue_json(subDict, "value");
}
}
else if (key == "componentName")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_comName = str; //DICTOOL->getStringValue_json(subDict, "value");
}
}
else if (key == "type")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_type = atoi(str); //DICTOOL->getIntValue_json(subDict, "value");
}
}
}
}
2013-12-26 01:17:04 +08:00
void PlayMusic::removeAll()
{
}
IMPLEMENT_CLASS_INFO(TMoveTo)
TMoveTo::TMoveTo(void)
:_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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionTo = MoveTo::create(_duration, _pos);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionTo == nullptr);
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_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;
}
}
}
2014-06-25 11:58:36 +08:00
void TMoveTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "x")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_pos.x = atof(str);
}
}
else if (key == "y")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_pos.y = atoi(str);
}
}
}
}
2013-12-26 01:17:04 +08:00
void TMoveTo::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TMoveBy)
TMoveBy::TMoveBy(void)
:_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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionBy = MoveBy::create(_duration, _pos);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionBy == nullptr);
if (_reverse == true)
2013-12-26 01:17:04 +08:00
{
ActionInterval* actionByBack = actionBy->reverse();
node->runAction( CCSequence::create(actionBy, actionByBack, nullptr));
2013-12-26 01:17:04 +08:00
}
else
{
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_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-03-24 10:12:40 +08:00
_reverse = DICTOOL->getIntValue_json(subDict, "value") ? true : false;
2013-12-26 01:17:04 +08:00
continue;
}
}
}
2014-06-25 11:58:36 +08:00
void TMoveBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "x")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_pos.x = atof(str);
}
}
else if (key == "y")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_pos.y = atof(str);
}
}
else if (key == "IsReverse")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_reverse = atoi(str)!=0?true:false; //DICTOOL->getIntValue_json(subDict, "value") != 0? true: false;
}
}
}
}
2013-12-26 01:17:04 +08:00
void TMoveBy::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TRotateTo)
TRotateTo::TRotateTo(void)
: _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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionTo = RotateTo::create(_duration, _deltaAngle);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionTo == nullptr);
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_duration = DICTOOL->getFloatValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "DeltaAngle")
{
_deltaAngle = DICTOOL->getFloatValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
}
}
2014-06-25 11:58:36 +08:00
void TRotateTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "DeltaAngle")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_deltaAngle = atof(str);
}
}
}
}
2013-12-26 01:17:04 +08:00
void TRotateTo::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TRotateBy)
TRotateBy::TRotateBy(void)
: _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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionBy = RotateBy::create(_duration, _deltaAngle);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionBy == nullptr);
if (_reverse == true)
2013-12-26 01:17:04 +08:00
{
ActionInterval* actionByBack = actionBy->reverse();
node->runAction( Sequence::create(actionBy, actionByBack, nullptr));
2013-12-26 01:17:04 +08:00
}
else
{
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_duration = DICTOOL->getFloatValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "DeltaAngle")
{
_deltaAngle = DICTOOL->getFloatValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "IsReverse")
{
2014-03-24 10:12:40 +08:00
_reverse = (DICTOOL->getIntValue_json(subDict, "value")) ? true : false;
2013-12-26 01:17:04 +08:00
continue;
}
}
}
2014-06-25 11:58:36 +08:00
void TRotateBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "DeltaAngle")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_deltaAngle = atof(str);
}
}
else if (key == "IsReverse")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_reverse = atoi(str)!=0?true:false;
}
}
}
}
2013-12-26 01:17:04 +08:00
void TRotateBy::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TScaleTo)
TScaleTo::TScaleTo(void)
: _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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionTo = ScaleTo::create(_duration, _scale.x, _scale.y);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionTo == nullptr);
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_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;
}
}
}
2014-06-25 11:58:36 +08:00
void TScaleTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "ScaleX")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_scale.x = atof(str);
}
}
else if (key == "ScaleY")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_scale.y = atof(str);
}
}
}
}
2013-12-26 01:17:04 +08:00
void TScaleTo::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TScaleBy)
TScaleBy::TScaleBy(void)
: _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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionBy = ScaleBy::create(_duration, _scale.x, _scale.y);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionBy == nullptr);
if (_reverse == true)
2013-12-26 01:17:04 +08:00
{
ActionInterval* actionByBack = actionBy->reverse();
node->runAction(Sequence::create(actionBy, actionByBack, nullptr));
2013-12-26 01:17:04 +08:00
}
else
{
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_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-03-24 10:12:40 +08:00
_reverse = (DICTOOL->getIntValue_json(subDict, "value")) ? true : false;
2013-12-26 01:17:04 +08:00
continue;
}
}
}
2014-06-25 11:58:36 +08:00
void TScaleBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "ScaleX")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_scale.x = atof(str);
}
}
else if (key == "ScaleY")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_scale.y = atof(str);
}
}
else if (key == "IsReverse")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_reverse = atoi(str)!=0?true:false; //DICTOOL->getIntValue_json(subDict, "value")!= 0? true:false;
}
continue;
}
}
}
2013-12-26 01:17:04 +08:00
void TScaleBy::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TSkewTo)
TSkewTo::TSkewTo(void)
: _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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionTo = SkewTo::create(_duration, _skew.x, _skew.y);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionTo == nullptr);
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_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;
}
}
}
2014-06-25 11:58:36 +08:00
void TSkewTo::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "SkewX")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_skew.x = atof(str);
}
}
else if (key == "SkewY")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_skew.y = atof(str);
}
}
}
}
2013-12-26 01:17:04 +08:00
void TSkewTo::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TSkewBy)
TSkewBy::TSkewBy(void)
: _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
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
ActionInterval* actionBy = SkewBy::create(_duration, _skew.x, _skew.y);
2013-12-26 01:17:04 +08:00
CC_BREAK_IF(actionBy == nullptr);
if (_reverse == true)
2013-12-26 01:17:04 +08:00
{
ActionInterval* actionByBack = actionBy->reverse();
node->runAction(Sequence::create(actionBy, actionByBack, nullptr));
2013-12-26 01:17:04 +08:00
}
else
{
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "Duration")
{
_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-03-24 10:12:40 +08:00
_reverse = DICTOOL->getIntValue_json(subDict, "value") ? true : false;
2013-12-26 01:17:04 +08:00
}
}
}
2014-06-25 11:58:36 +08:00
void TSkewBy::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);
}
}
else if (key == "Duration")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_duration = atof(str);
}
}
else if (key == "SkewX")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_skew.x = atof(str);
}
}
else if (key == "SkewY")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_skew.y = atof(str);
}
}
else if (key == "IsReverse")
{
_reverse = atoi(str)!=0?true:false; //DICTOOL->getIntValue_json(subDict, "value")!= 0? true:false;
}
}
}
2013-12-26 01:17:04 +08:00
void TSkewBy::removeAll()
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
node->getActionManager()->removeAllActions();
2013-12-26 01:17:04 +08:00
}
IMPLEMENT_CLASS_INFO(TriggerState)
TriggerState::TriggerState(void)
{
_id = -1;
_state = 0;
2013-12-26 01:17:04 +08:00
}
TriggerState::~TriggerState(void)
{
}
bool TriggerState::init()
{
return true;
}
void TriggerState::done()
{
TriggerObj *obj = TriggerMng::getInstance()->getTriggerObj(_id);
2013-12-26 01:17:04 +08:00
if (obj != nullptr)
{
if (_state == 0)
2013-12-26 01:17:04 +08:00
{
obj->setEnabled(false);
2013-12-26 01:17:04 +08:00
}
else if (_state == 1)
2013-12-26 01:17:04 +08:00
{
obj->setEnabled(true);
2013-12-26 01:17:04 +08:00
}
else if (_state == 2)
2013-12-26 01:17:04 +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")
{
_id = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "State")
{
_state = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
}
}
2014-06-25 11:58:36 +08:00
void TriggerState::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "ID")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_id = atoi(str);
}
}
else if (key == "State")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_state = atoi(str);
}
}
}
}
2013-12-26 01:17:04 +08:00
void TriggerState::removeAll()
{
CCLOG("TriggerState::removeAll");
}
IMPLEMENT_CLASS_INFO(ArmaturePlayAction)
ArmaturePlayAction::ArmaturePlayAction(void)
: _tag(-1)
2013-12-26 01:17:04 +08:00
{
}
ArmaturePlayAction::~ArmaturePlayAction(void)
{
}
bool ArmaturePlayAction::init()
{
return true;
}
void ArmaturePlayAction::done()
{
do
{
Node *node = SceneReader::getInstance()->getNodeByTag(_tag);
CC_BREAK_IF(node == nullptr);
2014-06-25 11:58:36 +08:00
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")
{
_tag = DICTOOL->getIntValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "componentName")
{
2014-06-25 11:58:36 +08:00
_comName = DICTOOL->getStringValue_json(subDict, "value");
2013-12-26 01:17:04 +08:00
continue;
}
else if (key == "AnimationName")
{
_aniname = DICTOOL->getStringValue_json(subDict, "value");
continue;
}
}
}
2014-06-25 11:58:36 +08:00
void ArmaturePlayAction::serialize(cocostudio::CocoLoader *pCocoLoader, cocostudio::stExpCocoNode *pCocoNode)
{
int length = pCocoNode->GetChildNum();
int count = 0;
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemsArray = pCocoNode->GetChildArray(pCocoLoader);
2014-06-25 11:58:36 +08:00
std::string key;
const char *str = nullptr;
2014-06-25 11:58:36 +08:00
for (int i = 0; i < length; ++i)
{
count = pDataItemsArray[i].GetChildNum();
2014-07-01 16:31:17 +08:00
stExpCocoNode *pDataItemArray = pDataItemsArray[i].GetChildArray(pCocoLoader);
key = pDataItemArray[0].GetValue(pCocoLoader);
str = pDataItemArray[1].GetValue(pCocoLoader);
2014-06-25 11:58:36 +08:00
if (key == "Tag")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_tag = atoi(str);//DICTOOL->getIntValue_json(subDict, "value");
}
}
else if (key == "componentName")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_comName = str; //DICTOOL->getStringValue_json(subDict, "value");
}
}
else if (key == "AnimationName")
{
if (str != nullptr)
2014-06-25 11:58:36 +08:00
{
_aniname = str; //DICTOOL->getStringValue_json(subDict, "value");
}
}
}
}
2013-12-26 01:17:04 +08:00
void ArmaturePlayAction::removeAll()
{
CCLOG("ArmaturePlayAction::removeAll");
}