mirror of https://github.com/axmolengine/axmol.git
Animation easing.
This commit is contained in:
parent
64c45fa3ca
commit
80ad7bbee8
|
@ -574,6 +574,12 @@ Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::B
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -591,6 +597,12 @@ Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -609,6 +621,12 @@ Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::Sca
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -627,6 +645,12 @@ Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffe
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -644,6 +668,12 @@ Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::Col
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -701,6 +731,12 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -711,9 +747,7 @@ Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::Eve
|
|||
std::string event = flatbuffers->value()->c_str();
|
||||
|
||||
if (event != "")
|
||||
frame->setEvent(event);
|
||||
|
||||
CCLOG("event = %s", event.c_str());
|
||||
frame->setEvent(event);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
@ -721,6 +755,12 @@ Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::Eve
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -741,23 +781,29 @@ Frame* ActionTimelineCache::loadAlphaFrameWithFlatBuffers(const flatbuffers::Int
|
|||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadAnchorPointFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers)
|
||||
Frame* ActionTimelineCache::loadAnchorPointFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers)
|
||||
{
|
||||
AnchorPointFrame* frame = AnchorPointFrame::create();
|
||||
|
||||
auto f_scale = flatbuffers->scale();
|
||||
Vec2 scale(f_scale->scaleX(), f_scale->scaleY());
|
||||
frame->setAnchorPoint(scale);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
AnchorPointFrame* frame = AnchorPointFrame::create();
|
||||
|
||||
auto f_scale = flatbuffers->scale();
|
||||
Vec2 scale(f_scale->scaleX(), f_scale->scaleY());
|
||||
frame->setAnchorPoint(scale);
|
||||
|
||||
int frameIndex = flatbuffers->frameIndex();
|
||||
frame->setFrameIndex(frameIndex);
|
||||
|
||||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
return frame;
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers)
|
||||
{
|
||||
ZOrderFrame* frame = ZOrderFrame::create();
|
||||
|
@ -772,6 +818,12 @@ Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::In
|
|||
bool tween = flatbuffers->tween() != 0;
|
||||
frame->setTween(tween);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
|
@ -797,9 +849,33 @@ Frame* ActionTimelineCache::loadInnerActionFrameWithFlatBuffers(const flatbuffer
|
|||
frame->setEnterWithName(true);
|
||||
frame->setAnimationName(currentAnimationFrame);
|
||||
|
||||
auto easingData = flatbuffers->easingData();
|
||||
if (easingData)
|
||||
{
|
||||
loadEasingDataWithFlatBuffers(frame, easingData);
|
||||
}
|
||||
|
||||
return frame;
|
||||
}
|
||||
|
||||
void ActionTimelineCache::loadEasingDataWithFlatBuffers(cocostudio::timeline::Frame *frame,
|
||||
const flatbuffers::EasingData *flatbuffers)
|
||||
{
|
||||
int type = flatbuffers->type();
|
||||
frame->setTweenType((cocos2d::tweenfunc::TweenType)type);
|
||||
auto points = flatbuffers->points();
|
||||
if (points)
|
||||
{
|
||||
for (auto it = points->begin(); it != points->end(); ++it)
|
||||
{
|
||||
std::vector<float> easings;
|
||||
easings.push_back(it->x());
|
||||
easings.push_back(it->y());
|
||||
frame->setEasingParams(easings);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(const std::string& fileName)
|
||||
{
|
||||
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
||||
|
|
|
@ -46,6 +46,7 @@ namespace flatbuffers
|
|||
struct IntFrame;
|
||||
struct BoolFrame;
|
||||
struct InnerActionFrame;
|
||||
struct EasingData;
|
||||
}
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
@ -115,6 +116,8 @@ protected:
|
|||
Frame* loadAnchorPointFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
|
||||
Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
|
||||
Frame* loadInnerActionFrameWithFlatBuffers (const flatbuffers::InnerActionFrame* flatbuffers);
|
||||
|
||||
void loadEasingDataWithFlatBuffers(Frame* frame, const flatbuffers::EasingData* flatbuffers);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -38,14 +38,17 @@ NS_TIMELINE_BEGIN
|
|||
Frame::Frame()
|
||||
: _frameIndex(0)
|
||||
, _tween(true)
|
||||
, _tweenType(TweenType::Linear)
|
||||
, _enterWhenPassed(false)
|
||||
, _timeline(nullptr)
|
||||
, _node(nullptr)
|
||||
{
|
||||
_easingParam.clear();
|
||||
}
|
||||
|
||||
Frame::~Frame()
|
||||
{
|
||||
_easingParam.clear();
|
||||
}
|
||||
|
||||
void Frame::emitEvent()
|
||||
|
@ -60,6 +63,37 @@ void Frame::cloneProperty(Frame* frame)
|
|||
{
|
||||
_frameIndex = frame->getFrameIndex();
|
||||
_tween = frame->isTween();
|
||||
|
||||
_tweenType = frame->getTweenType();
|
||||
setEasingParams(frame->getEasingParams());
|
||||
}
|
||||
|
||||
void Frame::apply(float percent)
|
||||
{
|
||||
if (!_tween)
|
||||
return;
|
||||
|
||||
float tweenpercent = percent;
|
||||
if ( _tweenType != tweenfunc::TWEEN_EASING_MAX && _tweenType != tweenfunc::Linear)
|
||||
{
|
||||
tweenpercent = tweenPercent(tweenpercent);
|
||||
}
|
||||
onApply(tweenpercent);
|
||||
}
|
||||
|
||||
float Frame::tweenPercent(float percent)
|
||||
{
|
||||
return tweenfunc::tweenTo(percent, _tweenType, _easingParam.data());
|
||||
}
|
||||
|
||||
void Frame::setEasingParams(const std::vector<float>& easingParams)
|
||||
{
|
||||
_easingParam.assign(easingParams.begin(), easingParams.end());
|
||||
}
|
||||
|
||||
const std::vector<float>& Frame::getEasingParams() const
|
||||
{
|
||||
return _easingParam;
|
||||
}
|
||||
|
||||
|
||||
|
@ -83,10 +117,7 @@ VisibleFrame::VisibleFrame()
|
|||
|
||||
void VisibleFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node)
|
||||
{
|
||||
_node->setVisible(_visible);
|
||||
}
|
||||
_node->setVisible(_visible);
|
||||
}
|
||||
|
||||
|
||||
|
@ -173,11 +204,6 @@ RotationFrame::RotationFrame()
|
|||
|
||||
void RotationFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_node->setRotation(_rotation);
|
||||
|
||||
if(_tween)
|
||||
|
@ -186,9 +212,9 @@ void RotationFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void RotationFrame::apply(float percent)
|
||||
void RotationFrame::onApply(float percent)
|
||||
{
|
||||
if (_node && _tween && _betwennRotation != 0)
|
||||
if (_betwennRotation != 0)
|
||||
{
|
||||
float rotation = _rotation + percent * _betwennRotation;
|
||||
_node->setRotation(rotation);
|
||||
|
@ -228,11 +254,6 @@ SkewFrame::SkewFrame()
|
|||
|
||||
void SkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_node->setSkewX(_skewX);
|
||||
_node->setSkewY(_skewY);
|
||||
|
||||
|
@ -243,9 +264,9 @@ void SkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void SkewFrame::apply(float percent)
|
||||
void SkewFrame::onApply(float percent)
|
||||
{
|
||||
if (_node && _tween && (_betweenSkewX != 0 || _betweenSkewY != 0))
|
||||
if (_betweenSkewX != 0 || _betweenSkewY != 0)
|
||||
{
|
||||
float skewx = _skewX + percent * _betweenSkewX;
|
||||
float skewy = _skewY + percent * _betweenSkewY;
|
||||
|
@ -288,11 +309,6 @@ RotationSkewFrame::RotationSkewFrame()
|
|||
|
||||
void RotationSkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_node->setRotationSkewX(_skewX);
|
||||
_node->setRotationSkewY(_skewY);
|
||||
|
||||
|
@ -303,9 +319,9 @@ void RotationSkewFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void RotationSkewFrame::apply(float percent)
|
||||
void RotationSkewFrame::onApply(float percent)
|
||||
{
|
||||
if (_node && _tween && (_betweenSkewX != 0 || _betweenSkewY != 0))
|
||||
if (_betweenSkewX != 0 || _betweenSkewY != 0)
|
||||
{
|
||||
float skewx = _skewX + percent * _betweenSkewX;
|
||||
float skewy = _skewY + percent * _betweenSkewY;
|
||||
|
@ -347,11 +363,6 @@ PositionFrame::PositionFrame()
|
|||
|
||||
void PositionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_node->setPosition(_position);
|
||||
|
||||
if(_tween)
|
||||
|
@ -361,9 +372,9 @@ void PositionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void PositionFrame::apply(float percent)
|
||||
void PositionFrame::onApply(float percent)
|
||||
{
|
||||
if (_node && _tween && (_betweenX != 0 || _betweenY != 0))
|
||||
if (_betweenX != 0 || _betweenY != 0)
|
||||
{
|
||||
Point p;
|
||||
p.x = _position.x + _betweenX * percent;
|
||||
|
@ -405,11 +416,6 @@ ScaleFrame::ScaleFrame()
|
|||
|
||||
void ScaleFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_node->setScaleX(_scaleX);
|
||||
_node->setScaleY(_scaleY);
|
||||
|
||||
|
@ -420,9 +426,9 @@ void ScaleFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void ScaleFrame::apply(float percent)
|
||||
void ScaleFrame::onApply(float percent)
|
||||
{
|
||||
if (_node && _tween && (_betweenScaleX != 0 || _betweenScaleY != 0))
|
||||
if (_betweenScaleX != 0 || _betweenScaleY != 0)
|
||||
{
|
||||
float scaleX = _scaleX + _betweenScaleX * percent;
|
||||
float scaleY = _scaleY + _betweenScaleY * percent;
|
||||
|
@ -464,11 +470,6 @@ AnchorPointFrame::AnchorPointFrame()
|
|||
|
||||
void AnchorPointFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_node->setAnchorPoint(_anchorPoint);
|
||||
}
|
||||
|
||||
|
@ -505,19 +506,14 @@ InnerActionFrame::InnerActionFrame()
|
|||
, _startFrameIndex(0)
|
||||
, _endFrameIndex(0)
|
||||
, _singleFrameIndex(0)
|
||||
, _animationName("")
|
||||
, _enterWithName(false)
|
||||
, _animationName("")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto innerActiontimeline = static_cast<ActionTimeline*>(_node->getActionByTag(_node->getTag()));
|
||||
if( nullptr == innerActiontimeline)
|
||||
return;
|
||||
|
@ -633,20 +629,20 @@ ColorFrame* ColorFrame::create()
|
|||
}
|
||||
|
||||
ColorFrame::ColorFrame()
|
||||
: _color(Color3B(255, 255, 255))
|
||||
: _alpha(255)
|
||||
, _color(Color3B(255, 255, 255))
|
||||
{
|
||||
}
|
||||
|
||||
void ColorFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_node->setOpacity(_alpha);
|
||||
_node->setColor(_color);
|
||||
|
||||
if(_tween)
|
||||
{
|
||||
_betweenAlpha = static_cast<ColorFrame*>(nextFrame)->_alpha - _alpha;
|
||||
|
||||
const Color3B& color = static_cast<ColorFrame*>(nextFrame)->_color;
|
||||
_betweenRed = color.r - _color.r;
|
||||
_betweenGreen = color.g - _color.g;
|
||||
|
@ -654,15 +650,18 @@ void ColorFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void ColorFrame::apply(float percent)
|
||||
void ColorFrame::onApply(float percent)
|
||||
{
|
||||
if (_node && _tween && (_betweenRed != 0 || _betweenGreen != 0 || _betweenBlue != 0))
|
||||
if (_betweenAlpha !=0 || _betweenRed != 0 || _betweenGreen != 0 || _betweenBlue != 0)
|
||||
{
|
||||
GLubyte alpha = _alpha + _betweenAlpha * percent;
|
||||
|
||||
Color3B color;
|
||||
color.r = _color.r+ _betweenRed * percent;
|
||||
color.g = _color.g+ _betweenGreen * percent;
|
||||
color.b = _color.b+ _betweenBlue * percent;
|
||||
|
||||
_node->setOpacity(alpha);
|
||||
_node->setColor(color);
|
||||
}
|
||||
}
|
||||
|
@ -670,6 +669,7 @@ void ColorFrame::apply(float percent)
|
|||
Frame* ColorFrame::clone()
|
||||
{
|
||||
ColorFrame* frame = ColorFrame::create();
|
||||
frame->setAlpha(_alpha);
|
||||
frame->setColor(_color);
|
||||
|
||||
frame->cloneProperty(this);
|
||||
|
@ -697,11 +697,6 @@ AlphaFrame::AlphaFrame()
|
|||
|
||||
void AlphaFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
||||
{
|
||||
if (_node == nullptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_node->setOpacity(_alpha);
|
||||
|
||||
if (_tween)
|
||||
|
@ -710,13 +705,10 @@ void AlphaFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
void AlphaFrame::apply(float percent)
|
||||
void AlphaFrame::onApply(float percent)
|
||||
{
|
||||
if (_node && _tween)
|
||||
{
|
||||
GLubyte alpha = _alpha + _betweenAlpha * percent;
|
||||
_node->setOpacity(alpha);
|
||||
}
|
||||
GLubyte alpha = _alpha + _betweenAlpha * percent;
|
||||
_node->setOpacity(alpha);
|
||||
}
|
||||
|
||||
Frame* AlphaFrame::clone()
|
||||
|
|
|
@ -30,9 +30,11 @@ THE SOFTWARE.
|
|||
#include "base/CCVector.h"
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/CCTweenFunction.h"
|
||||
#include "CCTimelineMacro.h"
|
||||
#include "cocostudio/CocosStudioExport.h"
|
||||
|
||||
using namespace cocos2d::tweenfunc;
|
||||
|
||||
NS_TIMELINE_BEGIN
|
||||
|
||||
|
@ -55,15 +57,26 @@ public:
|
|||
virtual void setTween(bool tween) { _tween = tween; }
|
||||
virtual bool isTween() const { return _tween; }
|
||||
|
||||
virtual void setTweenType(const TweenType& tweenType) { _tweenType = tweenType; }
|
||||
virtual TweenType getTweenType() const { return _tweenType; }
|
||||
|
||||
// !to make easing with params, need setTweenType(TweenType::CUSTOM_EASING)
|
||||
virtual void setEasingParams(const std::vector<float>& easingParams);
|
||||
virtual const std::vector<float>& getEasingParams() const;
|
||||
|
||||
virtual bool isEnterWhenPassed() { return _enterWhenPassed; }
|
||||
|
||||
virtual void onEnter(Frame* nextFrame, int currentFrameIndex) = 0;
|
||||
virtual void apply(float percent) {}
|
||||
virtual void apply(float percent);
|
||||
|
||||
virtual Frame* clone() = 0;
|
||||
protected:
|
||||
Frame();
|
||||
virtual ~Frame();
|
||||
virtual void onApply(float percent){}
|
||||
|
||||
//update percent depends _tweenType, and return the Calculated percent
|
||||
virtual float tweenPercent(float percent);
|
||||
|
||||
virtual void emitEvent();
|
||||
virtual void cloneProperty(Frame* frame);
|
||||
|
@ -71,12 +84,14 @@ protected:
|
|||
|
||||
unsigned int _frameIndex;
|
||||
bool _tween;
|
||||
TweenType _tweenType;
|
||||
std::vector<float> _easingParam;
|
||||
bool _enterWhenPassed;
|
||||
|
||||
Timeline* _timeline;
|
||||
cocos2d::Node* _node;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
class CC_STUDIO_DLL VisibleFrame : public Frame
|
||||
{
|
||||
|
@ -103,7 +118,7 @@ public:
|
|||
|
||||
TextureFrame();
|
||||
|
||||
virtual void setNode(cocos2d::Node* node) override;
|
||||
virtual void setNode(cocos2d::Node* node);
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual Frame* clone() override;
|
||||
|
@ -124,13 +139,14 @@ public:
|
|||
RotationFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setRotation(float rotation) { _rotation = rotation; }
|
||||
inline float getRotation() const { return _rotation; }
|
||||
|
||||
protected:
|
||||
virtual void onApply(float percent) override;
|
||||
|
||||
float _rotation;
|
||||
float _betwennRotation;
|
||||
};
|
||||
|
@ -143,7 +159,6 @@ public:
|
|||
SkewFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setSkewX(float skewx) { _skewX = skewx; }
|
||||
|
@ -153,6 +168,8 @@ public:
|
|||
inline float getSkewY() const { return _skewY; }
|
||||
|
||||
protected:
|
||||
virtual void onApply(float percent) override;
|
||||
|
||||
float _skewX;
|
||||
float _skewY;
|
||||
float _betweenSkewX;
|
||||
|
@ -168,8 +185,10 @@ public:
|
|||
RotationSkewFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
protected:
|
||||
virtual void onApply(float percent) override;
|
||||
};
|
||||
|
||||
|
||||
|
@ -181,7 +200,6 @@ public:
|
|||
PositionFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setPosition(const cocos2d::Point& position) { _position = position; }
|
||||
|
@ -193,6 +211,8 @@ public:
|
|||
inline float getX() const { return _position.x; }
|
||||
inline float getY() const { return _position.y; }
|
||||
protected:
|
||||
virtual void onApply(float percent) override;
|
||||
|
||||
cocos2d::Point _position;
|
||||
float _betweenX;
|
||||
float _betweenY;
|
||||
|
@ -207,7 +227,6 @@ public:
|
|||
ScaleFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setScale(float scale) { _scaleX = scale; _scaleY = scale; }
|
||||
|
@ -219,6 +238,8 @@ public:
|
|||
inline float getScaleY() const { return _scaleY; }
|
||||
|
||||
protected:
|
||||
virtual void onApply(float percent) override;
|
||||
|
||||
float _scaleX;
|
||||
float _scaleY;
|
||||
float _betweenScaleX;
|
||||
|
@ -296,20 +317,21 @@ public:
|
|||
ColorFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
/** @deprecated Use method setAlpha() and getAlpha() of AlphaFrame instead */
|
||||
CC_DEPRECATED_ATTRIBUTE inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
|
||||
CC_DEPRECATED_ATTRIBUTE inline GLubyte getAlpha() const { return _alpha; }
|
||||
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
|
||||
inline GLubyte getAlpha() const { return _alpha; }
|
||||
|
||||
inline void setColor(const cocos2d::Color3B& color) { _color = color; }
|
||||
inline cocos2d::Color3B getColor() const { return _color; }
|
||||
|
||||
protected:
|
||||
virtual void onApply(float percent) override;
|
||||
|
||||
GLubyte _alpha;
|
||||
cocos2d::Color3B _color;
|
||||
|
||||
int _betweenAlpha;
|
||||
int _betweenRed;
|
||||
int _betweenGreen;
|
||||
int _betweenBlue;
|
||||
|
@ -322,13 +344,14 @@ public:
|
|||
AlphaFrame();
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
|
||||
inline GLubyte getAlpha() const { return _alpha; }
|
||||
|
||||
protected:
|
||||
virtual void onApply(float percent) override;
|
||||
|
||||
GLubyte _alpha;
|
||||
int _betweenAlpha;
|
||||
};
|
||||
|
@ -341,7 +364,7 @@ public:
|
|||
|
||||
EventFrame();
|
||||
|
||||
virtual void setNode(cocos2d::Node* node) override;
|
||||
virtual void setNode(cocos2d::Node* node);
|
||||
|
||||
virtual void onEnter(Frame *nextFrame, int currentFrameIndex) override;
|
||||
virtual Frame* clone() override;
|
||||
|
|
|
@ -45,6 +45,7 @@ struct EventFrame;
|
|||
struct IntFrame;
|
||||
struct BoolFrame;
|
||||
struct InnerActionFrame;
|
||||
struct EasingData;
|
||||
struct RotationSkew;
|
||||
struct Position;
|
||||
struct Scale;
|
||||
|
@ -2085,11 +2086,14 @@ struct PointFrame : private flatbuffers::Table {
|
|||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const Position *postion() const { return GetStruct<const Position *>(8); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<Position>(verifier, 8 /* postion */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2100,10 +2104,11 @@ struct PointFrameBuilder {
|
|||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_postion(const Position *postion) { fbb_.AddStruct(8, postion); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(10, easingData); }
|
||||
PointFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
PointFrameBuilder &operator=(const PointFrameBuilder &);
|
||||
flatbuffers::Offset<PointFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<PointFrame>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<PointFrame>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2111,8 +2116,10 @@ struct PointFrameBuilder {
|
|||
inline flatbuffers::Offset<PointFrame> CreatePointFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
const Position *postion = 0) {
|
||||
const Position *postion = 0,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
PointFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_postion(postion);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
|
@ -2123,11 +2130,14 @@ struct ScaleFrame : private flatbuffers::Table {
|
|||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const Scale *scale() const { return GetStruct<const Scale *>(8); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<Scale>(verifier, 8 /* scale */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2138,10 +2148,11 @@ struct ScaleFrameBuilder {
|
|||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_scale(const Scale *scale) { fbb_.AddStruct(8, scale); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(10, easingData); }
|
||||
ScaleFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
ScaleFrameBuilder &operator=(const ScaleFrameBuilder &);
|
||||
flatbuffers::Offset<ScaleFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<ScaleFrame>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<ScaleFrame>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2149,8 +2160,10 @@ struct ScaleFrameBuilder {
|
|||
inline flatbuffers::Offset<ScaleFrame> CreateScaleFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
const Scale *scale = 0) {
|
||||
const Scale *scale = 0,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
ScaleFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_scale(scale);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
|
@ -2161,11 +2174,14 @@ struct ColorFrame : private flatbuffers::Table {
|
|||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const Color *color() const { return GetStruct<const Color *>(8); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<Color>(verifier, 8 /* color */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2176,10 +2192,11 @@ struct ColorFrameBuilder {
|
|||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_color(const Color *color) { fbb_.AddStruct(8, color); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(10, easingData); }
|
||||
ColorFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
ColorFrameBuilder &operator=(const ColorFrameBuilder &);
|
||||
flatbuffers::Offset<ColorFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<ColorFrame>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<ColorFrame>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2187,8 +2204,10 @@ struct ColorFrameBuilder {
|
|||
inline flatbuffers::Offset<ColorFrame> CreateColorFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
const Color *color = 0) {
|
||||
const Color *color = 0,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
ColorFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_color(color);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
|
@ -2199,12 +2218,15 @@ struct TextureFrame : private flatbuffers::Table {
|
|||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const ResourceData *textureFile() const { return GetPointer<const ResourceData *>(8); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* textureFile */) &&
|
||||
verifier.VerifyTable(textureFile()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2215,10 +2237,11 @@ struct TextureFrameBuilder {
|
|||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_textureFile(flatbuffers::Offset<ResourceData> textureFile) { fbb_.AddOffset(8, textureFile); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(10, easingData); }
|
||||
TextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
TextureFrameBuilder &operator=(const TextureFrameBuilder &);
|
||||
flatbuffers::Offset<TextureFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<TextureFrame>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<TextureFrame>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2226,8 +2249,10 @@ struct TextureFrameBuilder {
|
|||
inline flatbuffers::Offset<TextureFrame> CreateTextureFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
flatbuffers::Offset<ResourceData> textureFile = 0) {
|
||||
flatbuffers::Offset<ResourceData> textureFile = 0,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
TextureFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_textureFile(textureFile);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
|
@ -2238,12 +2263,15 @@ struct EventFrame : private flatbuffers::Table {
|
|||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
const flatbuffers::String *value() const { return GetPointer<const flatbuffers::String *>(8); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* value */) &&
|
||||
verifier.Verify(value()) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2254,10 +2282,11 @@ struct EventFrameBuilder {
|
|||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_value(flatbuffers::Offset<flatbuffers::String> value) { fbb_.AddOffset(8, value); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(10, easingData); }
|
||||
EventFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
EventFrameBuilder &operator=(const EventFrameBuilder &);
|
||||
flatbuffers::Offset<EventFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<EventFrame>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<EventFrame>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2265,8 +2294,10 @@ struct EventFrameBuilder {
|
|||
inline flatbuffers::Offset<EventFrame> CreateEventFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
flatbuffers::Offset<flatbuffers::String> value = 0) {
|
||||
flatbuffers::Offset<flatbuffers::String> value = 0,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
EventFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_value(value);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
|
@ -2277,11 +2308,14 @@ struct IntFrame : private flatbuffers::Table {
|
|||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
int32_t value() const { return GetField<int32_t>(8, 0); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<int32_t>(verifier, 8 /* value */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2292,10 +2326,11 @@ struct IntFrameBuilder {
|
|||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_value(int32_t value) { fbb_.AddElement<int32_t>(8, value, 0); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(10, easingData); }
|
||||
IntFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
IntFrameBuilder &operator=(const IntFrameBuilder &);
|
||||
flatbuffers::Offset<IntFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<IntFrame>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<IntFrame>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2303,8 +2338,10 @@ struct IntFrameBuilder {
|
|||
inline flatbuffers::Offset<IntFrame> CreateIntFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
int32_t value = 0) {
|
||||
int32_t value = 0,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
IntFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_value(value);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_tween(tween);
|
||||
|
@ -2315,11 +2352,14 @@ struct BoolFrame : private flatbuffers::Table {
|
|||
int32_t frameIndex() const { return GetField<int32_t>(4, 0); }
|
||||
uint8_t tween() const { return GetField<uint8_t>(6, 1); }
|
||||
uint8_t value() const { return GetField<uint8_t>(8, 1); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(10); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
VerifyField<uint8_t>(verifier, 6 /* tween */) &&
|
||||
VerifyField<uint8_t>(verifier, 8 /* value */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2330,10 +2370,11 @@ struct BoolFrameBuilder {
|
|||
void add_frameIndex(int32_t frameIndex) { fbb_.AddElement<int32_t>(4, frameIndex, 0); }
|
||||
void add_tween(uint8_t tween) { fbb_.AddElement<uint8_t>(6, tween, 1); }
|
||||
void add_value(uint8_t value) { fbb_.AddElement<uint8_t>(8, value, 1); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(10, easingData); }
|
||||
BoolFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
BoolFrameBuilder &operator=(const BoolFrameBuilder &);
|
||||
flatbuffers::Offset<BoolFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<BoolFrame>(fbb_.EndTable(start_, 3));
|
||||
auto o = flatbuffers::Offset<BoolFrame>(fbb_.EndTable(start_, 4));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2341,8 +2382,10 @@ struct BoolFrameBuilder {
|
|||
inline flatbuffers::Offset<BoolFrame> CreateBoolFrame(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t frameIndex = 0,
|
||||
uint8_t tween = 1,
|
||||
uint8_t value = 1) {
|
||||
uint8_t value = 1,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
BoolFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_frameIndex(frameIndex);
|
||||
builder_.add_value(value);
|
||||
builder_.add_tween(tween);
|
||||
|
@ -2355,6 +2398,7 @@ struct InnerActionFrame : private flatbuffers::Table {
|
|||
int32_t innerActionType() const { return GetField<int32_t>(8, 0); }
|
||||
const flatbuffers::String *currentAniamtionName() const { return GetPointer<const flatbuffers::String *>(10); }
|
||||
int32_t singleFrameIndex() const { return GetField<int32_t>(12, 0); }
|
||||
const EasingData *easingData() const { return GetPointer<const EasingData *>(14); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* frameIndex */) &&
|
||||
|
@ -2363,6 +2407,8 @@ struct InnerActionFrame : private flatbuffers::Table {
|
|||
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* currentAniamtionName */) &&
|
||||
verifier.Verify(currentAniamtionName()) &&
|
||||
VerifyField<int32_t>(verifier, 12 /* singleFrameIndex */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* easingData */) &&
|
||||
verifier.VerifyTable(easingData()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
@ -2375,10 +2421,11 @@ struct InnerActionFrameBuilder {
|
|||
void add_innerActionType(int32_t innerActionType) { fbb_.AddElement<int32_t>(8, innerActionType, 0); }
|
||||
void add_currentAniamtionName(flatbuffers::Offset<flatbuffers::String> currentAniamtionName) { fbb_.AddOffset(10, currentAniamtionName); }
|
||||
void add_singleFrameIndex(int32_t singleFrameIndex) { fbb_.AddElement<int32_t>(12, singleFrameIndex, 0); }
|
||||
void add_easingData(flatbuffers::Offset<EasingData> easingData) { fbb_.AddOffset(14, easingData); }
|
||||
InnerActionFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
InnerActionFrameBuilder &operator=(const InnerActionFrameBuilder &);
|
||||
flatbuffers::Offset<InnerActionFrame> Finish() {
|
||||
auto o = flatbuffers::Offset<InnerActionFrame>(fbb_.EndTable(start_, 5));
|
||||
auto o = flatbuffers::Offset<InnerActionFrame>(fbb_.EndTable(start_, 6));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
@ -2388,8 +2435,10 @@ inline flatbuffers::Offset<InnerActionFrame> CreateInnerActionFrame(flatbuffers:
|
|||
uint8_t tween = 1,
|
||||
int32_t innerActionType = 0,
|
||||
flatbuffers::Offset<flatbuffers::String> currentAniamtionName = 0,
|
||||
int32_t singleFrameIndex = 0) {
|
||||
int32_t singleFrameIndex = 0,
|
||||
flatbuffers::Offset<EasingData> easingData = 0) {
|
||||
InnerActionFrameBuilder builder_(_fbb);
|
||||
builder_.add_easingData(easingData);
|
||||
builder_.add_singleFrameIndex(singleFrameIndex);
|
||||
builder_.add_currentAniamtionName(currentAniamtionName);
|
||||
builder_.add_innerActionType(innerActionType);
|
||||
|
@ -2398,6 +2447,40 @@ inline flatbuffers::Offset<InnerActionFrame> CreateInnerActionFrame(flatbuffers:
|
|||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct EasingData : private flatbuffers::Table {
|
||||
int32_t type() const { return GetField<int32_t>(4, -1); }
|
||||
const flatbuffers::Vector<const Position *> *points() const { return GetPointer<const flatbuffers::Vector<const Position *> *>(6); }
|
||||
bool Verify(flatbuffers::Verifier &verifier) const {
|
||||
return VerifyTableStart(verifier) &&
|
||||
VerifyField<int32_t>(verifier, 4 /* type */) &&
|
||||
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* points */) &&
|
||||
verifier.Verify(points()) &&
|
||||
verifier.EndTable();
|
||||
}
|
||||
};
|
||||
|
||||
struct EasingDataBuilder {
|
||||
flatbuffers::FlatBufferBuilder &fbb_;
|
||||
flatbuffers::uoffset_t start_;
|
||||
void add_type(int32_t type) { fbb_.AddElement<int32_t>(4, type, -1); }
|
||||
void add_points(flatbuffers::Offset<flatbuffers::Vector<const Position *>> points) { fbb_.AddOffset(6, points); }
|
||||
EasingDataBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
|
||||
EasingDataBuilder &operator=(const EasingDataBuilder &);
|
||||
flatbuffers::Offset<EasingData> Finish() {
|
||||
auto o = flatbuffers::Offset<EasingData>(fbb_.EndTable(start_, 2));
|
||||
return o;
|
||||
}
|
||||
};
|
||||
|
||||
inline flatbuffers::Offset<EasingData> CreateEasingData(flatbuffers::FlatBufferBuilder &_fbb,
|
||||
int32_t type = -1,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const Position *>> points = 0) {
|
||||
EasingDataBuilder builder_(_fbb);
|
||||
builder_.add_points(points);
|
||||
builder_.add_type(type);
|
||||
return builder_.Finish();
|
||||
}
|
||||
|
||||
struct ResourceData : private flatbuffers::Table {
|
||||
const flatbuffers::String *path() const { return GetPointer<const flatbuffers::String *>(4); }
|
||||
const flatbuffers::String *plistFile() const { return GetPointer<const flatbuffers::String *>(6); }
|
||||
|
|
|
@ -790,12 +790,15 @@ Offset<flatbuffers::PointFrame> FlatBuffersSerialize::createPointFrame(const tin
|
|||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Position f_position(position.x, position.y);
|
||||
|
||||
return CreatePointFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_position);
|
||||
&f_position,
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::ScaleFrame> FlatBuffersSerialize::createScaleFrame(const tinyxml2::XMLElement *objectData)
|
||||
|
@ -835,7 +838,8 @@ Offset<flatbuffers::ScaleFrame> FlatBuffersSerialize::createScaleFrame(const tin
|
|||
return CreateScaleFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_scale);
|
||||
&f_scale,
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::ColorFrame> FlatBuffersSerialize::createColorFrame(const tinyxml2::XMLElement *objectData)
|
||||
|
@ -896,7 +900,8 @@ Offset<flatbuffers::ColorFrame> FlatBuffersSerialize::createColorFrame(const tin
|
|||
return CreateColorFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
&f_color);
|
||||
&f_color,
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::TextureFrame> FlatBuffersSerialize::createTextureFrame(const tinyxml2::XMLElement *objectData)
|
||||
|
@ -969,7 +974,8 @@ Offset<flatbuffers::TextureFrame> FlatBuffersSerialize::createTextureFrame(const
|
|||
CreateResourceData(*_builder,
|
||||
_builder->CreateString(path),
|
||||
_builder->CreateString(plistFile),
|
||||
resourceType));
|
||||
resourceType),
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::EventFrame> FlatBuffersSerialize::createEventFrame(const tinyxml2::XMLElement *objectData)
|
||||
|
@ -1003,7 +1009,8 @@ Offset<flatbuffers::EventFrame> FlatBuffersSerialize::createEventFrame(const tin
|
|||
return CreateEventFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
_builder->CreateString(value));
|
||||
_builder->CreateString(value),
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::IntFrame> FlatBuffersSerialize::createIntFrame(const tinyxml2::XMLElement *objectData)
|
||||
|
@ -1037,7 +1044,8 @@ Offset<flatbuffers::IntFrame> FlatBuffersSerialize::createIntFrame(const tinyxml
|
|||
return CreateIntFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
value);
|
||||
value,
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::BoolFrame> FlatBuffersSerialize::createBoolFrame(const tinyxml2::XMLElement *objectData)
|
||||
|
@ -1069,67 +1077,133 @@ Offset<flatbuffers::BoolFrame> FlatBuffersSerialize::createBoolFrame(const tinyx
|
|||
}
|
||||
|
||||
return CreateBoolFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
value);
|
||||
frameIndex,
|
||||
tween,
|
||||
value,
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
Offset<flatbuffers::InnerActionFrame> FlatBuffersSerialize::createInnerActionFrame(const tinyxml2::XMLElement *objectData)
|
||||
Offset<flatbuffers::InnerActionFrame> FlatBuffersSerialize::createInnerActionFrame(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
int innerActionType = 0;
|
||||
std::string currentAniamtionName = "";
|
||||
int singleFrameIndex = 0;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
{
|
||||
int frameIndex = 0;
|
||||
bool tween = true;
|
||||
int innerActionType = 0;
|
||||
std::string currentAniamtionName = "";
|
||||
int singleFrameIndex = 0;
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
while (attribute)
|
||||
if (name == "InnerActionType")
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string attrivalue = attribute->Value();
|
||||
|
||||
if (name == "InnerActionType")
|
||||
if (attrivalue == "LoopAction")
|
||||
{
|
||||
if (attrivalue == "LoopAction")
|
||||
{
|
||||
innerActionType = 0;
|
||||
}
|
||||
else if (attrivalue == "NoLoopAction")
|
||||
{
|
||||
innerActionType = 1;
|
||||
}
|
||||
else if (attrivalue == "SingleFrame")
|
||||
{
|
||||
innerActionType = 2;
|
||||
}
|
||||
innerActionType = 0;
|
||||
}
|
||||
else if (name == "CurrentAniamtionName")
|
||||
else if (attrivalue == "NoLoopAction")
|
||||
{
|
||||
currentAniamtionName = attrivalue;
|
||||
innerActionType = 1;
|
||||
}
|
||||
else if (name == "SingleFrameIndex")
|
||||
else if (attrivalue == "SingleFrame")
|
||||
{
|
||||
singleFrameIndex = atoi(attrivalue.c_str());
|
||||
innerActionType = 2;
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
else if (name == "CurrentAniamtionName")
|
||||
{
|
||||
currentAniamtionName = attrivalue;
|
||||
}
|
||||
else if (name == "SingleFrameIndex")
|
||||
{
|
||||
singleFrameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "FrameIndex")
|
||||
{
|
||||
frameIndex = atoi(attrivalue.c_str());
|
||||
}
|
||||
else if (name == "Tween")
|
||||
{
|
||||
tween = (attrivalue == "True") ? true : false;
|
||||
}
|
||||
|
||||
return CreateInnerActionFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
innerActionType,
|
||||
_builder->CreateString(currentAniamtionName),
|
||||
singleFrameIndex);
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
return CreateInnerActionFrame(*_builder,
|
||||
frameIndex,
|
||||
tween,
|
||||
innerActionType,
|
||||
_builder->CreateString(currentAniamtionName),
|
||||
singleFrameIndex,
|
||||
createEasingData(objectData->FirstChildElement()));
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::EasingData> FlatBuffersSerialize::createEasingData(const tinyxml2::XMLElement *objectData)
|
||||
{
|
||||
if (!objectData)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int type = -1;
|
||||
std::vector<flatbuffers::Position> points;
|
||||
|
||||
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
|
||||
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (name == "Type")
|
||||
{
|
||||
type = atoi(value.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
|
||||
const tinyxml2::XMLElement* Points = objectData->FirstChildElement();
|
||||
if (Points)
|
||||
{
|
||||
const tinyxml2::XMLElement* PointF = Points->FirstChildElement();
|
||||
while (PointF)
|
||||
{
|
||||
Vec2 pointF = Vec2::ZERO;
|
||||
|
||||
attribute = PointF->FirstAttribute();
|
||||
|
||||
while (attribute)
|
||||
{
|
||||
std::string name = attribute->Name();
|
||||
std::string value = attribute->Value();
|
||||
|
||||
if (name == "X")
|
||||
{
|
||||
pointF.x = atof(value.c_str());
|
||||
}
|
||||
else if (name == "Y")
|
||||
{
|
||||
pointF.y = atof(value.c_str());
|
||||
}
|
||||
attribute = attribute->Next();
|
||||
}
|
||||
flatbuffers::Position f_PointF(pointF.x, pointF.y);
|
||||
points.push_back(f_PointF);
|
||||
|
||||
PointF = PointF->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
return CreateEasingData(*_builder,
|
||||
type,
|
||||
_builder->CreateVectorOfStructs(points));
|
||||
}
|
||||
|
||||
|
||||
/* create flat buffers with XML */
|
||||
FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulator(const std::string &xmlFileName)
|
||||
|
|
|
@ -77,6 +77,7 @@ namespace flatbuffers
|
|||
struct IntFrame;
|
||||
struct BoolFrame;
|
||||
struct InnerActionFrame;
|
||||
struct EasingData;
|
||||
}
|
||||
|
||||
namespace tinyxml2
|
||||
|
@ -122,6 +123,8 @@ public:
|
|||
flatbuffers::Offset<flatbuffers::IntFrame> createIntFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::BoolFrame> createBoolFrame(const tinyxml2::XMLElement* objectData);
|
||||
flatbuffers::Offset<flatbuffers::InnerActionFrame> createInnerActionFrame(const tinyxml2::XMLElement* objectData);
|
||||
|
||||
flatbuffers::Offset<flatbuffers::EasingData> createEasingData(const tinyxml2::XMLElement* objectData);
|
||||
|
||||
//Animation Info
|
||||
flatbuffers::Offset<flatbuffers::AnimationInfo> createAnimationInfo(const tinyxml2::XMLElement* objectData);
|
||||
|
|
Loading…
Reference in New Issue