mirror of https://github.com/axmolengine/axmol.git
Change rotation range from(-180 -- 180) to (-infinity -- infinity)
This commit is contained in:
parent
dba7f3eae6
commit
07f72ac1b4
|
@ -271,25 +271,25 @@ 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);
|
||||
|
||||
|
@ -427,7 +427,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)
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -853,6 +853,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 +1427,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)
|
||||
|
|
Loading…
Reference in New Issue