2013-06-06 12:02:54 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "CCDatas.h"
|
|
|
|
#include "CCArmature/utils/CCUtilMath.h"
|
|
|
|
|
|
|
|
NS_CC_EXT_BEGIN
|
|
|
|
|
2013-06-07 19:48:31 +08:00
|
|
|
|
|
|
|
CCBaseData::CCBaseData()
|
|
|
|
: x(0.0f)
|
|
|
|
, y(0.0f)
|
|
|
|
, zOrder(0)
|
|
|
|
|
|
|
|
, skewX(0.0f)
|
|
|
|
, skewY(0.0f)
|
|
|
|
, scaleX(1.0f)
|
|
|
|
, scaleY(1.0f)
|
|
|
|
|
|
|
|
, tweenRotate(0.0f)
|
|
|
|
|
|
|
|
, isUseColorInfo(false)
|
|
|
|
, a(255)
|
|
|
|
, r(255)
|
|
|
|
, g(255)
|
|
|
|
, b(255)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CCBaseData::~CCBaseData()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCBaseData::copy(const CCBaseData *node )
|
|
|
|
{
|
|
|
|
x = node->x;
|
|
|
|
y = node->y;
|
|
|
|
zOrder = node->zOrder;
|
|
|
|
|
|
|
|
scaleX = node->scaleX;
|
|
|
|
scaleY = node->scaleY;
|
|
|
|
skewX = node->skewX;
|
|
|
|
skewY = node->skewY;
|
|
|
|
|
|
|
|
tweenRotate = node->tweenRotate;
|
|
|
|
|
|
|
|
isUseColorInfo = node->isUseColorInfo;
|
|
|
|
r = node->r;
|
|
|
|
g = node->g;
|
|
|
|
b = node->b;
|
|
|
|
a = node->a;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCBaseData::subtract(CCBaseData *from, CCBaseData *to)
|
|
|
|
{
|
|
|
|
x = to->x - from->x;
|
|
|
|
y = to->y - from->y;
|
|
|
|
scaleX = to->scaleX - from->scaleX;
|
|
|
|
scaleY = to->scaleY - from->scaleY;
|
|
|
|
skewX = to->skewX - from->skewX;
|
|
|
|
skewY = to->skewY - from->skewY;
|
|
|
|
|
|
|
|
if(from->isUseColorInfo || to->isUseColorInfo)
|
|
|
|
{
|
|
|
|
a = to->a - from->a;
|
|
|
|
r = to->r - from->r;
|
|
|
|
g = to->g - from->g;
|
|
|
|
b = to->b - from->b;
|
|
|
|
|
|
|
|
isUseColorInfo = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (skewX > M_PI)
|
|
|
|
{
|
|
|
|
skewX -= (float)CC_DOUBLE_PI;
|
|
|
|
}
|
|
|
|
if (skewX < -M_PI)
|
|
|
|
{
|
|
|
|
skewX += (float)CC_DOUBLE_PI;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (skewY > M_PI)
|
|
|
|
{
|
|
|
|
skewY -= (float)CC_DOUBLE_PI;
|
|
|
|
}
|
|
|
|
if (skewY < -M_PI)
|
|
|
|
{
|
|
|
|
skewY += (float)CC_DOUBLE_PI;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (to->tweenRotate)
|
|
|
|
{
|
|
|
|
skewX += to->tweenRotate;
|
|
|
|
skewY -= to->tweenRotate;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
const char *CCDisplayData::changeDisplayToTexture(const char *displayName)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
// remove .xxx
|
|
|
|
std::string textureName = displayName;
|
|
|
|
size_t startPos = textureName.find_last_of(".");
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
if(startPos != std::string::npos)
|
|
|
|
{
|
|
|
|
textureName = textureName.erase(startPos);
|
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
return textureName.c_str();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCDisplayData::CCDisplayData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: displayType(CS_DISPLAY_SPRITE)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCDisplayData::~CCDisplayData(void)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCSpriteDisplayData::CCSpriteDisplayData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: displayName("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayType = CS_DISPLAY_SPRITE;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCSpriteDisplayData::~CCSpriteDisplayData()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCSpriteDisplayData::copy(CCSpriteDisplayData *displayData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayName = displayData->displayName;
|
|
|
|
displayType = displayData->displayType;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCArmatureDisplayData::CCArmatureDisplayData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: displayName("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayType = CS_DISPLAY_ARMATURE;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCArmatureDisplayData::~CCArmatureDisplayData()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCArmatureDisplayData::copy(CCArmatureDisplayData *displayData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayName = displayData->displayName;
|
|
|
|
displayType = displayData->displayType;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCParticleDisplayData::CCParticleDisplayData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: plist("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayType = CS_DISPLAY_PARTICLE;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCParticleDisplayData::copy(CCParticleDisplayData *displayData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
plist = displayData->plist;
|
|
|
|
displayType = displayData->displayType;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCShaderDisplayData::CCShaderDisplayData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: vert("")
|
|
|
|
, frag("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayType = CS_DISPLAY_SHADER;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCShaderDisplayData::copy(CCShaderDisplayData *displayData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
vert = displayData->vert;
|
|
|
|
frag = displayData->frag;
|
|
|
|
displayType = displayData->displayType;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCBoneData::CCBoneData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: name("")
|
|
|
|
, parentName("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCBoneData::~CCBoneData(void)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
bool CCBoneData::init()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayDataList.init();
|
|
|
|
return true;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCBoneData::addDisplayData(CCDisplayData *displayData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
displayDataList.addObject(displayData);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCDisplayData *CCBoneData::getDisplayData(int index)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return (CCDisplayData *)displayDataList.objectAtIndex(index);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCArmatureData::CCArmatureData()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCArmatureData::~CCArmatureData()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
bool CCArmatureData::init()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return boneList.init();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCArmatureData::addBoneData(CCBoneData *boneData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
boneDataDic.setObject(boneData, boneData->name);
|
|
|
|
boneList.addObject(boneData);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCBoneData *CCArmatureData::getBoneData(const char *boneName)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return (CCBoneData *)boneDataDic.objectForKey(boneName);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCFrameData::CCFrameData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: duration(1)
|
|
|
|
, tweenEasing(Linear)
|
|
|
|
, displayIndex(0)
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
, m_strMovement("")
|
|
|
|
, m_strEvent("")
|
|
|
|
, m_strSound("")
|
|
|
|
, m_strSoundEffect("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCFrameData::~CCFrameData(void)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCFrameData::copy(CCFrameData *frameData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
CCBaseData::copy(frameData);
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
duration = frameData->duration;
|
|
|
|
displayIndex = frameData->displayIndex;
|
|
|
|
tweenEasing = frameData->tweenEasing;
|
|
|
|
}
|
2013-06-06 12:02:54 +08:00
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCMovementBoneData::CCMovementBoneData()
|
2013-06-07 10:52:32 +08:00
|
|
|
: delay(0.0f)
|
|
|
|
, scale(1.0f)
|
|
|
|
, duration(0)
|
|
|
|
, name("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCMovementBoneData::~CCMovementBoneData(void)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
bool CCMovementBoneData::init()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return frameList.init();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCMovementBoneData::addFrameData(CCFrameData *frameData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
frameList.addObject(frameData);
|
|
|
|
duration += frameData->duration;
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCFrameData *CCMovementBoneData::getFrameData(int index)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return (CCFrameData *)frameList.objectAtIndex(index);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCMovementData::CCMovementData(void)
|
2013-06-07 10:52:32 +08:00
|
|
|
: name("")
|
|
|
|
, duration(0)
|
|
|
|
, durationTo(0)
|
|
|
|
, durationTween(0)
|
|
|
|
, loop(true)
|
|
|
|
, tweenEasing(Linear)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCMovementData::~CCMovementData(void)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCMovementData::addMovementBoneData(CCMovementBoneData *movBoneData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
movBoneDataDic.setObject(movBoneData, movBoneData->name);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCMovementBoneData *CCMovementData::getMovementBoneData(const char *boneName)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return (CCMovementBoneData *)movBoneDataDic.objectForKey(boneName);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCAnimationData::CCAnimationData(void)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCAnimationData::~CCAnimationData(void)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCAnimationData::release()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
CCObject::release();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCAnimationData::retain()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
CCObject::retain();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCAnimationData::addMovement(CCMovementData *movData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
movementDataDic.setObject(movData, movData->name);
|
|
|
|
movementNames.push_back(movData->name);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCMovementData *CCAnimationData::getMovement(const char *movementName)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return (CCMovementData *)movementDataDic.objectForKey(movementName);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
int CCAnimationData::getMovementCount()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return movementDataDic.count();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCContourData::CCContourData()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCContourData::~CCContourData()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
bool CCContourData::init()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return vertexList.init();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCTextureData::CCTextureData()
|
2013-06-07 10:52:32 +08:00
|
|
|
: height(0.0f)
|
|
|
|
, width(0.0f)
|
|
|
|
, pivotX(0.5f)
|
|
|
|
, pivotY(0.5f)
|
|
|
|
, name("")
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCTextureData::~CCTextureData()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
bool CCTextureData::init()
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return contourDataList.init();
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
void CCTextureData::addContourData(CCContourData *contourData)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
contourDataList.addObject(contourData);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
2013-06-06 16:22:58 +08:00
|
|
|
CCContourData *CCTextureData::getContourData(int index)
|
2013-06-06 12:02:54 +08:00
|
|
|
{
|
2013-06-07 10:52:32 +08:00
|
|
|
return (CCContourData *)contourDataList.objectAtIndex(index);
|
2013-06-06 12:02:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-07 10:52:32 +08:00
|
|
|
NS_CC_EXT_END
|