mirror of https://github.com/axmolengine/axmol.git
1. change color json format
2. fix tween easing 3. fix CCBone crate bug
This commit is contained in:
parent
a9054ba14a
commit
25196072f2
|
@ -65,6 +65,7 @@ CC_DEPRECATED_ATTRIBUTE typedef Bone CCBone;
|
|||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureAnimation CCArmatureAnimation;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef Armature CCArmature;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef ArmatureDataManager CCArmatureDataManager;
|
||||
CC_DEPRECATED_ATTRIBUTE typedef TweenType CCTweenType;
|
||||
|
||||
class Armature : public cocos2d::NodeRGBA, public cocos2d::BlendProtocol
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ THE SOFTWARE.
|
|||
|
||||
#define VERSION_COMBINED 0.30f
|
||||
#define VERSION_CHANGE_ROTATION_RANGE 1.0f
|
||||
#define VERSION_COLOR_READING 1.1f
|
||||
|
||||
#ifndef AUTO_ADD_SPRITE_FRAME_NAME_PREFIX
|
||||
#define AUTO_ADD_SPRITE_FRAME_NAME_PREFIX 0
|
||||
|
|
|
@ -90,10 +90,7 @@ Bone::~Bone(void)
|
|||
CC_SAFE_DELETE(_displayManager);
|
||||
CC_SAFE_DELETE(_worldInfo);
|
||||
|
||||
if(_boneData)
|
||||
{
|
||||
_boneData->release();
|
||||
}
|
||||
CC_SAFE_RELEASE_NULL(_boneData);
|
||||
|
||||
CC_SAFE_RELEASE(_childArmature);
|
||||
}
|
||||
|
@ -129,6 +126,9 @@ bool Bone::init(const char *name)
|
|||
CC_SAFE_DELETE(_worldInfo);
|
||||
_worldInfo = new BaseData();
|
||||
|
||||
CC_SAFE_DELETE(_boneData);
|
||||
_boneData = new CCBoneData();
|
||||
|
||||
bRet = true;
|
||||
}
|
||||
while (0);
|
||||
|
@ -140,8 +140,12 @@ void Bone::setBoneData(BoneData *boneData)
|
|||
{
|
||||
CCASSERT(NULL != boneData, "_boneData must not be NULL");
|
||||
|
||||
_boneData = boneData;
|
||||
_boneData->retain();
|
||||
if (_boneData != boneData)
|
||||
{
|
||||
CC_SAFE_RETAIN(boneData);
|
||||
CC_SAFE_RELEASE(_boneData);
|
||||
_boneData = boneData;
|
||||
}
|
||||
|
||||
_name = _boneData->name;
|
||||
_ZOrder = _boneData->zOrder;
|
||||
|
|
|
@ -140,12 +140,8 @@ namespace cocostudio {
|
|||
|
||||
|
||||
float s_PositionReadScale = 1;
|
||||
float s_ContentScale = 1;
|
||||
static float s_FlashToolVersion = VERSION_2_0;
|
||||
static float s_CocoStudioVersion = VERSION_COMBINED;
|
||||
|
||||
std::vector<std::string> DataReaderHelper::_configFileList;
|
||||
std::string DataReaderHelper::_basefilePath = "";
|
||||
|
||||
DataReaderHelper *DataReaderHelper::_dataReaderHelper = NULL;
|
||||
|
||||
|
@ -188,6 +184,8 @@ void DataReaderHelper::loadData()
|
|||
// generate data info
|
||||
DataInfo *pDataInfo = new DataInfo();
|
||||
pDataInfo->asyncStruct = pAsyncStruct;
|
||||
pDataInfo->filename = pAsyncStruct->filename;
|
||||
pDataInfo->baseFilePath = pAsyncStruct->baseFilePath;
|
||||
|
||||
if (pAsyncStruct->configType == DragonBone_XML)
|
||||
{
|
||||
|
@ -280,15 +278,16 @@ void DataReaderHelper::addDataFromFile(const char *filePath)
|
|||
|
||||
|
||||
//! find the base file path
|
||||
_basefilePath = filePath;
|
||||
size_t pos = _basefilePath.find_last_of("/");
|
||||
std::string basefilePath = filePath;
|
||||
size_t pos = basefilePath.find_last_of("/");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
_basefilePath = _basefilePath.substr(0, pos + 1);
|
||||
basefilePath = basefilePath.substr(0, pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_basefilePath = "";
|
||||
basefilePath = "";
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,6 +302,7 @@ void DataReaderHelper::addDataFromFile(const char *filePath)
|
|||
DataInfo dataInfo;
|
||||
dataInfo.filename = filePathStr;
|
||||
dataInfo.asyncStruct = NULL;
|
||||
dataInfo.baseFilePath = basefilePath;
|
||||
|
||||
if (str.compare(".xml") == 0)
|
||||
{
|
||||
|
@ -502,7 +502,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *root = document.RootElement();
|
||||
CCASSERT(root, "XML error or XML is empty.");
|
||||
|
||||
root->QueryFloatAttribute(VERSION, &s_FlashToolVersion);
|
||||
root->QueryFloatAttribute(VERSION, &dataInfo->flashToolVersion);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -512,7 +512,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *armatureXML = armaturesXML->FirstChildElement(ARMATURE);
|
||||
while(armatureXML)
|
||||
{
|
||||
ArmatureData *armatureData = DataReaderHelper::decodeArmature(armatureXML);
|
||||
ArmatureData *armatureData = DataReaderHelper::decodeArmature(armatureXML, dataInfo);
|
||||
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
|
@ -536,7 +536,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *animationXML = animationsXML->FirstChildElement(ANIMATION);
|
||||
while(animationXML)
|
||||
{
|
||||
AnimationData *animationData = DataReaderHelper::decodeAnimation(animationXML);
|
||||
AnimationData *animationData = DataReaderHelper::decodeAnimation(animationXML, dataInfo);
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
_dataReaderHelper->_addDataMutex.lock();
|
||||
|
@ -558,7 +558,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
tinyxml2::XMLElement *textureXML = texturesXML->FirstChildElement(SUB_TEXTURE);
|
||||
while(textureXML)
|
||||
{
|
||||
TextureData *textureData = DataReaderHelper::decodeTexture(textureXML);
|
||||
TextureData *textureData = DataReaderHelper::decodeTexture(textureXML, dataInfo);
|
||||
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
|
@ -574,7 +574,7 @@ void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *data
|
|||
}
|
||||
}
|
||||
|
||||
ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML)
|
||||
ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML, DataInfo *dataInfo)
|
||||
{
|
||||
ArmatureData *armatureData = new ArmatureData();
|
||||
armatureData->init();
|
||||
|
@ -606,7 +606,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
|
|||
}
|
||||
}
|
||||
|
||||
BoneData *boneData = decodeBone(boneXML, parentXML);
|
||||
BoneData *boneData = decodeBone(boneXML, parentXML, dataInfo);
|
||||
armatureData->addBoneData(boneData);
|
||||
boneData->release();
|
||||
|
||||
|
@ -616,7 +616,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
|
|||
return armatureData;
|
||||
}
|
||||
|
||||
BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXml)
|
||||
BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXml, DataInfo *dataInfo)
|
||||
{
|
||||
BoneData *boneData = new BoneData();
|
||||
boneData->init();
|
||||
|
@ -634,7 +634,7 @@ BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::
|
|||
tinyxml2::XMLElement *displayXML = boneXML->FirstChildElement(DISPLAY);
|
||||
while(displayXML)
|
||||
{
|
||||
DisplayData *displayData = decodeBoneDisplay(displayXML);
|
||||
DisplayData *displayData = decodeBoneDisplay(displayXML, dataInfo);
|
||||
boneData->addDisplayData(displayData);
|
||||
displayData->release();
|
||||
|
||||
|
@ -644,7 +644,7 @@ BoneData *DataReaderHelper::decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::
|
|||
return boneData;
|
||||
}
|
||||
|
||||
DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXML)
|
||||
DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXML, DataInfo *dataInfo)
|
||||
{
|
||||
int _isArmature = 0;
|
||||
|
||||
|
@ -687,7 +687,7 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(tinyxml2::XMLElement *displayXM
|
|||
return displayData;
|
||||
}
|
||||
|
||||
AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animationXML)
|
||||
AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animationXML, DataInfo *dataInfo)
|
||||
{
|
||||
AnimationData *aniData = new AnimationData();
|
||||
|
||||
|
@ -701,7 +701,7 @@ AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animation
|
|||
|
||||
while( movementXML )
|
||||
{
|
||||
MovementData *movementData = decodeMovement(movementXML, armatureData);
|
||||
MovementData *movementData = decodeMovement(movementXML, armatureData, dataInfo);
|
||||
aniData->addMovement(movementData);
|
||||
movementData->release();
|
||||
|
||||
|
@ -712,7 +712,7 @@ AnimationData *DataReaderHelper::decodeAnimation(tinyxml2::XMLElement *animation
|
|||
return aniData;
|
||||
}
|
||||
|
||||
MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData)
|
||||
MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData, DataInfo *dataInfo)
|
||||
{
|
||||
MovementData *movementData = new MovementData();
|
||||
|
||||
|
@ -747,12 +747,12 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
{
|
||||
if( movementXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
movementData->tweenEasing = (CCTweenType)tweenEasing;
|
||||
movementData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
movementData->tweenEasing = TWEEN_EASING_MAX;
|
||||
movementData->tweenEasing = Linear;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
}
|
||||
}
|
||||
|
||||
MovementBoneData *moveBoneData = decodeMovementBone(movBoneXml, parentXml, boneData);
|
||||
MovementBoneData *moveBoneData = decodeMovementBone(movBoneXml, parentXml, boneData, dataInfo);
|
||||
movementData->addMovementBoneData(moveBoneData);
|
||||
moveBoneData->release();
|
||||
|
||||
|
@ -799,7 +799,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
}
|
||||
|
||||
|
||||
MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData)
|
||||
MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData, DataInfo *dataInfo)
|
||||
{
|
||||
MovementBoneData *movBoneData = new MovementBoneData();
|
||||
movBoneData->init();
|
||||
|
@ -874,7 +874,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
}
|
||||
}
|
||||
|
||||
FrameData *frameData = decodeFrame( frameXML, parentFrameXML, boneData);
|
||||
FrameData *frameData = decodeFrame( frameXML, parentFrameXML, boneData, dataInfo);
|
||||
movBoneData->addFrameData(frameData);
|
||||
frameData->release();
|
||||
|
||||
|
@ -918,7 +918,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
return movBoneData;
|
||||
}
|
||||
|
||||
FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData)
|
||||
FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo)
|
||||
{
|
||||
float x, y, scale_x, scale_y, skew_x, skew_y = 0;
|
||||
int duration, displayIndex, zOrder, tweenEasing, blendType = 0;
|
||||
|
@ -944,7 +944,7 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
|
||||
|
||||
|
||||
if (s_FlashToolVersion >= VERSION_2_0)
|
||||
if (dataInfo->flashToolVersion >= VERSION_2_0)
|
||||
{
|
||||
if(frameXML->QueryFloatAttribute(A_COCOS2DX_X, &x) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
|
@ -1037,12 +1037,12 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
{
|
||||
if( frameXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
frameData->tweenEasing = (CCTweenType)tweenEasing;
|
||||
frameData->tweenEasing = tweenEasing == 2 ? Sine_EaseInOut : (TweenType)tweenEasing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
frameData->tweenEasing = TWEEN_EASING_MAX;
|
||||
frameData->tweenEasing = Linear;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1052,7 +1052,7 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
* recalculate frame data from parent frame data, use for translate matrix
|
||||
*/
|
||||
BaseData helpNode;
|
||||
if (s_FlashToolVersion >= VERSION_2_0)
|
||||
if (dataInfo->flashToolVersion >= VERSION_2_0)
|
||||
{
|
||||
parentFrameXml->QueryFloatAttribute(A_COCOS2DX_X, &helpNode.x);
|
||||
parentFrameXml->QueryFloatAttribute(A_COCOS2DX_Y, &helpNode.y);
|
||||
|
@ -1076,7 +1076,7 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
return frameData;
|
||||
}
|
||||
|
||||
TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML)
|
||||
TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML, DataInfo *dataInfo)
|
||||
{
|
||||
TextureData *textureData = new TextureData();
|
||||
textureData->init();
|
||||
|
@ -1088,7 +1088,7 @@ TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML)
|
|||
|
||||
float px, py, width, height = 0;
|
||||
|
||||
if(s_FlashToolVersion >= VERSION_2_0)
|
||||
if(dataInfo->flashToolVersion >= VERSION_2_0)
|
||||
{
|
||||
textureXML->QueryFloatAttribute(A_COCOS2D_PIVOT_X, &px);
|
||||
textureXML->QueryFloatAttribute(A_COCOS2D_PIVOT_Y, &py);
|
||||
|
@ -1112,7 +1112,7 @@ TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML)
|
|||
|
||||
while (contourXML)
|
||||
{
|
||||
ContourData *contourData = decodeContour(contourXML);
|
||||
ContourData *contourData = decodeContour(contourXML, dataInfo);
|
||||
textureData->addContourData(contourData);
|
||||
contourData->release();
|
||||
|
||||
|
@ -1122,7 +1122,7 @@ TextureData *DataReaderHelper::decodeTexture(tinyxml2::XMLElement *textureXML)
|
|||
return textureData;
|
||||
}
|
||||
|
||||
ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML)
|
||||
ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo)
|
||||
{
|
||||
ContourData *contourData = new ContourData();
|
||||
contourData->init();
|
||||
|
@ -1153,14 +1153,7 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
JsonDictionary json;
|
||||
json.initWithDescription(fileContent);
|
||||
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
dataInfo->contentScale = json.getItemFloatValue(CONTENT_SCALE, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s_ContentScale = json.getItemFloatValue(CONTENT_SCALE, 1);
|
||||
}
|
||||
dataInfo->contentScale = json.getItemFloatValue(CONTENT_SCALE, 1);
|
||||
|
||||
// Decode armatures
|
||||
int length = json.getArrayItemCount(ARMATURE_DATA);
|
||||
|
@ -1248,7 +1241,7 @@ void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *d
|
|||
std::string plistPath = filePath + ".plist";
|
||||
std::string pngPath = filePath + ".png";
|
||||
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((_basefilePath + plistPath).c_str(), (_basefilePath + pngPath).c_str());
|
||||
ArmatureDataManager::getInstance()->addSpriteFrameFromFile((dataInfo->baseFilePath + plistPath).c_str(), (dataInfo->baseFilePath + pngPath).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1265,7 +1258,7 @@ ArmatureData *DataReaderHelper::decodeArmature(JsonDictionary &json, DataInfo *d
|
|||
armatureData->name = name;
|
||||
}
|
||||
|
||||
s_CocoStudioVersion = armatureData->dataVersion = json.getItemFloatValue(VERSION, 0.1f);
|
||||
dataInfo->cocoStudioVersion = armatureData->dataVersion = json.getItemFloatValue(VERSION, 0.1f);
|
||||
|
||||
int length = json.getArrayItemCount(BONE_DATA);
|
||||
for (int i = 0; i < length; i++)
|
||||
|
@ -1344,16 +1337,8 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json, DataInfo
|
|||
sdd->skinData.skewX = dic->getItemFloatValue(A_SKEW_X, 0);
|
||||
sdd->skinData.skewY = dic->getItemFloatValue(A_SKEW_Y, 0);
|
||||
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
sdd->skinData.x *= dataInfo->contentScale;
|
||||
sdd->skinData.y *= dataInfo->contentScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
sdd->skinData.x *= s_ContentScale;
|
||||
sdd->skinData.y *= s_ContentScale;
|
||||
}
|
||||
sdd->skinData.x *= dataInfo->contentScale;
|
||||
sdd->skinData.y *= dataInfo->contentScale;
|
||||
|
||||
delete dic;
|
||||
}
|
||||
|
@ -1384,7 +1369,7 @@ DisplayData *DataReaderHelper::decodeBoneDisplay(JsonDictionary &json, DataInfo
|
|||
}
|
||||
else
|
||||
{
|
||||
static_cast<ParticleDisplayData *>(displayData)->plist = _basefilePath + plist;
|
||||
static_cast<ParticleDisplayData *>(displayData)->plist = dataInfo->baseFilePath + plist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1435,7 +1420,7 @@ MovementData *DataReaderHelper::decodeMovement(JsonDictionary &json, DataInfo *d
|
|||
movementData->durationTo = json.getItemIntValue(A_DURATION_TO, 0);
|
||||
movementData->duration = json.getItemIntValue(A_DURATION, 0);
|
||||
movementData->scale = json.getItemFloatValue(A_MOVEMENT_SCALE, 1);
|
||||
movementData->tweenEasing = (CCTweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
movementData->tweenEasing = (TweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
|
||||
const char *name = json.getItemStringValue(A_NAME);
|
||||
if(name != NULL)
|
||||
|
@ -1479,7 +1464,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat
|
|||
movementBoneData->addFrameData(frameData);
|
||||
frameData->release();
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
frameData->frameID = movementBoneData->duration;
|
||||
movementBoneData->duration += frameData->duration;
|
||||
|
@ -1489,7 +1474,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat
|
|||
}
|
||||
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
|
||||
{
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
FrameData **frames = (FrameData **)movementBoneData->frameList.data->arr;
|
||||
|
@ -1513,7 +1498,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(JsonDictionary &json, Dat
|
|||
}
|
||||
}
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
if (movementBoneData->frameList.count() > 0)
|
||||
{
|
||||
|
@ -1535,7 +1520,7 @@ FrameData *DataReaderHelper::decodeFrame(JsonDictionary &json, DataInfo *dataInf
|
|||
|
||||
decodeNode(frameData, json, dataInfo);
|
||||
|
||||
frameData->tweenEasing = (CCTweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
frameData->tweenEasing = (TweenType)json.getItemIntValue(A_TWEEN_EASING, Linear);
|
||||
frameData->displayIndex = json.getItemIntValue(A_DISPLAY_INDEX, 0);
|
||||
frameData->blendType = (BlendType)json.getItemIntValue(A_BLEND_TYPE, 0);
|
||||
frameData->isTween = (bool)json.getItemBoolvalue(A_TWEEN_FRAME, true);
|
||||
|
@ -1546,7 +1531,7 @@ FrameData *DataReaderHelper::decodeFrame(JsonDictionary &json, DataInfo *dataInf
|
|||
frameData->strEvent = event;
|
||||
}
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
frameData->duration = json.getItemIntValue(A_DURATION, 1);
|
||||
}
|
||||
|
@ -1617,17 +1602,8 @@ void DataReaderHelper::decodeNode(BaseData *node, JsonDictionary &json, DataInfo
|
|||
node->x = json.getItemFloatValue(A_X, 0) * s_PositionReadScale;
|
||||
node->y = json.getItemFloatValue(A_Y, 0) * s_PositionReadScale;
|
||||
|
||||
if (dataInfo->asyncStruct)
|
||||
{
|
||||
node->x *= dataInfo->contentScale;
|
||||
node->y *= dataInfo->contentScale;
|
||||
}
|
||||
else
|
||||
{
|
||||
node->x *= s_ContentScale;
|
||||
node->y *= s_ContentScale;
|
||||
}
|
||||
|
||||
node->x *= dataInfo->contentScale;
|
||||
node->y *= dataInfo->contentScale;
|
||||
|
||||
node->zOrder = json.getItemIntValue(A_Z, 0);
|
||||
|
||||
|
@ -1636,7 +1612,15 @@ void DataReaderHelper::decodeNode(BaseData *node, JsonDictionary &json, DataInfo
|
|||
node->scaleX = json.getItemFloatValue(A_SCALE_X, 1);
|
||||
node->scaleY = json.getItemFloatValue(A_SCALE_Y, 1);
|
||||
|
||||
JsonDictionary *colorDic = json.getSubItemFromArray(COLOR_INFO, 0);
|
||||
JsonDictionary *colorDic = NULL;
|
||||
if (dataInfo->cocoStudioVersion < VERSION_COLOR_READING)
|
||||
{
|
||||
colorDic = json.getSubItemFromArray(COLOR_INFO, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
colorDic = json.getSubDictionary(COLOR_INFO);
|
||||
}
|
||||
|
||||
if (colorDic)
|
||||
{
|
||||
|
|
|
@ -74,6 +74,9 @@ protected:
|
|||
std::queue<std::string> configFileQueue;
|
||||
float contentScale;
|
||||
std::string filename;
|
||||
std::string baseFilePath;
|
||||
float flashToolVersion;
|
||||
float cocoStudioVersion;
|
||||
} DataInfo;
|
||||
|
||||
public:
|
||||
|
@ -123,29 +126,29 @@ public:
|
|||
/**
|
||||
* Decode Armature Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static ArmatureData *decodeArmature(tinyxml2::XMLElement *armatureXML);
|
||||
static BoneData *decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXML);
|
||||
static DisplayData *decodeBoneDisplay(tinyxml2::XMLElement *displayXML);
|
||||
static ArmatureData *decodeArmature(tinyxml2::XMLElement *armatureXML, DataInfo *dataInfo);
|
||||
static BoneData *decodeBone(tinyxml2::XMLElement *boneXML, tinyxml2::XMLElement *parentXML, DataInfo *dataInfo);
|
||||
static DisplayData *decodeBoneDisplay(tinyxml2::XMLElement *displayXML, DataInfo *dataInfo);
|
||||
|
||||
|
||||
/**
|
||||
* Decode ArmatureAnimation Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static AnimationData *decodeAnimation(tinyxml2::XMLElement *animationXML);
|
||||
static MovementData *decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData);
|
||||
static MovementBoneData *decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData);
|
||||
static FrameData *decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData);
|
||||
static AnimationData *decodeAnimation(tinyxml2::XMLElement *animationXML, DataInfo *dataInfo);
|
||||
static MovementData *decodeMovement(tinyxml2::XMLElement *movementXML, ArmatureData *armatureData, DataInfo *dataInfo);
|
||||
static MovementBoneData *decodeMovementBone(tinyxml2::XMLElement *movBoneXml, tinyxml2::XMLElement *parentXml, BoneData *boneData, DataInfo *dataInfo);
|
||||
static FrameData *decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo);
|
||||
|
||||
|
||||
/**
|
||||
* Decode Texture Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static TextureData *decodeTexture(tinyxml2::XMLElement *textureXML);
|
||||
static TextureData *decodeTexture(tinyxml2::XMLElement *textureXML, DataInfo *dataInfo);
|
||||
|
||||
/**
|
||||
* Decode Contour Datas from xml export from Dragon Bone flash tool
|
||||
*/
|
||||
static ContourData *decodeContour(tinyxml2::XMLElement *contourXML);
|
||||
static ContourData *decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo);
|
||||
|
||||
public:
|
||||
static void addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo = NULL);
|
||||
|
@ -193,7 +196,6 @@ protected:
|
|||
std::queue<AsyncStruct *> *_asyncStructQueue;
|
||||
std::queue<DataInfo *> *_dataQueue;
|
||||
|
||||
static std::string _basefilePath;
|
||||
static std::vector<std::string> _configFileList;
|
||||
|
||||
static DataReaderHelper *_dataReaderHelper;
|
||||
|
|
|
@ -341,7 +341,7 @@ public:
|
|||
public:
|
||||
int frameID;
|
||||
int duration; //! The frame will last duration frames
|
||||
CCTweenType tweenEasing; //! Every frame's tween easing effect
|
||||
TweenType tweenEasing; //! Every frame's tween easing effect
|
||||
bool isTween; //! Whether it's a tween key frame
|
||||
|
||||
/**
|
||||
|
@ -435,7 +435,7 @@ public:
|
|||
* Which tween easing effect the movement use
|
||||
* TWEEN_EASING_MAX : use the value from MovementData get from flash design panel
|
||||
*/
|
||||
CCTweenType tweenEasing;
|
||||
TweenType tweenEasing;
|
||||
|
||||
/**
|
||||
* @brief save movment bone data
|
||||
|
|
|
@ -89,7 +89,7 @@ void ProcessBase::play(void *animation, int durationTo, int durationTween, int
|
|||
* When changing end, m_iTotalFrames will be setted to _durationTween
|
||||
*/
|
||||
_nextFrameIndex = durationTo;
|
||||
_tweenEasing = (CCTweenType)tweenEasing;
|
||||
_tweenEasing = (TweenType)tweenEasing;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -146,7 +146,7 @@ protected:
|
|||
CC_SYNTHESIZE(AnimationType, _loopType, LoopType);
|
||||
|
||||
//! The tween easing effect
|
||||
CC_SYNTHESIZE(CCTweenType, _tweenEasing, TweenEasing);
|
||||
CC_SYNTHESIZE(TweenType, _tweenEasing, TweenEasing);
|
||||
|
||||
//! The animation update speed
|
||||
CC_SYNTHESIZE(float, _animationInternal, AnimationInternal);
|
||||
|
|
|
@ -414,7 +414,7 @@ float Tween::updateFrameData(float currentPercent)
|
|||
{
|
||||
from = to = frames[0];
|
||||
setBetween(from, to);
|
||||
return currentPercent;
|
||||
return _currentPercent;
|
||||
}
|
||||
|
||||
if(playedTime >= frames[length - 1]->frameID)
|
||||
|
@ -422,6 +422,8 @@ float Tween::updateFrameData(float currentPercent)
|
|||
// If _passLastFrame is true and playedTime >= frames[length - 1]->frameID, then do not need to go on.
|
||||
if (_passLastFrame)
|
||||
{
|
||||
from = to = frames[length - 1];
|
||||
setBetween(from, to);
|
||||
return _currentPercent;
|
||||
}
|
||||
_passLastFrame = true;
|
||||
|
@ -472,16 +474,10 @@ float Tween::updateFrameData(float currentPercent)
|
|||
/*
|
||||
* If frame tween easing equal to TWEEN_EASING_MAX, then it will not do tween.
|
||||
*/
|
||||
|
||||
CCTweenType tweenType;
|
||||
|
||||
if ( _frameTweenEasing != TWEEN_EASING_MAX)
|
||||
TweenType tweenType = (_frameTweenEasing != Linear) ? _frameTweenEasing : _tweenEasing;
|
||||
if (tweenType != TWEEN_EASING_MAX && tweenType != Linear)
|
||||
{
|
||||
tweenType = (_tweenEasing == TWEEN_EASING_MAX) ? _frameTweenEasing : _tweenEasing;
|
||||
if (tweenType != TWEEN_EASING_MAX && tweenType != Linear)
|
||||
{
|
||||
currentPercent = TweenFunction::tweenTo(0, 1, currentPercent, 1, tweenType);
|
||||
}
|
||||
currentPercent = TweenFunction::tweenTo(0, 1, currentPercent, 1, tweenType);
|
||||
}
|
||||
|
||||
return currentPercent;
|
||||
|
|
|
@ -131,7 +131,7 @@ protected:
|
|||
|
||||
Bone *_bone; //! A weak reference to the Bone
|
||||
|
||||
CCTweenType _frameTweenEasing; //! Dedermine which tween effect current frame use
|
||||
TweenType _frameTweenEasing; //! Dedermine which tween effect current frame use
|
||||
|
||||
int _betweenDuration; //! Current key frame will last _betweenDuration frames
|
||||
int _totalDuration;
|
||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
float TweenFunction::tweenTo(float from, float change, float time, float duration, CCTweenType tweenType)
|
||||
float TweenFunction::tweenTo(float from, float change, float time, float duration, TweenType tweenType)
|
||||
{
|
||||
float delta = 0;
|
||||
|
||||
|
@ -163,8 +163,8 @@ float TweenFunction::quadEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::quadEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t + b;
|
||||
--t;
|
||||
return -c / 2 * (t * (t - 2) - 1) + b;
|
||||
|
@ -182,8 +182,8 @@ float TweenFunction::cubicEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::cubicEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t * t + b;
|
||||
t -= 2;
|
||||
return c / 2 * (t * t * t + 2) + b;
|
||||
|
@ -201,8 +201,8 @@ float TweenFunction::quartEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::quartEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t * t * t + b;
|
||||
t -= 2;
|
||||
return -c / 2 * (t * t * t * t - 2) + b;
|
||||
|
@ -220,8 +220,8 @@ float TweenFunction::quintEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::quintEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return c / 2 * t * t * t * t * t + b;
|
||||
t -= 2;
|
||||
return c / 2 * (t * t * t * t * t + 2) + b;
|
||||
|
@ -272,8 +272,8 @@ float TweenFunction::circEaseOut(float t, float b, float c, float d)
|
|||
}
|
||||
float TweenFunction::circEaseInOut(float t, float b, float c, float d)
|
||||
{
|
||||
t /= d;
|
||||
if ((t / 2) < 1)
|
||||
t = t/d*2;
|
||||
if ((t) < 1)
|
||||
return -c / 2 * (sqrt(1 - t * t) - 1) + b;
|
||||
t -= 2;
|
||||
return c / 2 * (sqrt(1 - t * t) + 1) + b;
|
||||
|
@ -323,8 +323,8 @@ float TweenFunction::elasticEaseInOut(float t, float b, float c, float d, float
|
|||
float s = 0;
|
||||
if (t == 0)
|
||||
return b;
|
||||
t /= d;
|
||||
if ((t / 2) == 2)
|
||||
t = t/d*2;
|
||||
if ((t) == 2)
|
||||
return b + c;
|
||||
if (!p)
|
||||
p = d * (.3 * 1.5);
|
||||
|
|
|
@ -31,16 +31,15 @@ THE SOFTWARE.
|
|||
|
||||
namespace cocostudio {
|
||||
|
||||
enum CCTweenType
|
||||
enum TweenType
|
||||
{
|
||||
TWEEN_EASING_MIN = -1,
|
||||
|
||||
Linear,
|
||||
|
||||
Sine_EaseIn,
|
||||
Sine_EaseInOut,
|
||||
Sine_EaseOut,
|
||||
|
||||
Sine_EaseInOut,
|
||||
|
||||
Quad_EaseIn,
|
||||
Quad_EaseOut,
|
||||
|
@ -85,7 +84,7 @@ class TweenFunction
|
|||
{
|
||||
public:
|
||||
|
||||
static float tweenTo(float from, float change, float time, float duration, CCTweenType tweenType);
|
||||
static float tweenTo(float from, float change, float time, float duration, TweenType tweenType);
|
||||
|
||||
static float linear(float t, float b, float c, float d);
|
||||
|
||||
|
|
Loading…
Reference in New Issue