mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3657 from 2youyouo2/develop
update armature[ci skip]
This commit is contained in:
commit
e3a34bd5c5
|
@ -271,28 +271,34 @@ void Tween::updateHandler()
|
|||
}
|
||||
}
|
||||
|
||||
void Tween::setBetween(FrameData *from, FrameData *to)
|
||||
void Tween::setBetween(FrameData *from, FrameData *to, bool limit)
|
||||
{
|
||||
do
|
||||
{
|
||||
if(from->displayIndex < 0 && to->displayIndex >= 0)
|
||||
{
|
||||
_from->copy(to);
|
||||
_between->subtract(to, to);
|
||||
_between->subtract(to, to, limit);
|
||||
break;
|
||||
}
|
||||
else if(to->displayIndex < 0 && from->displayIndex >= 0)
|
||||
{
|
||||
_from->copy(from);
|
||||
_between->subtract(to, to);
|
||||
_between->subtract(to, to, limit);
|
||||
break;
|
||||
}
|
||||
|
||||
_from->copy(from);
|
||||
_between->subtract(from, to);
|
||||
_between->subtract(from, to, limit);
|
||||
}
|
||||
while (0);
|
||||
|
||||
if (!from->isTween)
|
||||
{
|
||||
_tweenData->copy(from);
|
||||
_tweenData->isTween = true;
|
||||
}
|
||||
|
||||
arriveKeyFrame(from);
|
||||
}
|
||||
|
||||
|
@ -334,6 +340,11 @@ FrameData *Tween::tweenNodeTo(float percent, FrameData *node)
|
|||
{
|
||||
node = node == NULL ? _tweenData : node;
|
||||
|
||||
if (!_from->isTween)
|
||||
{
|
||||
return _from;
|
||||
}
|
||||
|
||||
node->x = _from->x + percent * _between->x;
|
||||
node->y = _from->y + percent * _between->y;
|
||||
node->scaleX = _from->scaleX + percent * _between->scaleX;
|
||||
|
@ -427,7 +438,7 @@ float Tween::updateFrameData(float currentPercent)
|
|||
|
||||
_frameTweenEasing = from->tweenEasing;
|
||||
|
||||
setBetween(from, to);
|
||||
setBetween(from, to, false);
|
||||
|
||||
}
|
||||
currentPercent = _betweenDuration == 0 ? 0 : (playedTime - _totalDuration) / (float)_betweenDuration;
|
||||
|
|
|
@ -106,7 +106,7 @@ protected:
|
|||
/**
|
||||
* Calculate the between value of _from and _to, and give it to between frame data
|
||||
*/
|
||||
virtual void setBetween(FrameData *from, FrameData *to);
|
||||
virtual void setBetween(FrameData *from, FrameData *to, bool limit = true);
|
||||
|
||||
/**
|
||||
* According to the percent to calculate current FrameData with tween effect
|
||||
|
|
|
@ -74,7 +74,7 @@ void BaseData::copy(const BaseData *node )
|
|||
}
|
||||
|
||||
|
||||
void BaseData::subtract(BaseData *from, BaseData *to)
|
||||
void BaseData::subtract(BaseData *from, BaseData *to, bool limit)
|
||||
{
|
||||
x = to->x - from->x;
|
||||
y = to->y - from->y;
|
||||
|
@ -98,22 +98,25 @@ void BaseData::subtract(BaseData *from, BaseData *to)
|
|||
isUseColorInfo = false;
|
||||
}
|
||||
|
||||
if (skewX > M_PI)
|
||||
{
|
||||
skewX -= (float)CC_DOUBLE_PI;
|
||||
}
|
||||
if (skewX < -M_PI)
|
||||
{
|
||||
skewX += (float)CC_DOUBLE_PI;
|
||||
}
|
||||
if (limit)
|
||||
{
|
||||
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 (skewY > M_PI)
|
||||
{
|
||||
skewY -= (float)CC_DOUBLE_PI;
|
||||
}
|
||||
if (skewY < -M_PI)
|
||||
{
|
||||
skewY += (float)CC_DOUBLE_PI;
|
||||
}
|
||||
}
|
||||
|
||||
if (to->tweenRotate)
|
||||
|
@ -121,6 +124,7 @@ void BaseData::subtract(BaseData *from, BaseData *to)
|
|||
skewX += to->tweenRotate;
|
||||
skewY -= to->tweenRotate;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BaseData::setColor(const Color4B &color)
|
||||
|
@ -261,6 +265,7 @@ FrameData::FrameData(void)
|
|||
: frameID(0)
|
||||
, duration(1)
|
||||
, tweenEasing(Linear)
|
||||
, isTween(true)
|
||||
, displayIndex(0)
|
||||
, blendType(BLEND_NORMAL)
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public:
|
|||
* @param from from BaseData
|
||||
* @param to to BaseData
|
||||
*/
|
||||
virtual void subtract(BaseData *from, BaseData *to);
|
||||
virtual void subtract(BaseData *from, BaseData *to, bool limit);
|
||||
|
||||
virtual void setColor(const Color4B &color);
|
||||
virtual Color4B getColor();
|
||||
|
@ -342,6 +342,7 @@ public:
|
|||
int frameID;
|
||||
int duration; //! The frame will last duration frames
|
||||
CCTweenType tweenEasing; //! Every frame's tween easing effect
|
||||
bool isTween; //! Whether it's a tween key frame
|
||||
|
||||
/**
|
||||
* The current display index when change to this frame.
|
||||
|
|
|
@ -30,7 +30,7 @@ THE SOFTWARE.
|
|||
#include "ExtensionMacros.h"
|
||||
|
||||
#define VERSION_COMBINED 0.30f
|
||||
|
||||
#define VERSION_CHANGE_ROTATION_RANGE 1.0f
|
||||
|
||||
#ifndef AUTO_ADD_SPRITE_FRAME_NAME_PREFIX
|
||||
#define AUTO_ADD_SPRITE_FRAME_NAME_PREFIX 0
|
||||
|
|
|
@ -101,6 +101,7 @@ static const char *A_RED_OFFSET = "rM";
|
|||
static const char *A_GREEN_OFFSET = "gM";
|
||||
static const char *A_BLUE_OFFSET = "bM";
|
||||
static const char *A_COLOR_TRANSFORM = "colorTransform";
|
||||
static const char *A_TWEEN_FRAME = "tweenFrame";
|
||||
//static const char *A_ROTATION = "rotation";
|
||||
//static const char *A_USE_COLOR_INFO = "uci";
|
||||
|
||||
|
@ -853,6 +854,28 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
}
|
||||
|
||||
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
CCFrameData **frames = (CCFrameData **)movBoneData->frameList.data->arr;
|
||||
for (int i = movBoneData->frameList.count() - 1; i >= 0; i--)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX;
|
||||
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY;
|
||||
|
||||
if (difSkewX < -M_PI || difSkewX > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI;
|
||||
}
|
||||
|
||||
if (difSkewY < -M_PI || difSkewY > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
FrameData *frameData = new FrameData();
|
||||
frameData->copy((FrameData *)movBoneData->frameList.getLastObject());
|
||||
|
@ -1405,6 +1428,31 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(cs::JsonDictionary &json)
|
|||
delete dic;
|
||||
}
|
||||
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_CHANGE_ROTATION_RANGE)
|
||||
{
|
||||
//! Change rotation range from (-180 -- 180) to (-infinity -- infinity)
|
||||
CCFrameData **frames = (CCFrameData **)movementBoneData->frameList.data->arr;
|
||||
for (int i = movementBoneData->frameList.count() - 1; i >= 0; i--)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
float difSkewX = frames[i]->skewX - frames[i - 1]->skewX;
|
||||
float difSkewY = frames[i]->skewY - frames[i - 1]->skewY;
|
||||
|
||||
if (difSkewX < -M_PI || difSkewX > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewX = difSkewX < 0 ? frames[i - 1]->skewX - 2 * M_PI : frames[i - 1]->skewX + 2 * M_PI;
|
||||
}
|
||||
|
||||
if (difSkewY < -M_PI || difSkewY > M_PI)
|
||||
{
|
||||
frames[i - 1]->skewY = difSkewY < 0 ? frames[i - 1]->skewY - 2 * M_PI : frames[i - 1]->skewY + 2 * M_PI;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (s_CocoStudioVersion < VERSION_COMBINED)
|
||||
{
|
||||
if (movementBoneData->frameList.count() > 0)
|
||||
|
@ -1430,6 +1478,7 @@ FrameData *DataReaderHelper::decodeFrame(cs::JsonDictionary &json)
|
|||
frameData->tweenEasing = (CCTweenType)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);
|
||||
|
||||
const char *event = json.getItemStringValue(A_EVENT);
|
||||
if (event != NULL)
|
||||
|
|
Loading…
Reference in New Issue