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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);//DICTOOL->getIntValue_json(subDict, "value");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "componentName")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_comName = str; //DICTOOL->getStringValue_json(subDict, "value");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "type")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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)
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "x")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_pos.x = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "y")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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-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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "x")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_pos.x = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "y")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_pos.y = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "IsReverse")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "DeltaAngle")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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-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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "DeltaAngle")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_deltaAngle = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "IsReverse")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "ScaleX")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_scale.x = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "ScaleY")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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-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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "ScaleX")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_scale.x = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "ScaleY")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_scale.y = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "IsReverse")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "SkewX")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_skew.x = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "SkewY")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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-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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "Duration")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_duration = atof(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "SkewX")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_skew.x = atof(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "SkewY")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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()
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_id = atoi(str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "State")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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)
|
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);
|
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")
|
|
|
|
{
|
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")
|
|
|
|
{
|
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;
|
2014-07-10 00:45:27 +08:00
|
|
|
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")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_tag = atoi(str);//DICTOOL->getIntValue_json(subDict, "value");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (key == "componentName")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
if (str != nullptr)
|
2014-06-25 11:58:36 +08:00
|
|
|
{
|
|
|
|
_comName = str; //DICTOOL->getStringValue_json(subDict, "value");
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (key == "AnimationName")
|
|
|
|
{
|
2014-07-10 00:45:27 +08:00
|
|
|
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");
|
|
|
|
}
|
|
|
|
|
|
|
|
|