Parse InnerActionFrame, AlphaFrame, modify cocostudio editor version number.

This commit is contained in:
pipu 2015-01-12 10:55:15 +08:00
parent 45f54e8358
commit 78b32332d3
13 changed files with 1186 additions and 727 deletions

View File

@ -93,14 +93,14 @@ bool ActionTimeline::init()
void ActionTimeline::play(std::string name, bool loop)
{
if(_indexes.find(name) == _indexes.end())
if (_animationInfos.find(name) == _animationInfos.end())
{
CCLOG("Cann't find action indexes for %s.", name.c_str());
return;
CCLOG("Can't find animation info for %s", name.c_str());
return;
}
ActionIndexes& indexes = _indexes[name];
gotoFrameAndPlay(indexes.startIndex, indexes.endIndex, loop);
AnimationInfo& index = _animationInfos[name];
gotoFrameAndPlay(index.startIndex, index.endIndex, loop);
}
void ActionTimeline::gotoFrameAndPlay(int startIndex)
@ -278,26 +278,37 @@ void ActionTimeline::removeTimeline(Timeline* timeline)
}
}
void ActionTimeline::addIndexes(const ActionIndexes& indexes)
void ActionTimeline::addAnimationInfo(const AnimationInfo& animationInfo)
{
if(_indexes.find(indexes.name) != _indexes.end())
if (_animationInfos.find(animationInfo.name) != _animationInfos.end())
{
CCLOG("ActionIndexes (%s) already exsists.", indexes.name.c_str());
CCLOG("Animation (%s) already exists.", animationInfo.name.c_str());
return;
}
_indexes[indexes.name] = indexes;
_animationInfos[animationInfo.name] = animationInfo;
}
void ActionTimeline::removeIndexes(std::string name)
void ActionTimeline::removeAnimationInfo(std::string animationName)
{
if(_indexes.find(name) == _indexes.end())
if (_animationInfos.find(animationName) == _animationInfos.end())
{
CCLOG("ActionIndexes %s don't exsists.", name.c_str());
CCLOG("AnimationInfo (%s) not exists.", animationName.c_str());
return;
}
_indexes.erase(name);
_animationInfos.erase(animationName);
}
bool ActionTimeline::IsAnimationInfoExists(const std::string& animationName)
{
return _animationInfos.find(animationName) != _animationInfos.end();
}
AnimationInfo ActionTimeline::getAnimationInfo(const std::string &animationName)
{
return _animationInfos.find(animationName)->second;
}
void ActionTimeline::setFrameEventCallFunc(std::function<void(Frame *)> listener)
@ -348,5 +359,4 @@ void ActionTimeline::stepToFrame(int frameIndex)
_timelineList.at(i)->stepToFrame(frameIndex);
}
}
NS_TIMELINE_END

View File

@ -31,7 +31,7 @@ THE SOFTWARE.
NS_TIMELINE_BEGIN
struct ActionIndexes
struct AnimationInfo
{
std::string name;
int startIndex;
@ -63,9 +63,9 @@ public:
ActionTimeline();
virtual ~ActionTimeline();
virtual bool init();
virtual void play(std::string animationName, bool loop);
virtual void play(std::string name, bool loop);
virtual bool init();
/** Goto the specified frame index, and start playing from this index.
* @param startIndex The animation will play from this index.
@ -98,7 +98,6 @@ public:
*/
virtual void gotoFrameAndPause(int startIndex);
/** Pause the animation. */
virtual void pause();
/** Resume the animation. */
@ -133,12 +132,14 @@ public:
virtual void addTimeline(Timeline* timeline);
virtual void removeTimeline(Timeline* timeline);
/** add ActionIndexes */
virtual void addIndexes(const ActionIndexes& indexes);
virtual void removeIndexes(std::string name);
virtual const cocos2d::Vector<Timeline*>& getTimelines() const { return _timelineList; }
/** add ActionIndexes*/
virtual void addAnimationInfo(const AnimationInfo& animationInfo);
virtual void removeAnimationInfo(std::string animationName);
virtual bool IsAnimationInfoExists(const std::string& animationName);
virtual AnimationInfo getAnimationInfo(const std::string& animationName);
/** Set ActionTimeline's frame event callback function */
void setFrameEventCallFunc(std::function<void(Frame *)> listener);
void clearFrameEventCallFunc();
@ -182,7 +183,7 @@ protected:
std::function<void(Frame*)> _frameEventListener;
std::function<void()> _lastFrameListener;
std::map<std::string, ActionIndexes> _indexes;
std::map<std::string, AnimationInfo> _animationInfos;
};
NS_TIMELINE_END

View File

@ -47,18 +47,16 @@ using namespace flatbuffers;
namespace cocostudio {
namespace timeline{
static const char* FrameType_VisibleFrame = "VisibleFrame";
static const char* FrameType_PositionFrame = "PositionFrame";
static const char* FrameType_ScaleFrame = "ScaleFrame";
static const char* FrameType_RotationFrame = "RotationFrame";
static const char* FrameType_SkewFrame = "SkewFrame";
static const char* FrameType_RotationSkewFrame = "RotationSkewFrame";
static const char* FrameType_AnchorFrame = "AnchorPointFrame";
static const char* FrameType_InnerActionFrame = "InnerActionFrame";
static const char* FrameType_ColorFrame = "ColorFrame";
static const char* FrameType_TextureFrame = "TextureFrame";
static const char* FrameType_EventFrame = "EventFrame";
static const char* FrameType_ZOrderFrame = "ZOrderFrame";
static const char* Property_VisibleForFrame = "VisibleForFrame";
static const char* Property_Position = "Position";
static const char* Property_Scale = "Scale";
static const char* Property_RotationSkew = "RotationSkew";
static const char* Property_CColor = "CColor";
static const char* Property_FileData = "FileData";
static const char* Property_FrameEvent = "FrameEvent";
static const char* Property_Alpha = "Alpha";
static const char* Property_ZOrder = "ZOrder";
static const char* Property_ActionValue = "ActionValue";
static const char* ACTION = "action";
static const char* DURATION = "duration";
@ -108,6 +106,7 @@ void ActionTimelineCache::purge()
void ActionTimelineCache::init()
{
using namespace std::placeholders;
/*
_funcs.insert(Pair(FrameType_VisibleFrame, std::bind(&ActionTimelineCache::loadVisibleFrame, this, _1)));
_funcs.insert(Pair(FrameType_PositionFrame, std::bind(&ActionTimelineCache::loadPositionFrame, this, _1)));
_funcs.insert(Pair(FrameType_ScaleFrame, std::bind(&ActionTimelineCache::loadScaleFrame, this, _1)));
@ -120,6 +119,7 @@ void ActionTimelineCache::init()
_funcs.insert(Pair(FrameType_TextureFrame, std::bind(&ActionTimelineCache::loadTextureFrame, this, _1)));
_funcs.insert(Pair(FrameType_EventFrame, std::bind(&ActionTimelineCache::loadEventFrame, this, _1)));
_funcs.insert(Pair(FrameType_ZOrderFrame, std::bind(&ActionTimelineCache::loadZOrderFrame, this, _1)));
*/
}
@ -439,6 +439,17 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithFlatBuffersFile(cons
float speed = nodeAction->speed();
action->setTimeSpeed(speed);
auto animationlist = csparsebinary->animationList();
int animationcount = animationlist->size();
for (int i = 0; i < animationcount; i++)
{
auto animationdata = animationlist->Get(i);
AnimationInfo info;
info.name = animationdata->name()->c_str();
info.startIndex = animationdata->startIndex();
info.endIndex = animationdata->endIndex();
action->addAnimationInfo(info);
}
auto timelines = nodeAction->timeLines();
int timelineLength = timelines->size();
@ -460,14 +471,14 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti
{
Timeline* timeline = nullptr;
// get frame type
std::string frameType = flatbuffers->frameType()->c_str();
if(frameType == "")
// property
std::string property = flatbuffers->property()->c_str();
if(property == "")
return nullptr;
CCLOG("frameType = %s", frameType.c_str());
CCLOG("property = %s", property.c_str());
if(frameType != "")
if(property != "")
{
timeline = Timeline::create();
@ -482,52 +493,62 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti
auto frameFlatbuf = framesFlatbuf->Get(i);
Frame* frame = nullptr;
if (frameType == FrameType_VisibleFrame)
if (property == Property_VisibleForFrame)
{
auto visibleFrame = frameFlatbuf->visibleFrame();
frame = loadVisibleFrameWithFlatBuffers(visibleFrame);
auto boolFrame = frameFlatbuf->boolFrame();
frame = loadVisibleFrameWithFlatBuffers(boolFrame);
}
else if (frameType == FrameType_ZOrderFrame)
else if (property == Property_Position)
{
auto zOrderFrame = frameFlatbuf->zOrderFrame();
frame = loadZOrderFrameWithFlatBuffers(zOrderFrame);
}
else if (frameType == FrameType_RotationSkewFrame)
{
auto rotationSkewFrame = frameFlatbuf->rotationSkewFrame();
frame = loadRotationSkewFrameWithFlatBuffers(rotationSkewFrame);
}
else if (frameType == FrameType_EventFrame)
{
auto eventFrame = frameFlatbuf->eventFrame();
frame = loadEventFrameWithFlatBuffers(eventFrame);
}
else if (frameType == FrameType_AnchorFrame)
{
auto anchorPointFrame = frameFlatbuf->anchorPointFrame();
frame = loadAnchorPointFrameWithFlatBuffers(anchorPointFrame);
}
else if (frameType == FrameType_PositionFrame)
{
auto potisionFrame = frameFlatbuf->positionFrame();
auto potisionFrame = frameFlatbuf->pointFrame();
frame = loadPositionFrameWithFlatBuffers(potisionFrame);
}
else if (frameType == FrameType_ScaleFrame)
else if (property == Property_Scale)
{
auto scaleFrame = frameFlatbuf->scaleFrame();
frame = loadScaleFrameWithFlatBuffers(scaleFrame);
}
else if (frameType == FrameType_ColorFrame)
else if (property == Property_RotationSkew)
{
auto scaleFrame = frameFlatbuf->scaleFrame();
frame = loadRotationSkewFrameWithFlatBuffers(scaleFrame);
}
else if (property == Property_CColor)
{
auto colorFrame = frameFlatbuf->colorFrame();
frame = loadColorFrameWithFlatBuffers(colorFrame);
}
else if (frameType == FrameType_TextureFrame)
else if (property == Property_FrameEvent)
{
auto eventFrame = frameFlatbuf->eventFrame();
frame = loadEventFrameWithFlatBuffers(eventFrame);
}
else if (property == Property_FileData)
{
auto textureFrame = frameFlatbuf->textureFrame();
frame = loadTextureFrameWithFlatBuffers(textureFrame);
}
else if (property == Property_Alpha)
{
auto intFrame = frameFlatbuf->intFrame();
frame = loadAlphaFrameWithFlatBuffers(intFrame);
}
else if (property == Property_ZOrder)
{
auto intFrame = frameFlatbuf->intFrame();
frame = loadZOrderFrameWithFlatBuffers(intFrame);
}
else if (property == Property_ActionValue)
{
auto innerActionFrame = frameFlatbuf->innerActionFrame();
frame = loadInnerActionFrameWithFlatBuffers(innerActionFrame);
}
if (!frame)
{
CCLOG("frame is invalid.");
continue;
}
timeline->addFrame(frame);
}
}
@ -535,15 +556,14 @@ Timeline* ActionTimelineCache::loadTimelineWithFlatBuffers(const flatbuffers::Ti
return timeline;
}
Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::TimeLineBoolFrame *flatbuffers)
Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::BoolFrame *flatbuffers)
{
VisibleFrame* frame = VisibleFrame::create();
bool visible = flatbuffers->value();
frame->setVisible(visible);
CCLOG("visible = %d", visible);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
@ -553,80 +573,7 @@ Frame* ActionTimelineCache::loadVisibleFrameWithFlatBuffers(const flatbuffers::T
return frame;
}
Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::TimeLineIntFrame *flatbuffers)
{
ZOrderFrame* frame = ZOrderFrame::create();
int zorder = flatbuffers->value();
frame->setZOrder(zorder);
CCLOG("zorder = %d", zorder);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
{
RotationSkewFrame* frame = RotationSkewFrame::create();
auto f_rotationSkew = flatbuffers->postion();
Vec2 rotationSkew(f_rotationSkew->x(), f_rotationSkew->y());
frame->setSkewX(rotationSkew.x);
frame->setSkewY(rotationSkew.y);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::TimeLineStringFrame *flatbuffers)
{
EventFrame* frame = EventFrame::create();
std::string event = flatbuffers->value()->c_str();
if (event != "")
frame->setEvent(event);
CCLOG("event = %s", event.c_str());
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadAnchorPointFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
{
AnchorPointFrame* frame = AnchorPointFrame::create();
auto f_anchorPoint = flatbuffers->postion();
Vec2 anchorPoint(f_anchorPoint->x(), f_anchorPoint->y());
frame->setAnchorPoint(anchorPoint);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::PointFrame *flatbuffers)
{
PositionFrame* frame = PositionFrame::create();
@ -643,12 +590,12 @@ Frame* ActionTimelineCache::loadPositionFrameWithFlatBuffers(const flatbuffers::
return frame;
}
Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::TimeLinePointFrame *flatbuffers)
Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers)
{
ScaleFrame* frame = ScaleFrame::create();
auto f_scale = flatbuffers->postion();
Vec2 scale(f_scale->x(), f_scale->y());
auto f_scale = flatbuffers->scale();
Vec2 scale(f_scale->scaleX(), f_scale->scaleY());
frame->setScaleX(scale.x);
frame->setScaleY(scale.y);
@ -661,16 +608,14 @@ Frame* ActionTimelineCache::loadScaleFrameWithFlatBuffers(const flatbuffers::Tim
return frame;
}
Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::TimeLineColorFrame *flatbuffers)
Frame* ActionTimelineCache::loadRotationSkewFrameWithFlatBuffers(const flatbuffers::ScaleFrame *flatbuffers)
{
ColorFrame* frame = ColorFrame::create();
RotationSkewFrame* frame = RotationSkewFrame::create();
auto f_color = flatbuffers->color();
Color3B color(f_color->r(), f_color->g(), f_color->b());
frame->setColor(color);
int alpha = f_color->a();
frame->setAlpha(alpha);
auto f_scale = flatbuffers->scale();
Vec2 rotationSkew(f_scale->scaleX(), f_scale->scaleY());
frame->setSkewX(rotationSkew.x);
frame->setSkewY(rotationSkew.y);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
@ -681,7 +626,24 @@ Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::Tim
return frame;
}
Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::TimeLineTextureFrame *flatbuffers)
Frame* ActionTimelineCache::loadColorFrameWithFlatBuffers(const flatbuffers::ColorFrame *flatbuffers)
{
ColorFrame* frame = ColorFrame::create();
auto f_color = flatbuffers->color();
Color3B color(f_color->r(), f_color->g(), f_color->b());
frame->setColor(color);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::TextureFrame *flatbuffers)
{
std::string path = "";
int resourceType = 0;
@ -689,7 +651,7 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
TextureFrame* frame = TextureFrame::create();
auto fileNameData = flatbuffers->fileNameData();
auto fileNameData = flatbuffers->textureFile();
resourceType = fileNameData->resourceType();
switch (resourceType)
@ -727,7 +689,6 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
break;
}
frame->setTextureName(path);
int frameIndex = flatbuffers->frameIndex();
@ -739,6 +700,85 @@ Frame* ActionTimelineCache::loadTextureFrameWithFlatBuffers(const flatbuffers::T
return frame;
}
Frame* ActionTimelineCache::loadEventFrameWithFlatBuffers(const flatbuffers::EventFrame *flatbuffers)
{
EventFrame* frame = EventFrame::create();
std::string event = flatbuffers->value()->c_str();
if (event != "")
frame->setEvent(event);
CCLOG("event = %s", event.c_str());
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadAlphaFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers)
{
AlphaFrame* frame = AlphaFrame::create();
int alpha = flatbuffers->value();
frame->setAlpha(alpha);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadZOrderFrameWithFlatBuffers(const flatbuffers::IntFrame *flatbuffers)
{
ZOrderFrame* frame = ZOrderFrame::create();
int zorder = flatbuffers->value();
frame->setZOrder(zorder);
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
return frame;
}
Frame* ActionTimelineCache::loadInnerActionFrameWithFlatBuffers(const flatbuffers::InnerActionFrame *flatbuffers)
{
InnerActionFrame* frame = InnerActionFrame::create();
InnerActionType innerActionType = (InnerActionType)flatbuffers->innerActionType();
std::string currentAnimationFrame = flatbuffers->currentAniamtionName()->c_str();
int singleFrameIndex = flatbuffers->singleFrameIndex();
int frameIndex = flatbuffers->frameIndex();
frame->setFrameIndex(frameIndex);
bool tween = flatbuffers->tween();
frame->setTween(tween);
frame->setInnerActionType(innerActionType);
frame->setSingleFrameIndex(singleFrameIndex);
frame->setEnterWithName(true);
frame->setAnimationName(currentAnimationFrame);
return frame;
}
ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(const std::string& fileName)
{
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
@ -758,6 +798,18 @@ ActionTimeline* ActionTimelineCache::createActionWithFlatBuffersForSimulator(con
float speed = nodeAction->speed();
action->setTimeSpeed(speed);
auto animationlist = csparsebinary->animationList();
int animationcount = animationlist->size();
for (int i = 0; i < animationcount; i++)
{
auto animationdata = animationlist->Get(i);
AnimationInfo info;
info.name = animationdata->name()->c_str();
info.startIndex = animationdata->startIndex();
info.endIndex = animationdata->endIndex();
action->addAnimationInfo(info);
}
auto timeLines = nodeAction->timeLines();
int timelineLength = timeLines->size();
for (int i = 0; i < timelineLength; i++)

View File

@ -38,12 +38,14 @@ namespace flatbuffers
struct NodeAction;
struct TimeLine;
struct TimeLineBoolFrame;
struct TimeLineIntFrame;
struct TimeLineStringFrame;
struct TimeLinePointFrame;
struct TimeLineColorFrame;
struct TimeLineTextureFrame;
struct PointFrame;
struct ScaleFrame;
struct ColorFrame;
struct TextureFrame;
struct EventFrame;
struct IntFrame;
struct BoolFrame;
struct InnerActionFrame;
}
NS_TIMELINE_BEGIN
@ -55,6 +57,7 @@ class Frame;
class CC_STUDIO_DLL ActionTimelineCache
{
public:
/** Gets the singleton */
static ActionTimelineCache* getInstance();
@ -101,15 +104,16 @@ protected:
Timeline* loadTimelineWithFlatBuffers(const flatbuffers::TimeLine* flatbuffers);
Frame* loadVisibleFrameWithFlatBuffers (const flatbuffers::TimeLineBoolFrame* flatbuffers);
Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::TimeLineIntFrame* flatbuffers);
Frame* loadRotationSkewFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
Frame* loadEventFrameWithFlatBuffers (const flatbuffers::TimeLineStringFrame* flatbuffers);
Frame* loadAnchorPointFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
Frame* loadPositionFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
Frame* loadScaleFrameWithFlatBuffers (const flatbuffers::TimeLinePointFrame* flatbuffers);
Frame* loadColorFrameWithFlatBuffers (const flatbuffers::TimeLineColorFrame* flatbuffers);
Frame* loadTextureFrameWithFlatBuffers (const flatbuffers::TimeLineTextureFrame* flatbuffers);
Frame* loadVisibleFrameWithFlatBuffers (const flatbuffers::BoolFrame* flatbuffers);
Frame* loadPositionFrameWithFlatBuffers (const flatbuffers::PointFrame* flatbuffers);
Frame* loadScaleFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
Frame* loadRotationSkewFrameWithFlatBuffers (const flatbuffers::ScaleFrame* flatbuffers);
Frame* loadColorFrameWithFlatBuffers (const flatbuffers::ColorFrame* flatbuffers);
Frame* loadTextureFrameWithFlatBuffers (const flatbuffers::TextureFrame* flatbuffers);
Frame* loadEventFrameWithFlatBuffers (const flatbuffers::EventFrame* flatbuffers);
Frame* loadAlphaFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
Frame* loadZOrderFrameWithFlatBuffers (const flatbuffers::IntFrame* flatbuffers);
Frame* loadInnerActionFrameWithFlatBuffers (const flatbuffers::InnerActionFrame* flatbuffers);
protected:

View File

@ -27,6 +27,8 @@ THE SOFTWARE.
#include "CCActionTimeline.h"
#include "2d/CCSpriteFrameCache.h"
#include "2d/CCSpriteFrame.h"
#include <exception>
#include <iostream>
USING_NS_CC;
@ -466,20 +468,89 @@ InnerActionFrame* InnerActionFrame::create()
InnerActionFrame::InnerActionFrame()
: _innerActionType(LoopAction)
, _startFrameIndex(0)
, _endFrameIndex(0)
{
}
void InnerActionFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{
int start = _startFrameIndex;
int end = _endFrameIndex;
auto actiontimeline = static_cast<ActionTimeline*>(_node->getActionByTag(_node->getTag()));
if (InnerActionType::SingleFrame == _innerActionType)
{
actiontimeline->gotoFrameAndPause(_singleFrameIndex);
return;
}
if (_enterWithName)
{
if (_animationName == "-- ALL --")
{
start = 0;
end = actiontimeline->getDuration();
}
else if(actiontimeline->IsAnimationInfoExists(_animationName))
{
AnimationInfo info = actiontimeline->getAnimationInfo(_animationName);
start = info.startIndex;
end = info.endIndex;
}
else
{
CCLOG("Animation %s not exists!", _animationName.c_str());
}
}
if (InnerActionType::NoLoopAction == _innerActionType)
{
actiontimeline->gotoFrameAndPlay(start, end, false);
}
else if (InnerActionType::LoopAction == _innerActionType)
{
actiontimeline->gotoFrameAndPlay(start, end, true);
}
}
void InnerActionFrame::setStartFrameIndex(int frameIndex) throw()
{
if(_enterWithName)
{
CCLOG(" cannot set start when enter frame with name. setEnterWithName false firstly!");
throw std::exception();
}
_startFrameIndex = frameIndex;
}
void InnerActionFrame::setEndFrameIndex(int frameIndex) throw()
{
if(_enterWithName)
{
CCLOG(" cannot set end when enter frame with name. setEnterWithName false firstly!");
throw std::exception();
}
_endFrameIndex = frameIndex;
}
void InnerActionFrame::setAnimationName(const std::string& animationName) throw()
{
if(!_enterWithName)
{
CCLOG(" cannot set aniamtioname when enter frame with index. setEnterWithName true firstly!");
throw std::exception();
}
_animationName = animationName;
}
Frame* InnerActionFrame::clone()
{
InnerActionFrame* frame = InnerActionFrame::create();
frame->setInnerActionType(_innerActionType);
frame->setStartFrameIndex(_startFrameIndex);
frame->setEndFrameIndex(_endFrameIndex);
frame->cloneProperty(this);
return frame;
@ -548,6 +619,51 @@ Frame* ColorFrame::clone()
return frame;
}
// AlphaFrame
AlphaFrame* AlphaFrame::create()
{
AlphaFrame* frame = new (std::nothrow) AlphaFrame();
if (frame)
{
frame->autorelease();
return frame;
}
CC_SAFE_DELETE(frame);
return nullptr;
}
AlphaFrame::AlphaFrame()
: _alpha(255)
{
}
void AlphaFrame::onEnter(Frame *nextFrame, int currentFrameIndex)
{
_node->setOpacity(_alpha);
if (_tween)
{
_betweenAlpha = static_cast<AlphaFrame*>(nextFrame)->_alpha - _alpha;
}
}
void AlphaFrame::apply(float percent)
{
if (_tween)
{
GLubyte alpha = _alpha + _betweenAlpha * percent;
_node->setOpacity(alpha);
}
}
Frame* AlphaFrame::clone()
{
AlphaFrame* frame = AlphaFrame::create();
frame->setAlpha(_alpha);
frame->cloneProperty(this);
return frame;
}
// EventFrame
EventFrame* EventFrame::create()

View File

@ -264,12 +264,26 @@ public:
inline void setInnerActionType(InnerActionType type) { _innerActionType = type; }
inline InnerActionType getInnerActionType() const { return _innerActionType; }
inline void setStartFrameIndex(int frameIndex) { _startFrameIndex = frameIndex; }
inline void setEnterWithName(bool isEnterWithName) { _enterWithName = isEnterWithName;}
void setStartFrameIndex(int frameIndex) throw();
inline int getStartFrameIndex() const { return _startFrameIndex; }
void setEndFrameIndex(int frameIndex) throw();
inline int getEndFrameIndex() const { return _endFrameIndex; }
void setAnimationName(const std::string& animationNamed) throw();
inline void setSingleFrameIndex(int frameIndex) { _singleFrameIndex = frameIndex;}
inline int getSingleFrameIndex() const { return _singleFrameIndex;}
protected:
InnerActionType _innerActionType;
int _startFrameIndex;
int _endFrameIndex;
int _singleFrameIndex;
std::string _animationName;
bool _enterWithName;
};
@ -299,6 +313,23 @@ protected:
int _betweenBlue;
};
class CC_STUDIO_DLL AlphaFrame : public Frame
{
public:
static AlphaFrame* create();
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:
GLubyte _alpha;
int _betweenAlpha;
};
class CC_STUDIO_DLL EventFrame : public Frame
{

View File

@ -181,7 +181,7 @@ CSLoader::CSLoader()
, _jsonPath("")
, _monoCocos2dxVersion("")
, _rootNode(nullptr)
, _csBuildID("2.0.8.0")
, _csBuildID("2.1.0.0")
{
CREATE_CLASS_NODE_READER_INFO(NodeReader);
CREATE_CLASS_NODE_READER_INFO(SingleNodeReader);
@ -285,6 +285,7 @@ ActionTimeline* CSLoader::createTimeline(const std::string &filename)
return nullptr;
}
/*
ActionTimelineNode* CSLoader::createActionTimelineNode(const std::string& filename)
{
Node* root = createNode(filename);
@ -308,6 +309,7 @@ ActionTimelineNode* CSLoader::createActionTimelineNode(const std::string& filena
return node;
}
*/
@ -834,28 +836,15 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree)
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
{
Node* root = createNodeWithFlatBuffersFile(filePath);
reader->setPropsWithFlatBuffers(root, options->data());
bool isloop = projectNodeOptions->isLoop();
bool isautoplay = projectNodeOptions->isAutoPlay();
node = createNodeWithFlatBuffersFile(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
if (action)
{
root->runAction(action);
if (isautoplay)
{
action->gotoFrameAndPlay(0, isloop);
}
else
{
action->gotoFrameAndPause(0);
}
node->runAction(action);
}
node = ActionTimelineNode::create(root, action);
node->setName(root->getName());
}
}
else if (classname == "SimpleAudio")
@ -1183,21 +1172,10 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree *nod
node = createNodeWithFlatBuffersForSimulator(filePath);
reader->setPropsWithFlatBuffers(node, options->data());
bool isloop = projectNodeOptions->isLoop();
bool isautoplay = projectNodeOptions->isAutoPlay();
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersFile(filePath);
cocostudio::timeline::ActionTimeline* action = cocostudio::timeline::ActionTimelineCache::getInstance()->createActionWithFlatBuffersForSimulator(filePath);
if (action)
{
node->runAction(action);
action->gotoFrameAndPlay(0);
if (isautoplay)
{
action->gotoFrameAndPlay(0, isloop);
}
else
{
action->gotoFrameAndPause(0);
}
}
}
}

View File

@ -77,8 +77,10 @@ public:
static cocos2d::Node* createNode(const std::string& filename);
static cocostudio::timeline::ActionTimeline* createTimeline(const std::string& filename);
/*
static cocostudio::timeline::ActionTimelineNode* createActionTimelineNode(const std::string& filename);
static cocostudio::timeline::ActionTimelineNode* createActionTimelineNode(const std::string& filename, int startIndex, int endIndex, bool loop);
*/
cocos2d::Node* createNodeFromJson(const std::string& filename);
cocos2d::Node* loadNodeWithFile(const std::string& fileName);

View File

@ -33,15 +33,18 @@ struct ListViewOptions;
struct ProjectNodeOptions;
struct ComponentOptions;
struct ComAudioOptions;
struct AnimationInfo;
struct NodeAction;
struct TimeLine;
struct Frame;
struct TimeLineBoolFrame;
struct TimeLineIntFrame;
struct TimeLineStringFrame;
struct TimeLinePointFrame;
struct TimeLineColorFrame;
struct TimeLineTextureFrame;
struct PointFrame;
struct ScaleFrame;
struct ColorFrame;
struct TextureFrame;
struct EventFrame;
struct IntFrame;
struct BoolFrame;
struct InnerActionFrame;
struct RotationSkew;
struct Position;
struct Scale;
@ -177,7 +180,8 @@ struct CSParseBinary : private flatbuffers::Table {
const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *texturePngs() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>> *>(6); }
const NodeTree *nodeTree() const { return GetPointer<const NodeTree *>(8); }
const NodeAction *action() const { return GetPointer<const NodeAction *>(10); }
const flatbuffers::String *version() const { return GetPointer<const flatbuffers::String *>(12); }
const flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>> *animationList() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>> *>(12); }
const flatbuffers::String *version() const { return GetPointer<const flatbuffers::String *>(14); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* textures */) &&
@ -190,7 +194,10 @@ struct CSParseBinary : private flatbuffers::Table {
verifier.VerifyTable(nodeTree()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* action */) &&
verifier.VerifyTable(action()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* version */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* animationList */) &&
verifier.Verify(animationList()) &&
verifier.VerifyVectorOfTables(animationList()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* version */) &&
verifier.Verify(version()) &&
verifier.EndTable();
}
@ -203,11 +210,12 @@ struct CSParseBinaryBuilder {
void add_texturePngs(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> texturePngs) { fbb_.AddOffset(6, texturePngs); }
void add_nodeTree(flatbuffers::Offset<NodeTree> nodeTree) { fbb_.AddOffset(8, nodeTree); }
void add_action(flatbuffers::Offset<NodeAction> action) { fbb_.AddOffset(10, action); }
void add_version(flatbuffers::Offset<flatbuffers::String> version) { fbb_.AddOffset(12, version); }
void add_animationList(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>>> animationList) { fbb_.AddOffset(12, animationList); }
void add_version(flatbuffers::Offset<flatbuffers::String> version) { fbb_.AddOffset(14, version); }
CSParseBinaryBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
CSParseBinaryBuilder &operator=(const CSParseBinaryBuilder &);
flatbuffers::Offset<CSParseBinary> Finish() {
auto o = flatbuffers::Offset<CSParseBinary>(fbb_.EndTable(start_, 5));
auto o = flatbuffers::Offset<CSParseBinary>(fbb_.EndTable(start_, 6));
return o;
}
};
@ -217,9 +225,11 @@ inline flatbuffers::Offset<CSParseBinary> CreateCSParseBinary(flatbuffers::FlatB
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<flatbuffers::String>>> texturePngs = 0,
flatbuffers::Offset<NodeTree> nodeTree = 0,
flatbuffers::Offset<NodeAction> action = 0,
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<AnimationInfo>>> animationList = 0,
flatbuffers::Offset<flatbuffers::String> version = 0) {
CSParseBinaryBuilder builder_(_fbb);
builder_.add_version(version);
builder_.add_animationList(animationList);
builder_.add_action(action);
builder_.add_nodeTree(nodeTree);
builder_.add_texturePngs(texturePngs);
@ -1675,16 +1685,12 @@ inline flatbuffers::Offset<ListViewOptions> CreateListViewOptions(flatbuffers::F
struct ProjectNodeOptions : private flatbuffers::Table {
const WidgetOptions *nodeOptions() const { return GetPointer<const WidgetOptions *>(4); }
const flatbuffers::String *fileName() const { return GetPointer<const flatbuffers::String *>(6); }
uint8_t isLoop() const { return GetField<uint8_t>(8, 1); }
uint8_t isAutoPlay() const { return GetField<uint8_t>(10, 1); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* nodeOptions */) &&
verifier.VerifyTable(nodeOptions()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* fileName */) &&
verifier.Verify(fileName()) &&
VerifyField<uint8_t>(verifier, 8 /* isLoop */) &&
VerifyField<uint8_t>(verifier, 10 /* isAutoPlay */) &&
verifier.EndTable();
}
};
@ -1694,26 +1700,20 @@ struct ProjectNodeOptionsBuilder {
flatbuffers::uoffset_t start_;
void add_nodeOptions(flatbuffers::Offset<WidgetOptions> nodeOptions) { fbb_.AddOffset(4, nodeOptions); }
void add_fileName(flatbuffers::Offset<flatbuffers::String> fileName) { fbb_.AddOffset(6, fileName); }
void add_isLoop(uint8_t isLoop) { fbb_.AddElement<uint8_t>(8, isLoop, 1); }
void add_isAutoPlay(uint8_t isAutoPlay) { fbb_.AddElement<uint8_t>(10, isAutoPlay, 1); }
ProjectNodeOptionsBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
ProjectNodeOptionsBuilder &operator=(const ProjectNodeOptionsBuilder &);
flatbuffers::Offset<ProjectNodeOptions> Finish() {
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 4));
auto o = flatbuffers::Offset<ProjectNodeOptions>(fbb_.EndTable(start_, 2));
return o;
}
};
inline flatbuffers::Offset<ProjectNodeOptions> CreateProjectNodeOptions(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<WidgetOptions> nodeOptions = 0,
flatbuffers::Offset<flatbuffers::String> fileName = 0,
uint8_t isLoop = 1,
uint8_t isAutoPlay = 1) {
flatbuffers::Offset<flatbuffers::String> fileName = 0) {
ProjectNodeOptionsBuilder builder_(_fbb);
builder_.add_fileName(fileName);
builder_.add_nodeOptions(nodeOptions);
builder_.add_isAutoPlay(isAutoPlay);
builder_.add_isLoop(isLoop);
return builder_.Finish();
}
@ -1814,10 +1814,50 @@ inline flatbuffers::Offset<ComAudioOptions> CreateComAudioOptions(flatbuffers::F
return builder_.Finish();
}
struct AnimationInfo : private flatbuffers::Table {
const flatbuffers::String *name() const { return GetPointer<const flatbuffers::String *>(4); }
int32_t startIndex() const { return GetField<int32_t>(6, 0); }
int32_t endIndex() const { return GetField<int32_t>(8, 0); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* name */) &&
verifier.Verify(name()) &&
VerifyField<int32_t>(verifier, 6 /* startIndex */) &&
VerifyField<int32_t>(verifier, 8 /* endIndex */) &&
verifier.EndTable();
}
};
struct AnimationInfoBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_name(flatbuffers::Offset<flatbuffers::String> name) { fbb_.AddOffset(4, name); }
void add_startIndex(int32_t startIndex) { fbb_.AddElement<int32_t>(6, startIndex, 0); }
void add_endIndex(int32_t endIndex) { fbb_.AddElement<int32_t>(8, endIndex, 0); }
AnimationInfoBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
AnimationInfoBuilder &operator=(const AnimationInfoBuilder &);
flatbuffers::Offset<AnimationInfo> Finish() {
auto o = flatbuffers::Offset<AnimationInfo>(fbb_.EndTable(start_, 3));
return o;
}
};
inline flatbuffers::Offset<AnimationInfo> CreateAnimationInfo(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::String> name = 0,
int32_t startIndex = 0,
int32_t endIndex = 0) {
AnimationInfoBuilder builder_(_fbb);
builder_.add_endIndex(endIndex);
builder_.add_startIndex(startIndex);
builder_.add_name(name);
return builder_.Finish();
}
struct NodeAction : private flatbuffers::Table {
int32_t duration() const { return GetField<int32_t>(4, 0); }
float speed() const { return GetField<float>(6, 0); }
const flatbuffers::Vector<flatbuffers::Offset<TimeLine>> *timeLines() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<TimeLine>> *>(8); }
const flatbuffers::String *currentAnimationName() const { return GetPointer<const flatbuffers::String *>(10); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<int32_t>(verifier, 4 /* duration */) &&
@ -1825,6 +1865,8 @@ struct NodeAction : private flatbuffers::Table {
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* timeLines */) &&
verifier.Verify(timeLines()) &&
verifier.VerifyVectorOfTables(timeLines()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* currentAnimationName */) &&
verifier.Verify(currentAnimationName()) &&
verifier.EndTable();
}
};
@ -1835,10 +1877,11 @@ struct NodeActionBuilder {
void add_duration(int32_t duration) { fbb_.AddElement<int32_t>(4, duration, 0); }
void add_speed(float speed) { fbb_.AddElement<float>(6, speed, 0); }
void add_timeLines(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TimeLine>>> timeLines) { fbb_.AddOffset(8, timeLines); }
void add_currentAnimationName(flatbuffers::Offset<flatbuffers::String> currentAnimationName) { fbb_.AddOffset(10, currentAnimationName); }
NodeActionBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
NodeActionBuilder &operator=(const NodeActionBuilder &);
flatbuffers::Offset<NodeAction> Finish() {
auto o = flatbuffers::Offset<NodeAction>(fbb_.EndTable(start_, 3));
auto o = flatbuffers::Offset<NodeAction>(fbb_.EndTable(start_, 4));
return o;
}
};
@ -1846,8 +1889,10 @@ struct NodeActionBuilder {
inline flatbuffers::Offset<NodeAction> CreateNodeAction(flatbuffers::FlatBufferBuilder &_fbb,
int32_t duration = 0,
float speed = 0,
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TimeLine>>> timeLines = 0) {
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<TimeLine>>> timeLines = 0,
flatbuffers::Offset<flatbuffers::String> currentAnimationName = 0) {
NodeActionBuilder builder_(_fbb);
builder_.add_currentAnimationName(currentAnimationName);
builder_.add_timeLines(timeLines);
builder_.add_speed(speed);
builder_.add_duration(duration);
@ -1855,13 +1900,13 @@ inline flatbuffers::Offset<NodeAction> CreateNodeAction(flatbuffers::FlatBufferB
}
struct TimeLine : private flatbuffers::Table {
const flatbuffers::String *frameType() const { return GetPointer<const flatbuffers::String *>(4); }
const flatbuffers::String *property() const { return GetPointer<const flatbuffers::String *>(4); }
int32_t actionTag() const { return GetField<int32_t>(6, 0); }
const flatbuffers::Vector<flatbuffers::Offset<Frame>> *frames() const { return GetPointer<const flatbuffers::Vector<flatbuffers::Offset<Frame>> *>(8); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* frameType */) &&
verifier.Verify(frameType()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* property */) &&
verifier.Verify(property()) &&
VerifyField<int32_t>(verifier, 6 /* actionTag */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* frames */) &&
verifier.Verify(frames()) &&
@ -1873,7 +1918,7 @@ struct TimeLine : private flatbuffers::Table {
struct TimeLineBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_frameType(flatbuffers::Offset<flatbuffers::String> frameType) { fbb_.AddOffset(4, frameType); }
void add_property(flatbuffers::Offset<flatbuffers::String> property) { fbb_.AddOffset(4, property); }
void add_actionTag(int32_t actionTag) { fbb_.AddElement<int32_t>(6, actionTag, 0); }
void add_frames(flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Frame>>> frames) { fbb_.AddOffset(8, frames); }
TimeLineBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
@ -1885,46 +1930,43 @@ struct TimeLineBuilder {
};
inline flatbuffers::Offset<TimeLine> CreateTimeLine(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<flatbuffers::String> frameType = 0,
flatbuffers::Offset<flatbuffers::String> property = 0,
int32_t actionTag = 0,
flatbuffers::Offset<flatbuffers::Vector<flatbuffers::Offset<Frame>>> frames = 0) {
TimeLineBuilder builder_(_fbb);
builder_.add_frames(frames);
builder_.add_actionTag(actionTag);
builder_.add_frameType(frameType);
builder_.add_property(property);
return builder_.Finish();
}
struct Frame : private flatbuffers::Table {
const TimeLineBoolFrame *visibleFrame() const { return GetPointer<const TimeLineBoolFrame *>(4); }
const TimeLineIntFrame *zOrderFrame() const { return GetPointer<const TimeLineIntFrame *>(6); }
const TimeLinePointFrame *rotationSkewFrame() const { return GetPointer<const TimeLinePointFrame *>(8); }
const TimeLineStringFrame *eventFrame() const { return GetPointer<const TimeLineStringFrame *>(10); }
const TimeLinePointFrame *anchorPointFrame() const { return GetPointer<const TimeLinePointFrame *>(12); }
const TimeLinePointFrame *positionFrame() const { return GetPointer<const TimeLinePointFrame *>(14); }
const TimeLinePointFrame *scaleFrame() const { return GetPointer<const TimeLinePointFrame *>(16); }
const TimeLineColorFrame *colorFrame() const { return GetPointer<const TimeLineColorFrame *>(18); }
const TimeLineTextureFrame *textureFrame() const { return GetPointer<const TimeLineTextureFrame *>(20); }
const PointFrame *pointFrame() const { return GetPointer<const PointFrame *>(4); }
const ScaleFrame *scaleFrame() const { return GetPointer<const ScaleFrame *>(6); }
const ColorFrame *colorFrame() const { return GetPointer<const ColorFrame *>(8); }
const TextureFrame *textureFrame() const { return GetPointer<const TextureFrame *>(10); }
const EventFrame *eventFrame() const { return GetPointer<const EventFrame *>(12); }
const IntFrame *intFrame() const { return GetPointer<const IntFrame *>(14); }
const BoolFrame *boolFrame() const { return GetPointer<const BoolFrame *>(16); }
const InnerActionFrame *innerActionFrame() const { return GetPointer<const InnerActionFrame *>(18); }
bool Verify(flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* visibleFrame */) &&
verifier.VerifyTable(visibleFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* zOrderFrame */) &&
verifier.VerifyTable(zOrderFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* rotationSkewFrame */) &&
verifier.VerifyTable(rotationSkewFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* eventFrame */) &&
verifier.VerifyTable(eventFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* anchorPointFrame */) &&
verifier.VerifyTable(anchorPointFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* positionFrame */) &&
verifier.VerifyTable(positionFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 16 /* scaleFrame */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 4 /* pointFrame */) &&
verifier.VerifyTable(pointFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 6 /* scaleFrame */) &&
verifier.VerifyTable(scaleFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 18 /* colorFrame */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 8 /* colorFrame */) &&
verifier.VerifyTable(colorFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 20 /* textureFrame */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* textureFrame */) &&
verifier.VerifyTable(textureFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 12 /* eventFrame */) &&
verifier.VerifyTable(eventFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 14 /* intFrame */) &&
verifier.VerifyTable(intFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 16 /* boolFrame */) &&
verifier.VerifyTable(boolFrame()) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 18 /* innerActionFrame */) &&
verifier.VerifyTable(innerActionFrame()) &&
verifier.EndTable();
}
};
@ -1932,123 +1974,197 @@ struct Frame : private flatbuffers::Table {
struct FrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
void add_visibleFrame(flatbuffers::Offset<TimeLineBoolFrame> visibleFrame) { fbb_.AddOffset(4, visibleFrame); }
void add_zOrderFrame(flatbuffers::Offset<TimeLineIntFrame> zOrderFrame) { fbb_.AddOffset(6, zOrderFrame); }
void add_rotationSkewFrame(flatbuffers::Offset<TimeLinePointFrame> rotationSkewFrame) { fbb_.AddOffset(8, rotationSkewFrame); }
void add_eventFrame(flatbuffers::Offset<TimeLineStringFrame> eventFrame) { fbb_.AddOffset(10, eventFrame); }
void add_anchorPointFrame(flatbuffers::Offset<TimeLinePointFrame> anchorPointFrame) { fbb_.AddOffset(12, anchorPointFrame); }
void add_positionFrame(flatbuffers::Offset<TimeLinePointFrame> positionFrame) { fbb_.AddOffset(14, positionFrame); }
void add_scaleFrame(flatbuffers::Offset<TimeLinePointFrame> scaleFrame) { fbb_.AddOffset(16, scaleFrame); }
void add_colorFrame(flatbuffers::Offset<TimeLineColorFrame> colorFrame) { fbb_.AddOffset(18, colorFrame); }
void add_textureFrame(flatbuffers::Offset<TimeLineTextureFrame> textureFrame) { fbb_.AddOffset(20, textureFrame); }
void add_pointFrame(flatbuffers::Offset<PointFrame> pointFrame) { fbb_.AddOffset(4, pointFrame); }
void add_scaleFrame(flatbuffers::Offset<ScaleFrame> scaleFrame) { fbb_.AddOffset(6, scaleFrame); }
void add_colorFrame(flatbuffers::Offset<ColorFrame> colorFrame) { fbb_.AddOffset(8, colorFrame); }
void add_textureFrame(flatbuffers::Offset<TextureFrame> textureFrame) { fbb_.AddOffset(10, textureFrame); }
void add_eventFrame(flatbuffers::Offset<EventFrame> eventFrame) { fbb_.AddOffset(12, eventFrame); }
void add_intFrame(flatbuffers::Offset<IntFrame> intFrame) { fbb_.AddOffset(14, intFrame); }
void add_boolFrame(flatbuffers::Offset<BoolFrame> boolFrame) { fbb_.AddOffset(16, boolFrame); }
void add_innerActionFrame(flatbuffers::Offset<InnerActionFrame> innerActionFrame) { fbb_.AddOffset(18, innerActionFrame); }
FrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
FrameBuilder &operator=(const FrameBuilder &);
flatbuffers::Offset<Frame> Finish() {
auto o = flatbuffers::Offset<Frame>(fbb_.EndTable(start_, 9));
auto o = flatbuffers::Offset<Frame>(fbb_.EndTable(start_, 8));
return o;
}
};
inline flatbuffers::Offset<Frame> CreateFrame(flatbuffers::FlatBufferBuilder &_fbb,
flatbuffers::Offset<TimeLineBoolFrame> visibleFrame = 0,
flatbuffers::Offset<TimeLineIntFrame> zOrderFrame = 0,
flatbuffers::Offset<TimeLinePointFrame> rotationSkewFrame = 0,
flatbuffers::Offset<TimeLineStringFrame> eventFrame = 0,
flatbuffers::Offset<TimeLinePointFrame> anchorPointFrame = 0,
flatbuffers::Offset<TimeLinePointFrame> positionFrame = 0,
flatbuffers::Offset<TimeLinePointFrame> scaleFrame = 0,
flatbuffers::Offset<TimeLineColorFrame> colorFrame = 0,
flatbuffers::Offset<TimeLineTextureFrame> textureFrame = 0) {
flatbuffers::Offset<PointFrame> pointFrame = 0,
flatbuffers::Offset<ScaleFrame> scaleFrame = 0,
flatbuffers::Offset<ColorFrame> colorFrame = 0,
flatbuffers::Offset<TextureFrame> textureFrame = 0,
flatbuffers::Offset<EventFrame> eventFrame = 0,
flatbuffers::Offset<IntFrame> intFrame = 0,
flatbuffers::Offset<BoolFrame> boolFrame = 0,
flatbuffers::Offset<InnerActionFrame> innerActionFrame = 0) {
FrameBuilder builder_(_fbb);
builder_.add_innerActionFrame(innerActionFrame);
builder_.add_boolFrame(boolFrame);
builder_.add_intFrame(intFrame);
builder_.add_eventFrame(eventFrame);
builder_.add_textureFrame(textureFrame);
builder_.add_colorFrame(colorFrame);
builder_.add_scaleFrame(scaleFrame);
builder_.add_positionFrame(positionFrame);
builder_.add_anchorPointFrame(anchorPointFrame);
builder_.add_eventFrame(eventFrame);
builder_.add_rotationSkewFrame(rotationSkewFrame);
builder_.add_zOrderFrame(zOrderFrame);
builder_.add_visibleFrame(visibleFrame);
builder_.add_pointFrame(pointFrame);
return builder_.Finish();
}
struct TimeLineBoolFrame : private flatbuffers::Table {
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); }
uint8_t value() const { return GetField<uint8_t>(8, 0); }
const Position *postion() const { return GetStruct<const Position *>(8); }
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<Position>(verifier, 8 /* postion */) &&
verifier.EndTable();
}
};
struct TimeLineBoolFrameBuilder {
struct PointFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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, 0); }
TimeLineBoolFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
TimeLineBoolFrameBuilder &operator=(const TimeLineBoolFrameBuilder &);
flatbuffers::Offset<TimeLineBoolFrame> Finish() {
auto o = flatbuffers::Offset<TimeLineBoolFrame>(fbb_.EndTable(start_, 3));
void add_postion(const Position *postion) { fbb_.AddStruct(8, postion); }
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));
return o;
}
};
inline flatbuffers::Offset<TimeLineBoolFrame> CreateTimeLineBoolFrame(flatbuffers::FlatBufferBuilder &_fbb,
inline flatbuffers::Offset<PointFrame> CreatePointFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
uint8_t value = 0) {
TimeLineBoolFrameBuilder builder_(_fbb);
builder_.add_frameIndex(frameIndex);
builder_.add_value(value);
builder_.add_tween(tween);
return builder_.Finish();
}
struct TimeLineIntFrame : 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); }
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 */) &&
verifier.EndTable();
}
};
struct TimeLineIntFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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); }
TimeLineIntFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
TimeLineIntFrameBuilder &operator=(const TimeLineIntFrameBuilder &);
flatbuffers::Offset<TimeLineIntFrame> Finish() {
auto o = flatbuffers::Offset<TimeLineIntFrame>(fbb_.EndTable(start_, 3));
return o;
}
};
inline flatbuffers::Offset<TimeLineIntFrame> CreateTimeLineIntFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
int32_t value = 0) {
TimeLineIntFrameBuilder builder_(_fbb);
builder_.add_value(value);
const Position *postion = 0) {
PointFrameBuilder builder_(_fbb);
builder_.add_postion(postion);
builder_.add_frameIndex(frameIndex);
builder_.add_tween(tween);
return builder_.Finish();
}
struct TimeLineStringFrame : private flatbuffers::Table {
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); }
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 */) &&
verifier.EndTable();
}
};
struct ScaleFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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); }
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));
return o;
}
};
inline flatbuffers::Offset<ScaleFrame> CreateScaleFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
const Scale *scale = 0) {
ScaleFrameBuilder builder_(_fbb);
builder_.add_scale(scale);
builder_.add_frameIndex(frameIndex);
builder_.add_tween(tween);
return builder_.Finish();
}
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); }
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 */) &&
verifier.EndTable();
}
};
struct ColorFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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); }
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));
return o;
}
};
inline flatbuffers::Offset<ColorFrame> CreateColorFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
const Color *color = 0) {
ColorFrameBuilder builder_(_fbb);
builder_.add_color(color);
builder_.add_frameIndex(frameIndex);
builder_.add_tween(tween);
return builder_.Finish();
}
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); }
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()) &&
verifier.EndTable();
}
};
struct TextureFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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); }
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));
return o;
}
};
inline flatbuffers::Offset<TextureFrame> CreateTextureFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
flatbuffers::Offset<ResourceData> textureFile = 0) {
TextureFrameBuilder builder_(_fbb);
builder_.add_textureFile(textureFile);
builder_.add_frameIndex(frameIndex);
builder_.add_tween(tween);
return builder_.Finish();
}
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); }
@ -2062,141 +2178,151 @@ struct TimeLineStringFrame : private flatbuffers::Table {
}
};
struct TimeLineStringFrameBuilder {
struct EventFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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); }
TimeLineStringFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
TimeLineStringFrameBuilder &operator=(const TimeLineStringFrameBuilder &);
flatbuffers::Offset<TimeLineStringFrame> Finish() {
auto o = flatbuffers::Offset<TimeLineStringFrame>(fbb_.EndTable(start_, 3));
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));
return o;
}
};
inline flatbuffers::Offset<TimeLineStringFrame> CreateTimeLineStringFrame(flatbuffers::FlatBufferBuilder &_fbb,
inline flatbuffers::Offset<EventFrame> CreateEventFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
flatbuffers::Offset<flatbuffers::String> value = 0) {
TimeLineStringFrameBuilder builder_(_fbb);
EventFrameBuilder builder_(_fbb);
builder_.add_value(value);
builder_.add_frameIndex(frameIndex);
builder_.add_tween(tween);
return builder_.Finish();
}
struct TimeLinePointFrame : private flatbuffers::Table {
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); }
const Position *postion() const { return GetStruct<const Position *>(8); }
int32_t value() const { return GetField<int32_t>(8, 0); }
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<int32_t>(verifier, 8 /* value */) &&
verifier.EndTable();
}
};
struct TimeLinePointFrameBuilder {
struct IntFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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); }
TimeLinePointFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
TimeLinePointFrameBuilder &operator=(const TimeLinePointFrameBuilder &);
flatbuffers::Offset<TimeLinePointFrame> Finish() {
auto o = flatbuffers::Offset<TimeLinePointFrame>(fbb_.EndTable(start_, 3));
void add_value(int32_t value) { fbb_.AddElement<int32_t>(8, value, 0); }
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));
return o;
}
};
inline flatbuffers::Offset<TimeLinePointFrame> CreateTimeLinePointFrame(flatbuffers::FlatBufferBuilder &_fbb,
inline flatbuffers::Offset<IntFrame> CreateIntFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
const Position *postion = 0) {
TimeLinePointFrameBuilder builder_(_fbb);
builder_.add_postion(postion);
int32_t value = 0) {
IntFrameBuilder builder_(_fbb);
builder_.add_value(value);
builder_.add_frameIndex(frameIndex);
builder_.add_tween(tween);
return builder_.Finish();
}
struct TimeLineColorFrame : private flatbuffers::Table {
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); }
const Color *color() const { return GetStruct<const Color *>(8); }
uint8_t value() const { return GetField<uint8_t>(8, 1); }
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<uint8_t>(verifier, 8 /* value */) &&
verifier.EndTable();
}
};
struct TimeLineColorFrameBuilder {
struct BoolFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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); }
TimeLineColorFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
TimeLineColorFrameBuilder &operator=(const TimeLineColorFrameBuilder &);
flatbuffers::Offset<TimeLineColorFrame> Finish() {
auto o = flatbuffers::Offset<TimeLineColorFrame>(fbb_.EndTable(start_, 3));
void add_value(uint8_t value) { fbb_.AddElement<uint8_t>(8, value, 1); }
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));
return o;
}
};
inline flatbuffers::Offset<TimeLineColorFrame> CreateTimeLineColorFrame(flatbuffers::FlatBufferBuilder &_fbb,
inline flatbuffers::Offset<BoolFrame> CreateBoolFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
const Color *color = 0) {
TimeLineColorFrameBuilder builder_(_fbb);
builder_.add_color(color);
uint8_t value = 1) {
BoolFrameBuilder builder_(_fbb);
builder_.add_frameIndex(frameIndex);
builder_.add_value(value);
builder_.add_tween(tween);
return builder_.Finish();
}
struct TimeLineTextureFrame : private flatbuffers::Table {
struct InnerActionFrame : 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 *fileNameData() const { return GetPointer<const ResourceData *>(8); }
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); }
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 /* fileNameData */) &&
verifier.VerifyTable(fileNameData()) &&
VerifyField<int32_t>(verifier, 8 /* innerActionType */) &&
VerifyField<flatbuffers::uoffset_t>(verifier, 10 /* currentAniamtionName */) &&
verifier.Verify(currentAniamtionName()) &&
VerifyField<int32_t>(verifier, 12 /* singleFrameIndex */) &&
verifier.EndTable();
}
};
struct TimeLineTextureFrameBuilder {
struct InnerActionFrameBuilder {
flatbuffers::FlatBufferBuilder &fbb_;
flatbuffers::uoffset_t start_;
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_fileNameData(flatbuffers::Offset<ResourceData> fileNameData) { fbb_.AddOffset(8, fileNameData); }
TimeLineTextureFrameBuilder(flatbuffers::FlatBufferBuilder &_fbb) : fbb_(_fbb) { start_ = fbb_.StartTable(); }
TimeLineTextureFrameBuilder &operator=(const TimeLineTextureFrameBuilder &);
flatbuffers::Offset<TimeLineTextureFrame> Finish() {
auto o = flatbuffers::Offset<TimeLineTextureFrame>(fbb_.EndTable(start_, 3));
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); }
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));
return o;
}
};
inline flatbuffers::Offset<TimeLineTextureFrame> CreateTimeLineTextureFrame(flatbuffers::FlatBufferBuilder &_fbb,
inline flatbuffers::Offset<InnerActionFrame> CreateInnerActionFrame(flatbuffers::FlatBufferBuilder &_fbb,
int32_t frameIndex = 0,
uint8_t tween = 1,
flatbuffers::Offset<ResourceData> fileNameData = 0) {
TimeLineTextureFrameBuilder builder_(_fbb);
builder_.add_fileNameData(fileNameData);
int32_t innerActionType = 0,
flatbuffers::Offset<flatbuffers::String> currentAniamtionName = 0,
int32_t singleFrameIndex = 0) {
InnerActionFrameBuilder builder_(_fbb);
builder_.add_singleFrameIndex(singleFrameIndex);
builder_.add_currentAniamtionName(currentAniamtionName);
builder_.add_innerActionType(innerActionType);
builder_.add_frameIndex(frameIndex);
builder_.add_tween(tween);
return builder_.Finish();

View File

@ -68,15 +68,16 @@ using namespace flatbuffers;
namespace cocostudio {
static const char* FrameType_VisibleFrame = "VisibleFrame";
static const char* FrameType_PositionFrame = "PositionFrame";
static const char* FrameType_ScaleFrame = "ScaleFrame";
static const char* FrameType_RotationSkewFrame = "RotationSkewFrame";
static const char* FrameType_AnchorFrame = "AnchorPointFrame";
static const char* FrameType_ColorFrame = "ColorFrame";
static const char* FrameType_TextureFrame = "TextureFrame";
static const char* FrameType_EventFrame = "EventFrame";
static const char* FrameType_ZOrderFrame = "ZOrderFrame";
static const char* Property_VisibleForFrame = "VisibleForFrame";
static const char* Property_Position = "Position";
static const char* Property_Scale = "Scale";
static const char* Property_RotationSkew = "RotationSkew";
static const char* Property_CColor = "CColor";
static const char* Property_FileData = "FileData";
static const char* Property_FrameEvent = "FrameEvent";
static const char* Property_Alpha = "Alpha";
static const char* Property_ZOrder = "ZOrder";
static const char* Property_ActionValue = "ActionValue";
static FlatBuffersSerialize* _instanceFlatBuffersSerialize = nullptr;
@ -232,7 +233,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
Offset<NodeTree> nodeTree;
Offset<NodeAction> aciton;
std::vector<Offset<flatbuffers::AnimationInfo>> animationInfos;
const tinyxml2::XMLElement* child = element->FirstChildElement();
@ -250,15 +251,26 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFile(const std::str
const tinyxml2::XMLElement* objectData = child;
nodeTree = createNodeTree(objectData, rootType);
}
else if (name == "AnimationList") // animation list
{
const tinyxml2::XMLElement* animationinfoElement = child->FirstChildElement();
while (animationinfoElement)
{
auto animationinfo = createAnimationInfo(animationinfoElement);
animationInfos.push_back(animationinfo);
animationinfoElement = animationinfoElement->NextSiblingElement();
}
}
child = child->NextSiblingElement();
}
auto csparsebinary = CreateCSParseBinary(*_builder,
_builder->CreateVector(_textures),
_builder->CreateVector(_texturePngs),
nodeTree,
aciton,
_builder->CreateVector(animationInfos),
_builder->CreateString(_csdVersion));
_builder->Finish(csparsebinary);
@ -514,6 +526,7 @@ Offset<NodeAction> FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle
{
int duration = 0;
float speed = 0.0f;
std::string currentAnimationName = "";
// CCLOG("animation name = %s", objectData->Name());
@ -534,6 +547,10 @@ Offset<NodeAction> FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle
{
speed = atof(value.c_str());
}
else if (name == "ActivedAnimationName")
{
currentAnimationName = value.c_str();
}
attribute = attribute->Next();
}
@ -552,13 +569,43 @@ Offset<NodeAction> FlatBuffersSerialize::createNodeAction(const tinyxml2::XMLEle
return CreateNodeAction(*_builder,
duration,
speed,
_builder->CreateVector(timelines));
_builder->CreateVector(timelines),
_builder->CreateString(currentAnimationName));
}
Offset<flatbuffers::AnimationInfo> FlatBuffersSerialize::createAnimationInfo(const tinyxml2::XMLElement *objectData)
{
std::string infoName = "";
int startIndex = 0;
int endIndex = 0;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string attrivalue = attribute->Value();
if (attriname == "Name")
{
infoName = attrivalue;
}
else if (attriname == "StartIndex")
{
startIndex = atoi(attrivalue.c_str());
}
else if (attriname == "EndIndex")
{
endIndex = atoi(attrivalue.c_str());
}
attribute = attribute->Next();
}
return CreateAnimationInfo(*_builder, _builder->CreateString(infoName), startIndex, endIndex);
}
Offset<TimeLine> FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement *objectData)
{
int actionTag = 0;
std::string frameType = "";
std::string property = "";
// TimelineData attrsibutes
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
@ -571,9 +618,9 @@ Offset<TimeLine> FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement
{
actionTag = atoi(value.c_str());
}
else if (name == "FrameType")
else if (name == "Property")
{
frameType = value;
property = value;
}
attribute = attribute->Next();
@ -587,210 +634,113 @@ Offset<TimeLine> FlatBuffersSerialize::createTimeLine(const tinyxml2::XMLElement
{
Offset<flatbuffers::Frame> frame;
if (frameType == FrameType_VisibleFrame)
if (property == Property_VisibleForFrame)
{
auto visibleFrame = createTimeLineBoolFrame(frameElement);
auto boolFrame = createBoolFrame(frameElement);
frame = CreateFrame(*_builder,
visibleFrame);
}
else if (frameType == FrameType_ZOrderFrame)
{
auto zOrderFrame = createTimeLineIntFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
zOrderFrame);
}
else if (frameType == FrameType_RotationSkewFrame)
{
auto rotationSkewFrame = createTimeLinePointFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
0, // ZOrderFrame
rotationSkewFrame);
}
else if (frameType == FrameType_EventFrame)
{
auto eventFrame = createTimeLineStringFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
0, // ZOrderFrame
0, // RotationSkewFrame
eventFrame);
}
else if (frameType == FrameType_AnchorFrame)
{
auto anchorPointFrame = createTimeLinePointFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
0, // ZOrderFrame
0, // RotationSkewFrame
0, // PointFrame
0, // ScaleFrame
0, // ColorFrame
0, // TextureFrame
0, // EventFrame
anchorPointFrame);
0, // IntFrame
boolFrame);
}
else if (frameType == FrameType_PositionFrame)
else if (property == Property_Position)
{
auto positionFrame = createTimeLinePointFrame(frameElement);
auto pointFrame = createPointFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
0, // ZOrderFrame
0, // RotationSkewFrame
0, // EventFrame
0, // AnchorPointFrame
positionFrame);
pointFrame);
}
else if (frameType == FrameType_ScaleFrame)
else if (property == Property_Scale)
{
auto scaleFrame = createTimeLinePointFrame(frameElement);
auto scaleFrame = createScaleFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
0, // ZOrderFrame
0, // RotationSkewFrame
0, // EventFrame
0, // AnchorPointFrame
0, // PositionFrame
0, // PointFrame
scaleFrame);
}
else if (frameType == FrameType_ColorFrame)
else if (property == Property_RotationSkew)
{
auto colorFrame = createTimeLineColorFrame(frameElement);
auto scaleFrame = createScaleFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
0, // ZOrderFrame
0, // RotationSkewFrame
0, // EventFrame
0, // AnchorPointFrame
0, // PositionFrame
0, // PointFrame
scaleFrame);
}
else if (property == Property_CColor)
{
auto colorFrame = createColorFrame(frameElement);
frame = CreateFrame(*_builder,
0, // PointFrame
0, // ScaleFrame
colorFrame);
}
else if (frameType == FrameType_TextureFrame)
else if (property == Property_FileData)
{
auto textureFrame = createTimeLineTextureFrame(frameElement);
auto textureFrame = createTextureFrame(frameElement);
frame = CreateFrame(*_builder,
0, // VisibleFrame
0, // ZOrderFrame
0, // RotationSkewFrame
0, // EventFrame
0, // AnchorPointFrame
0, // PositionFrame
0, // PointFrame
0, // ScaleFrame
0, // ColorFrame
textureFrame);
}
else if (property == Property_FrameEvent)
{
auto eventFrame = createEventFrame(frameElement);
frame = CreateFrame(*_builder,
0, // PointFrame
0, // ScaleFrame
0, // ColorFrame
0, // TextureFrame
eventFrame);
}
else if (property == Property_Alpha)
{
auto intFrame = createIntFrame(frameElement);
frame = CreateFrame(*_builder,
0, // PointFrame
0, // ScaleFrame
0, // ColorFrame
0, // TextureFrame
0, // EventFrame
intFrame);
}
else if (property == Property_ZOrder)
{
auto intFrame = createIntFrame(frameElement);
frame = CreateFrame(*_builder,
0, // PointFrame
0, // ScaleFrame
0, // ColorFrame
0, // TextureFrame
0, // EventFrame
intFrame);
}
else if (property == Property_ActionValue)
{
auto innerActionFrame = createInnerActionFrame(frameElement);
frame = CreateFrame(*_builder,
0, // PointFrame
0, // ScaleFrame
0, // ColorFrame
0, // TextureFrame
0, // EventFrame
0, // IntFrame
0, // BoolFrame
innerActionFrame);
}
frames.push_back(frame);
frameElement = frameElement->NextSiblingElement();
}
return CreateTimeLine(*_builder,
_builder->CreateString(frameType),
_builder->CreateString(property),
actionTag,
_builder->CreateVector(frames));
}
Offset<TimeLineBoolFrame> FlatBuffersSerialize::createTimeLineBoolFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
bool value = false;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string name = attribute->Name();
std::string attrivalue = attribute->Value();
if (name == "Value")
{
value = (attrivalue == "True") ? true : false;
}
else if (name == "FrameIndex")
{
frameIndex = atoi(attrivalue.c_str());
}
else if (name == "Tween")
{
tween = atoi(attrivalue.c_str());
}
attribute = attribute->Next();
}
return CreateTimeLineBoolFrame(*_builder,
frameIndex,
tween,
value);
}
Offset<TimeLineIntFrame> FlatBuffersSerialize::createTimeLineIntFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
int value = 0;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string name = attribute->Name();
std::string attrivalue = attribute->Value();
if (name == "Value") // to be gonna modify
{
value = atoi(attrivalue.c_str());
}
else if (name == "FrameIndex")
{
frameIndex = atoi(attrivalue.c_str());
}
else if (name == "Tween")
{
tween = (attrivalue == "True") ? true : false;
}
attribute = attribute->Next();
}
return CreateTimeLineIntFrame(*_builder,
frameIndex,
tween,
value);
}
Offset<TimeLineStringFrame> FlatBuffersSerialize::createTimeLineStringFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
std::string value = "";
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string name = attribute->Name();
std::string attrivalue = attribute->Value();
if (name == "Value") // to be gonna modify
{
value = attrivalue;
}
else if (name == "FrameIndex")
{
frameIndex = atoi(attrivalue.c_str());
}
else if (name == "Tween")
{
tween = (attrivalue == "True") ? true : false;
}
attribute = attribute->Next();
}
return CreateTimeLineStringFrame(*_builder,
frameIndex,
tween,
_builder->CreateString(value));
}
Offset<TimeLinePointFrame> FlatBuffersSerialize::createTimeLinePointFrame(const tinyxml2::XMLElement *objectData)
Offset<flatbuffers::PointFrame> FlatBuffersSerialize::createPointFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
@ -824,17 +774,57 @@ Offset<TimeLinePointFrame> FlatBuffersSerialize::createTimeLinePointFrame(const
Position f_position(position.x, position.y);
return CreateTimeLinePointFrame(*_builder,
frameIndex,
tween,
&f_position);
return CreatePointFrame(*_builder,
frameIndex,
tween,
&f_position);
}
Offset<TimeLineColorFrame> FlatBuffersSerialize::createTimeLineColorFrame(const tinyxml2::XMLElement *objectData)
Offset<flatbuffers::ScaleFrame> FlatBuffersSerialize::createScaleFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
Color4B color;
Vec2 scale;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string name = attribute->Name();
std::string value = attribute->Value();
if (name == "X")
{
scale.x = atof(value.c_str());
}
else if (name == "Y")
{
scale.y = atof(value.c_str());
}
else if (name == "FrameIndex")
{
frameIndex = atoi(value.c_str());
}
else if (name == "Tween")
{
tween = (value == "True") ? true : false;
}
attribute = attribute->Next();
}
Scale f_scale(scale.x, scale.y);
return CreateScaleFrame(*_builder,
frameIndex,
tween,
&f_scale);
}
Offset<flatbuffers::ColorFrame> FlatBuffersSerialize::createColorFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
Color3B color;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
@ -846,10 +836,6 @@ Offset<TimeLineColorFrame> FlatBuffersSerialize::createTimeLineColorFrame(const
{
frameIndex = atoi(value.c_str());
}
else if (name == "Alpha")
{
color.a = atoi(value.c_str());
}
else if (name == "Tween")
{
tween = (value == "True") ? true : false;
@ -887,85 +873,244 @@ Offset<TimeLineColorFrame> FlatBuffersSerialize::createTimeLineColorFrame(const
child = child->NextSiblingElement();
}
Color f_color(color.a, color.r, color.g, color.b);
Color f_color(255, color.r, color.g, color.b);
return CreateTimeLineColorFrame(*_builder,
frameIndex,
tween,
&f_color);
return CreateColorFrame(*_builder,
frameIndex,
tween,
&f_color);
}
Offset<TimeLineTextureFrame> FlatBuffersSerialize::createTimeLineTextureFrame(const tinyxml2::XMLElement *objectData)
Offset<flatbuffers::TextureFrame> FlatBuffersSerialize::createTextureFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
std::string path = "";
std::string plistFile = "";
int resourceType = 0;
std::string texture = "";
std::string texturePng = "";
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
int frameIndex = 0;
bool tween = true;
std::string attriname = attribute->Name();
std::string value = attribute->Value();
std::string path = "";
std::string plistFile = "";
int resourceType = 0;
if (attriname == "FrameIndex")
{
frameIndex = atoi(value.c_str());
}
else if (attriname == "Tween")
{
tween = (value == "True") ? true : false;
}
std::string texture = "";
std::string texturePng = "";
attribute = attribute->Next();
}
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child)
{
attribute = child->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "FrameIndex")
if (attriname == "Path")
{
frameIndex = atoi(value.c_str());
path = value;
}
else if (attriname == "Tween")
else if (attriname == "Type")
{
tween = (value == "True") ? true : false;
resourceType = getResourceType(value);
}
else if (attriname == "Plist")
{
plistFile = value;
texture = value;
}
attribute = attribute->Next();
}
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child)
if (resourceType == 1)
{
attribute = child->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "Path")
{
path = value;
}
else if (attriname == "Type")
{
resourceType = getResourceType(value);
}
else if (attriname == "Plist")
{
plistFile = value;
texture = value;
}
attribute = attribute->Next();
}
if (resourceType == 1)
{
_textures.push_back(_builder->CreateString(texture));
}
child = child->NextSiblingElement();
_textures.push_back(_builder->CreateString(texture));
}
return CreateTimeLineTextureFrame(*_builder,
frameIndex,
tween,
CreateResourceData(*_builder,
_builder->CreateString(path),
_builder->CreateString(plistFile),
resourceType));
child = child->NextSiblingElement();
}
return CreateTextureFrame(*_builder,
frameIndex,
tween,
CreateResourceData(*_builder,
_builder->CreateString(path),
_builder->CreateString(plistFile),
resourceType));
}
Offset<flatbuffers::EventFrame> FlatBuffersSerialize::createEventFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
std::string value = "";
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string name = attribute->Name();
std::string attrivalue = attribute->Value();
if (name == "Value") // to be gonna modify
{
value = attrivalue;
}
else if (name == "FrameIndex")
{
frameIndex = atoi(attrivalue.c_str());
}
else if (name == "Tween")
{
tween = (attrivalue == "True") ? true : false;
}
attribute = attribute->Next();
}
return CreateEventFrame(*_builder,
frameIndex,
tween,
_builder->CreateString(value));
}
Offset<flatbuffers::IntFrame> FlatBuffersSerialize::createIntFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
int value = 0;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string name = attribute->Name();
std::string attrivalue = attribute->Value();
if (name == "Value") // to be gonna modify
{
value = atoi(attrivalue.c_str());
}
else if (name == "FrameIndex")
{
frameIndex = atoi(attrivalue.c_str());
}
else if (name == "Tween")
{
tween = (attrivalue == "True") ? true : false;
}
attribute = attribute->Next();
}
return CreateIntFrame(*_builder,
frameIndex,
tween,
value);
}
Offset<flatbuffers::BoolFrame> FlatBuffersSerialize::createBoolFrame(const tinyxml2::XMLElement *objectData)
{
int frameIndex = 0;
bool tween = true;
bool value = true;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string name = attribute->Name();
std::string attrivalue = attribute->Value();
if (name == "Value")
{
value = (attrivalue == "True") ? true : false;
}
else if (name == "FrameIndex")
{
frameIndex = atoi(attrivalue.c_str());
}
else if (name == "Tween")
{
tween = (attrivalue == "True") ? true : false;
}
attribute = attribute->Next();
}
return CreateBoolFrame(*_builder,
frameIndex,
tween,
value);
}
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)
{
std::string name = attribute->Name();
std::string attrivalue = attribute->Value();
if (name == "InnerActionType")
{
if (attrivalue == "LoopAction")
{
innerActionType = 0;
}
else if (attrivalue == "NoLoopAction")
{
innerActionType = 1;
}
else if (attrivalue == "SingleFrame")
{
innerActionType = 2;
}
}
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;
}
attribute = attribute->Next();
}
return CreateInnerActionFrame(*_builder,
frameIndex,
tween,
innerActionType,
_builder->CreateString(currentAniamtionName),
singleFrameIndex);
}
/* create flat buffers with XML */
@ -1040,7 +1185,7 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
Offset<NodeTree> nodeTree;
Offset<NodeAction> aciton;
std::vector<Offset<flatbuffers::AnimationInfo> > animationInfos;
const tinyxml2::XMLElement* child = element->FirstChildElement();
@ -1058,6 +1203,16 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
const tinyxml2::XMLElement* objectData = child;
nodeTree = createNodeTreeForSimulator(objectData, rootType);
}
else if (name == "AnimationList") // animation list
{
const tinyxml2::XMLElement* animationinfoElement = child->FirstChildElement();
while (animationinfoElement)
{
auto animationinfo = createAnimationInfo(animationinfoElement);
animationInfos.push_back(animationinfo);
animationinfoElement = animationinfoElement->NextSiblingElement();
}
}
child = child->NextSiblingElement();
}
@ -1067,8 +1222,9 @@ FlatBufferBuilder* FlatBuffersSerialize::createFlatBuffersWithXMLFileForSimulato
_builder->CreateVector(_texturePngs),
nodeTree,
aciton,
_builder->CreateVector(animationInfos),
_builder->CreateString(_csdVersion));
_builder->Finish(csparsebinary);
_builder->Finish(csparsebinary);
_textures.clear();
_texturePngs.clear();
@ -1190,26 +1346,6 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
std::string filename = "";
bool isloop = true;
bool isAutoPlay = true;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "IsLoop")
{
isloop = (value == "True") ? true : false;
}
else if (attriname == "IsAutoPlay")
{
isAutoPlay = (value == "True") ? true : false;
}
attribute = attribute->Next();
}
// FileData
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
while (child)
@ -1218,19 +1354,19 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
if (name == "FileData")
{
const tinyxml2::XMLAttribute* attributeFileData = child->FirstAttribute();
const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
while (attributeFileData)
while (attribute)
{
name = attributeFileData->Name();
std::string value = attributeFileData->Value();
name = attribute->Name();
std::string value = attribute->Value();
if (name == "Path")
{
filename = value;
}
attributeFileData = attributeFileData->Next();
attribute = attribute->Next();
}
}
@ -1239,9 +1375,7 @@ Offset<ProjectNodeOptions> FlatBuffersSerialize::createProjectNodeOptionsForSimu
return CreateProjectNodeOptions(*_builder,
nodeOptions,
_builder->CreateString(filename),
isloop,
isAutoPlay);
_builder->CreateString(filename));
}
}

View File

@ -65,16 +65,18 @@ namespace flatbuffers
struct TextAtlasOptions;
struct NodeAction;
struct AnimationInfo;
struct TimeLine;
struct Frame;
struct TimeLineBoolFrame;
struct TimeLineIntFrame;
struct TimeLineStringFrame;
struct TimeLinePointFrame;
struct TimeLineColorFrame;
struct TimeLineTextureFrame;
struct PointFrame;
struct ScaleFrame;
struct ColorFrame;
struct TextureFrame;
struct EventFrame;
struct IntFrame;
struct BoolFrame;
struct InnerActionFrame;
}
namespace tinyxml2
@ -110,12 +112,17 @@ public:
// NodeAction
flatbuffers::Offset<flatbuffers::NodeAction> createNodeAction(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TimeLine> createTimeLine(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TimeLineBoolFrame> createTimeLineBoolFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TimeLineIntFrame> createTimeLineIntFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TimeLineStringFrame> createTimeLineStringFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TimeLinePointFrame> createTimeLinePointFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TimeLineColorFrame> createTimeLineColorFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TimeLineTextureFrame> createTimeLineTextureFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::PointFrame> createPointFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::ScaleFrame> createScaleFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::ColorFrame> createColorFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::TextureFrame> createTextureFrame(const tinyxml2::XMLElement* objectData);
flatbuffers::Offset<flatbuffers::EventFrame> createEventFrame(const tinyxml2::XMLElement* objectData);
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);
//Animation Info
flatbuffers::Offset<flatbuffers::AnimationInfo> createAnimationInfo(const tinyxml2::XMLElement* objectData);
/**/
int getResourceType(std::string key);

View File

@ -69,26 +69,6 @@ namespace cocostudio
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
std::string filename = "";
bool isloop = true;
bool isAutoPlay = true;
const tinyxml2::XMLAttribute* attribute = objectData->FirstAttribute();
while (attribute)
{
std::string attriname = attribute->Name();
std::string value = attribute->Value();
if (attriname == "IsLoop")
{
isloop = (value == "True") ? true : false;
}
else if (attriname == "IsAutoPlay")
{
isAutoPlay = (value == "True") ? true : false;
}
attribute = attribute->Next();
}
// FileData
const tinyxml2::XMLElement* child = objectData->FirstChildElement();
@ -98,12 +78,12 @@ namespace cocostudio
if (name == "FileData")
{
const tinyxml2::XMLAttribute* attributeFileData = child->FirstAttribute();
const tinyxml2::XMLAttribute* attribute = child->FirstAttribute();
while (attributeFileData)
while (attribute)
{
name = attributeFileData->Name();
std::string value = attributeFileData->Value();
name = attribute->Name();
std::string value = attribute->Value();
if (name == "Path")
{
@ -112,7 +92,7 @@ namespace cocostudio
filename = convert;
}
attributeFileData = attributeFileData->Next();
attribute = attribute->Next();
}
}
@ -121,9 +101,7 @@ namespace cocostudio
auto options = CreateProjectNodeOptions(*builder,
nodeOptions,
builder->CreateString(filename),
isloop,
isAutoPlay);
builder->CreateString(filename));
return *(Offset<Table>*)(&options);
}

View File

@ -197,7 +197,11 @@ void TestActionTimeline::onEnter()
{
ActionTimelineTestLayer::onEnter();
ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 0, 40, true);
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
node->runAction(action);
action->gotoFrameAndPlay(0);
// ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 0, 40, true);
node->setScale(0.2f);
node->setPosition(VisibleRect::center());
@ -217,8 +221,14 @@ void TestChangePlaySection::onEnter()
{
ActionTimelineTestLayer::onEnter();
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
node->runAction(action);
action->gotoFrameAndPlay(41);
/*
ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 41, 81, true);
action = node->getActionTimeline();
*/
node->setScale(0.2f);
node->setPosition(VisibleRect::center());
@ -250,8 +260,14 @@ void TestTimelineFrameEvent::onEnter()
{
ActionTimelineTestLayer::onEnter();
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
node->runAction(action);
action->gotoFrameAndPlay(0);
/*
ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 0, 40, true);
ActionTimeline* action = node->getActionTimeline();
*/
node->setScale(0.2f);
node->setPosition(150,100);
@ -291,7 +307,11 @@ void TestTimelinePerformance::onEnter()
for (int i = 0; i< 100; i++)
{
ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 41, 81, true);
Node* node = CSLoader::createNode("ActionTimeline/DemoPlayer.csb");
ActionTimeline* action = CSLoader::createTimeline("ActionTimeline/DemoPlayer.csb");
node->runAction(action);
action->gotoFrameAndPlay(41);
// ActionTimelineNode* node = CSLoader::createActionTimelineNode("ActionTimeline/DemoPlayer.csb", 41, 81, true);
node->setScale(0.1f);
node->setPosition(i*2,100);