support set tween key

This commit is contained in:
2youyou2 2013-09-17 20:14:08 +08:00
parent 07f72ac1b4
commit 57ec881727
4 changed files with 15 additions and 0 deletions

View File

@ -293,6 +293,12 @@ void Tween::setBetween(FrameData *from, FrameData *to, bool 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;

View File

@ -265,6 +265,7 @@ FrameData::FrameData(void)
: frameID(0)
, duration(1)
, tweenEasing(Linear)
, isTween(true)
, displayIndex(0)
, blendType(BLEND_NORMAL)

View File

@ -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.

View File

@ -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";
@ -1477,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)