diff --git a/cocos/2d/CCTimelineAction.cpp b/cocos/2d/CCActionTimeline.cpp similarity index 74% rename from cocos/2d/CCTimelineAction.cpp rename to cocos/2d/CCActionTimeline.cpp index a2699b5dd4..4724e12769 100644 --- a/cocos/2d/CCTimelineAction.cpp +++ b/cocos/2d/CCActionTimeline.cpp @@ -22,15 +22,15 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCTimelineAction.h" +#include "CCActionTimeline.h" NS_CC_BEGIN -// TimelineActionData -TimelineActionData* TimelineActionData::create(int actionTag) +// ActionTimelineData +ActionTimelineData* ActionTimelineData::create(int actionTag) { - TimelineActionData * ret = new TimelineActionData(); + ActionTimelineData * ret = new ActionTimelineData(); if (ret && ret->init(actionTag)) { ret->autorelease(); @@ -42,22 +42,22 @@ TimelineActionData* TimelineActionData::create(int actionTag) return ret; } -TimelineActionData::TimelineActionData() +ActionTimelineData::ActionTimelineData() : _actionTag(0) { } -bool TimelineActionData::init(int actionTag) +bool ActionTimelineData::init(int actionTag) { _actionTag = actionTag; return true; } -// TimelineAction -TimelineAction* TimelineAction::create() +// ActionTimeline +ActionTimeline* ActionTimeline::create() { - TimelineAction* object = new TimelineAction(); + ActionTimeline* object = new ActionTimeline(); if (object && object->init()) { object->autorelease(); @@ -67,7 +67,7 @@ TimelineAction* TimelineAction::create() return nullptr; } -TimelineAction::TimelineAction() +ActionTimeline::ActionTimeline() : _duration(0) , _time(0) , _timeSpeed(1) @@ -79,26 +79,26 @@ TimelineAction::TimelineAction() { } -TimelineAction::~TimelineAction() +ActionTimeline::~ActionTimeline() { } -bool TimelineAction::init() +bool ActionTimeline::init() { return true; } -void TimelineAction::gotoFrameAndPlay(int startIndex) +void ActionTimeline::gotoFrameAndPlay(int startIndex) { gotoFrameAndPlay(startIndex, true); } -void TimelineAction::gotoFrameAndPlay(int startIndex, bool loop) +void ActionTimeline::gotoFrameAndPlay(int startIndex, bool loop) { gotoFrameAndPlay(startIndex, _duration, loop); } -void TimelineAction::gotoFrameAndPlay(int startIndex, int endIndex, bool loop) +void ActionTimeline::gotoFrameAndPlay(int startIndex, int endIndex, bool loop) { _endFrame = endIndex; _loop = loop; @@ -109,7 +109,7 @@ void TimelineAction::gotoFrameAndPlay(int startIndex, int endIndex, bool loop) gotoFrame(_currentFrame); } -void TimelineAction::gotoFrameAndPause(int startIndex) +void ActionTimeline::gotoFrameAndPause(int startIndex) { _time =_currentFrame = startIndex; @@ -117,34 +117,24 @@ void TimelineAction::gotoFrameAndPause(int startIndex) gotoFrame(_currentFrame); } -void TimelineAction::pause() +void ActionTimeline::pause() { _playing = false; } -void TimelineAction::resume() +void ActionTimeline::resume() { _playing = true; } -bool TimelineAction::isPlaying() +bool ActionTimeline::isPlaying() const { return _playing; } -void TimelineAction::setTimeSpeed(float speed) +ActionTimeline* ActionTimeline::clone() const { - _timeSpeed = speed; -} - -float TimelineAction::getTimeSpeed() -{ - return _timeSpeed; -} - -TimelineAction* TimelineAction::clone() const -{ - TimelineAction* newAction = TimelineAction::create(); + ActionTimeline* newAction = ActionTimeline::create(); newAction->setDuration(_duration); newAction->setTimeSpeed(_timeSpeed); @@ -160,7 +150,7 @@ TimelineAction* TimelineAction::clone() const return newAction; } -void TimelineAction::step(float delta) +void ActionTimeline::step(float delta) { if (!_playing || _timelineMap.size() == 0 || _duration == 0) { @@ -194,14 +184,14 @@ void foreachNodeDescendant(Node* parent, tCallBack callback) } } -void TimelineAction::startWithTarget(Node *target) +void ActionTimeline::startWithTarget(Node *target) { Action::startWithTarget(target); foreachNodeDescendant(target, [this, target](Node* child) { - TimelineActionData* data = dynamic_cast(child->getUserObject()); + ActionTimelineData* data = dynamic_cast(child->getUserObject()); int actionTag = data->getActionTag(); if(_timelineMap.find(actionTag) != _timelineMap.end()) { @@ -214,7 +204,7 @@ void TimelineAction::startWithTarget(Node *target) }); } -void TimelineAction::addTimeline(Timeline* timeline) +void ActionTimeline::addTimeline(Timeline* timeline) { int tag = timeline->getActionTag(); if (_timelineMap.find(tag) == _timelineMap.end()) @@ -226,11 +216,11 @@ void TimelineAction::addTimeline(Timeline* timeline) { _timelineList.pushBack(timeline); _timelineMap[tag].pushBack(timeline); - timeline->setTimelineAction(this); + timeline->setActionTimeline(this); } } -void TimelineAction::removeTimeline(Timeline* timeline) +void ActionTimeline::removeTimeline(Timeline* timeline) { int tag = timeline->getActionTag(); if (_timelineMap.find(tag) != _timelineMap.end()) @@ -239,23 +229,23 @@ void TimelineAction::removeTimeline(Timeline* timeline) { _timelineMap[tag].eraseObject(timeline); _timelineList.eraseObject(timeline); - timeline->setTimelineAction(nullptr); + timeline->setActionTimeline(nullptr); } } } -void TimelineAction::setFrameEventCallFunc(std::function listener) +void ActionTimeline::setFrameEventCallFunc(std::function listener) { _frameEventListener = listener; } -void TimelineAction::clearFrameEventCallFunc() +void ActionTimeline::clearFrameEventCallFunc() { _frameEventListener = nullptr; } -void TimelineAction::emitFrameEvent(Frame* frame) +void ActionTimeline::emitFrameEvent(Frame* frame) { if(_frameEventListener) { @@ -263,7 +253,7 @@ void TimelineAction::emitFrameEvent(Frame* frame) } } -void TimelineAction::gotoFrame(int frameIndex) +void ActionTimeline::gotoFrame(int frameIndex) { int size = _timelineList.size(); for(int i = 0; i& getTimelines() const { return _timelineList; } + + /** Set ActionTimeline's frame event callback function */ void setFrameEventCallFunc(std::function listener); void clearFrameEventCallFunc(); - /** emit frame event, call it when enter a frame*/ - void emitFrameEvent(Frame* frame); - /** Inherit from Action. */ - /** Returns a clone of TimelineAction */ - virtual TimelineAction* clone() const override; + /** Returns a clone of ActionTimeline */ + virtual ActionTimeline* clone() const override; - /** Returns a reverse of TimelineAction. + /** Returns a reverse of ActionTimeline. * Not implement yet. */ - virtual TimelineAction* reverse() const override { return nullptr; } + virtual ActionTimeline* reverse() const override { return nullptr; } virtual void step(float delta) override; virtual void startWithTarget(Node *target) override; @@ -138,6 +136,9 @@ protected: virtual void gotoFrame(int frameIndex); virtual void stepToFrame(int frameIndex); + /** emit frame event, call it when enter a frame*/ + virtual void emitFrameEvent(Frame* frame); + std::map> _timelineMap; Vector _timelineList; diff --git a/cocos/2d/CCFrame.cpp b/cocos/2d/CCFrame.cpp index 8706cf2f10..aebacf0d99 100644 --- a/cocos/2d/CCFrame.cpp +++ b/cocos/2d/CCFrame.cpp @@ -24,7 +24,8 @@ THE SOFTWARE. #include "2d/CCFrame.h" #include "2d/CCTimeLine.h" -#include "2d/CCTimelineAction.h" +#include "2d/CCTimeLine.h" +#include "2d/CCActionTimeline.h" #include "2d/CCSprite.h" #include "2d/CCSpriteFrameCache.h" @@ -43,6 +44,14 @@ Frame::~Frame() { } +void Frame::emitEvent() +{ + if (_timeline) + { + _timeline->getActionTimeline()->emitFrameEvent(this); + } +} + void Frame::cloneProperty(Frame* frame) { _frameIndex = frame->getFrameIndex(); @@ -583,10 +592,7 @@ EventFrame::EventFrame() void EventFrame::onEnter(Frame *nextFrame) { - if (_timeline) - { - _timeline->getTimelineAction()->emitFrameEvent(this); - } + emitEvent(); } diff --git a/cocos/2d/CCFrame.h b/cocos/2d/CCFrame.h index 62cda149e1..475e6bb63f 100644 --- a/cocos/2d/CCFrame.h +++ b/cocos/2d/CCFrame.h @@ -25,27 +25,32 @@ THE SOFTWARE. #ifndef __CCFRAME_H__ #define __CCFRAME_H__ -#include "CCTimeLine.h" +#include "base/CCRef.h" +#include "math/Vec2.h" +#include "GL/glew.h" +#include "base/ccTypes.h" +#include NS_CC_BEGIN class Sprite; +class Timeline; class CC_DLL Frame : public Ref { public: virtual void setFrameIndex(unsigned int frameIndex) { _frameIndex = frameIndex; } - virtual unsigned int getFrameIndex()const { return _frameIndex; } + virtual unsigned int getFrameIndex() const { return _frameIndex; } virtual void setTimeline(Timeline* timeline) { _timeline = timeline; } - virtual Timeline* getTimeline() { return _timeline; } + virtual Timeline* getTimeline() const { return _timeline; } virtual void setNode(Node* node) { _node = node; } virtual Node* getTimelineNode() const { return _node; } virtual void setTween(bool tween) { _tween = tween; } - virtual bool isTween()const { return _tween; } + virtual bool isTween() const { return _tween; } virtual void onEnter(Frame *nextFrame) = 0; virtual void apply(float percent) {} @@ -55,9 +60,9 @@ protected: Frame(); virtual ~Frame(); - void cloneProperty(Frame* frame); + virtual void emitEvent(); + virtual void cloneProperty(Frame* frame); protected: - friend class Timeline; unsigned int _frameIndex; bool _tween; @@ -179,8 +184,8 @@ public: inline void setX(float x) { _position.x = x; } inline void setY(float y) { _position.y = y; } - inline float getX() { return _position.x; } - inline float getY() { return _position.y; } + inline float getX() const { return _position.x; } + inline float getY() const { return _position.y; } protected: Point _position; float _betweenX; diff --git a/cocos/2d/CCTimeLine.cpp b/cocos/2d/CCTimeLine.cpp index ea48fcb3ab..e04fe6fdc2 100644 --- a/cocos/2d/CCTimeLine.cpp +++ b/cocos/2d/CCTimeLine.cpp @@ -23,8 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCTimeLine.h" -#include "CCTimelineAction.h" -#include "CCFrame.h" +#include "CCActionTimeline.h" NS_CC_BEGIN @@ -47,7 +46,7 @@ Timeline::Timeline() , _toIndex(0) , _betweenDuration(0) , _actionTag(0) - , _timelineAction(nullptr) + , _ActionTimeline(nullptr) , _node(nullptr) { } @@ -82,7 +81,7 @@ Timeline* Timeline::clone() for (auto frame : _frames) { Frame* newFrame = frame->clone(); - timeline->getFrames().pushBack(newFrame); + timeline->addFrame(newFrame); } return timeline; @@ -114,7 +113,7 @@ void Timeline::setNode(Node* node) } } -Node* Timeline::getNode() +Node* Timeline::getNode() const { return _node; } diff --git a/cocos/2d/CCTimeLine.h b/cocos/2d/CCTimeLine.h index 4ac3f335ce..474f4ded3f 100644 --- a/cocos/2d/CCTimeLine.h +++ b/cocos/2d/CCTimeLine.h @@ -26,11 +26,11 @@ THE SOFTWARE. #define __CCTIMELINE_H__ #include "2d/CCNode.h" +#include "2d/CCFrame.h" NS_CC_BEGIN -class Frame; -class TimelineAction; +class ActionTimeline; class CC_DLL Timeline : public Ref { @@ -43,7 +43,6 @@ public: virtual void gotoFrame(int frameIndex); virtual void stepToFrame(int frameIndex); - virtual Vector& getFrames() { return _frames; } virtual const Vector& getFrames() const { return _frames; } virtual void addFrame(Frame* frame); @@ -51,17 +50,16 @@ public: virtual void removeFrame(Frame* frame); virtual void setActionTag(int tag) { _actionTag = tag; } - virtual int getActionTag() { return _actionTag; } + virtual int getActionTag() const { return _actionTag; } virtual void setNode(Node* node); - virtual Node* getNode(); + virtual Node* getNode() const; - virtual void setTimelineAction(TimelineAction* action) { _timelineAction = action; } - virtual TimelineAction* getTimelineAction() { return _timelineAction; } + virtual void setActionTimeline(ActionTimeline* action) { _ActionTimeline = action; } + virtual ActionTimeline* getActionTimeline() const { return _ActionTimeline; } virtual Timeline* clone(); - protected: virtual void apply(int frameIndex); @@ -77,7 +75,7 @@ protected: int _betweenDuration; int _actionTag; - TimelineAction* _timelineAction; + ActionTimeline* _ActionTimeline; Node* _node; }; diff --git a/cocos/2d/cocos2d.vcxproj b/cocos/2d/cocos2d.vcxproj index a6893f4040..f2205a3f87 100644 --- a/cocos/2d/cocos2d.vcxproj +++ b/cocos/2d/cocos2d.vcxproj @@ -333,7 +333,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - + @@ -532,7 +532,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou - + diff --git a/cocos/2d/cocos2d.vcxproj.filters b/cocos/2d/cocos2d.vcxproj.filters index 963f3d876d..3129e329f0 100644 --- a/cocos/2d/cocos2d.vcxproj.filters +++ b/cocos/2d/cocos2d.vcxproj.filters @@ -574,7 +574,7 @@ 2d - + 2d @@ -1165,7 +1165,7 @@ 2d - + 2d diff --git a/cocos/Android.mk b/cocos/Android.mk index ae1fc5f816..ba61451572 100644 --- a/cocos/Android.mk +++ b/cocos/Android.mk @@ -23,7 +23,7 @@ cocos2d.cpp \ 2d/CCActionTween.cpp \ 2d/CCFrame.cpp \ 2d/CCTimeline.cpp \ -2d/CCTimelineAction.cpp \ +2d/CCActionTimeline.cpp \ 2d/CCAnimation.cpp \ 2d/CCAnimationCache.cpp \ 2d/CCAtlasNode.cpp \ diff --git a/cocos/cocos2d.h b/cocos/cocos2d.h index ccec2a3ee4..066aabcdce 100644 --- a/cocos/cocos2d.h +++ b/cocos/cocos2d.h @@ -106,7 +106,7 @@ THE SOFTWARE. #include "2d/CCTweenFunction.h" #include "2d/CCFrame.h" #include "2d/CCTimeLine.h" -#include "2d/CCTimelineAction.h" +#include "2d/CCActionTimeline.h" // 2d nodes #include "2d/CCNode.h" diff --git a/cocos/editor-support/cocostudio/TimelineAction/CCTimelineActionCache.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp similarity index 75% rename from cocos/editor-support/cocostudio/TimelineAction/CCTimelineActionCache.cpp rename to cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp index bf8da1b0f8..c25f2ab4f7 100644 --- a/cocos/editor-support/cocostudio/TimelineAction/CCTimelineActionCache.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCTimelineActionCache.h" +#include "CCActionTimelineCache.h" #include "CCNodeReader.h" using namespace cocos2d; @@ -65,48 +65,48 @@ static const char* BLUE = "blue"; static const char* Value = "value"; -static TimelineActionCache* _sharedActionCache = nullptr; +static ActionTimelineCache* _sharedActionCache = nullptr; -TimelineActionCache* TimelineActionCache::getInstance() +ActionTimelineCache* ActionTimelineCache::getInstance() { if (! _sharedActionCache) { - _sharedActionCache = new TimelineActionCache(); + _sharedActionCache = new ActionTimelineCache(); _sharedActionCache->init(); } return _sharedActionCache; } -void TimelineActionCache::destroyInstance() +void ActionTimelineCache::destroyInstance() { CC_SAFE_DELETE(_sharedActionCache); } -void TimelineActionCache::purge() +void ActionTimelineCache::purge() { _animationActions.clear(); } -void TimelineActionCache::init() +void ActionTimelineCache::init() { using namespace std::placeholders; - _funcs.insert(Pair(FrameType_VisibleFrame, std::bind(&TimelineActionCache::loadVisibleFrame, this, _1))); - _funcs.insert(Pair(FrameType_PositionFrame, std::bind(&TimelineActionCache::loadPositionFrame, this, _1))); - _funcs.insert(Pair(FrameType_ScaleFrame, std::bind(&TimelineActionCache::loadScaleFrame, this, _1))); - _funcs.insert(Pair(FrameType_RotationFrame, std::bind(&TimelineActionCache::loadRotationFrame, this, _1))); - _funcs.insert(Pair(FrameType_SkewFrame, std::bind(&TimelineActionCache::loadSkewFrame, this, _1))); - _funcs.insert(Pair(FrameType_RotationSkewFrame, std::bind(&TimelineActionCache::loadRotationSkewFrame, this, _1))); - _funcs.insert(Pair(FrameType_AnchorFrame, std::bind(&TimelineActionCache::loadAnchorPointFrame, this, _1))); - _funcs.insert(Pair(FrameType_InnerActionFrame, std::bind(&TimelineActionCache::loadInnerActionFrame, this, _1))); - _funcs.insert(Pair(FrameType_ColorFrame, std::bind(&TimelineActionCache::loadColorFrame, this, _1))); - _funcs.insert(Pair(FrameType_TextureFrame, std::bind(&TimelineActionCache::loadTextureFrame, this, _1))); - _funcs.insert(Pair(FrameType_EventFrame, std::bind(&TimelineActionCache::loadEventFrame, this, _1))); - _funcs.insert(Pair(FrameType_ZOrderFrame, std::bind(&TimelineActionCache::loadZOrderFrame, this, _1))); + _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))); + _funcs.insert(Pair(FrameType_RotationFrame, std::bind(&ActionTimelineCache::loadRotationFrame, this, _1))); + _funcs.insert(Pair(FrameType_SkewFrame, std::bind(&ActionTimelineCache::loadSkewFrame, this, _1))); + _funcs.insert(Pair(FrameType_RotationSkewFrame, std::bind(&ActionTimelineCache::loadRotationSkewFrame, this, _1))); + _funcs.insert(Pair(FrameType_AnchorFrame, std::bind(&ActionTimelineCache::loadAnchorPointFrame, this, _1))); + _funcs.insert(Pair(FrameType_InnerActionFrame, std::bind(&ActionTimelineCache::loadInnerActionFrame, this, _1))); + _funcs.insert(Pair(FrameType_ColorFrame, std::bind(&ActionTimelineCache::loadColorFrame, this, _1))); + _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))); } -void TimelineActionCache::removeAction(const std::string& fileName) +void ActionTimelineCache::removeAction(const std::string& fileName) { if (_animationActions.find(fileName) != _animationActions.end()) { @@ -114,9 +114,9 @@ void TimelineActionCache::removeAction(const std::string& fileName) } } -TimelineAction* TimelineActionCache::createAction(const std::string& fileName) +ActionTimeline* ActionTimelineCache::createAction(const std::string& fileName) { - TimelineAction* action = _animationActions.at(fileName); + ActionTimeline* action = _animationActions.at(fileName); if (action == nullptr) { action = loadAnimationActionWithFile(fileName); @@ -124,7 +124,7 @@ TimelineAction* TimelineActionCache::createAction(const std::string& fileName) return action->clone(); } -TimelineAction* TimelineActionCache::loadAnimationActionWithFile(const std::string& fileName) +ActionTimeline* ActionTimelineCache::loadAnimationActionWithFile(const std::string& fileName) { // Read content from file std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(fileName); @@ -133,10 +133,10 @@ TimelineAction* TimelineActionCache::loadAnimationActionWithFile(const std::stri return loadAnimationActionWithContent(fileName, contentStr); } -TimelineAction* TimelineActionCache::loadAnimationActionWithContent(const std::string&fileName, const std::string& content) +ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(const std::string&fileName, const std::string& content) { // if already exists an action with filename, then return this action - TimelineAction* action = _animationActions.at(fileName); + ActionTimeline* action = _animationActions.at(fileName); if(action) return action; @@ -149,7 +149,7 @@ TimelineAction* TimelineActionCache::loadAnimationActionWithContent(const std::s const rapidjson::Value& json = DICTOOL->getSubDictionary_json(doc, ACTION); - action = TimelineAction::create(); + action = ActionTimeline::create(); action->setDuration(DICTOOL->getIntValue_json(json, DURATION)); action->setTimeSpeed(DICTOOL->getFloatValue_json(json, TIME_SPEED, 1.0f)); @@ -170,7 +170,7 @@ TimelineAction* TimelineActionCache::loadAnimationActionWithContent(const std::s } -Timeline* TimelineActionCache::loadTimeline(const rapidjson::Value& json) +Timeline* ActionTimelineCache::loadTimeline(const rapidjson::Value& json) { Timeline* timeline = nullptr; @@ -213,7 +213,7 @@ Timeline* TimelineActionCache::loadTimeline(const rapidjson::Value& json) return timeline; } -Frame* TimelineActionCache::loadVisibleFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadVisibleFrame(const rapidjson::Value& json) { VisibleFrame* frame = VisibleFrame::create(); @@ -223,7 +223,7 @@ Frame* TimelineActionCache::loadVisibleFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadPositionFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadPositionFrame(const rapidjson::Value& json) { PositionFrame* frame = PositionFrame::create(); @@ -234,7 +234,7 @@ Frame* TimelineActionCache::loadPositionFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadScaleFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadScaleFrame(const rapidjson::Value& json) { ScaleFrame* frame = ScaleFrame::create(); @@ -247,7 +247,7 @@ Frame* TimelineActionCache::loadScaleFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadSkewFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadSkewFrame(const rapidjson::Value& json) { SkewFrame* frame = SkewFrame::create(); @@ -260,7 +260,7 @@ Frame* TimelineActionCache::loadSkewFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadRotationSkewFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadRotationSkewFrame(const rapidjson::Value& json) { RotationSkewFrame* frame = RotationSkewFrame::create(); @@ -273,7 +273,7 @@ Frame* TimelineActionCache::loadRotationSkewFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadRotationFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadRotationFrame(const rapidjson::Value& json) { RotationFrame* frame = RotationFrame::create(); @@ -283,7 +283,7 @@ Frame* TimelineActionCache::loadRotationFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadAnchorPointFrame (const rapidjson::Value& json) +Frame* ActionTimelineCache::loadAnchorPointFrame (const rapidjson::Value& json) { AnchorPointFrame* frame = AnchorPointFrame::create(); @@ -295,7 +295,7 @@ Frame* TimelineActionCache::loadAnchorPointFrame (const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadInnerActionFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadInnerActionFrame(const rapidjson::Value& json) { InnerActionFrame* frame = InnerActionFrame::create(); @@ -308,7 +308,7 @@ Frame* TimelineActionCache::loadInnerActionFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadColorFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadColorFrame(const rapidjson::Value& json) { ColorFrame* frame = ColorFrame::create(); @@ -323,7 +323,7 @@ Frame* TimelineActionCache::loadColorFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadTextureFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadTextureFrame(const rapidjson::Value& json) { TextureFrame* frame = TextureFrame::create(); @@ -345,7 +345,7 @@ Frame* TimelineActionCache::loadTextureFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadEventFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadEventFrame(const rapidjson::Value& json) { EventFrame* frame = EventFrame::create(); @@ -357,7 +357,7 @@ Frame* TimelineActionCache::loadEventFrame(const rapidjson::Value& json) return frame; } -Frame* TimelineActionCache::loadZOrderFrame(const rapidjson::Value& json) +Frame* ActionTimelineCache::loadZOrderFrame(const rapidjson::Value& json) { ZOrderFrame* frame = ZOrderFrame::create(); diff --git a/cocos/editor-support/cocostudio/TimelineAction/CCTimelineActionCache.h b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h similarity index 90% rename from cocos/editor-support/cocostudio/TimelineAction/CCTimelineActionCache.h rename to cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h index 756be194da..bb59debd48 100644 --- a/cocos/editor-support/cocostudio/TimelineAction/CCTimelineActionCache.h +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCActionTimelineCache.h @@ -32,11 +32,11 @@ THE SOFTWARE. namespace cocostudio { namespace timeline{ -class TimelineActionCache +class ActionTimelineCache { public: /** Gets the singleton */ - static TimelineActionCache* getInstance(); + static ActionTimelineCache* getInstance(); /** Destroys the singleton */ static void destroyInstance(); @@ -49,10 +49,10 @@ public: void removeAction(const std::string& fileName); /** Clone a action with the specified name from the container. */ - cocos2d::TimelineAction* createAction(const std::string& fileName); + cocos2d::ActionTimeline* createAction(const std::string& fileName); - cocos2d::TimelineAction* loadAnimationActionWithFile(const std::string& fileName); - cocos2d::TimelineAction* loadAnimationActionWithContent(const std::string&fileName, const std::string& content); + cocos2d::ActionTimeline* loadAnimationActionWithFile(const std::string& fileName); + cocos2d::ActionTimeline* loadAnimationActionWithContent(const std::string&fileName, const std::string& content); protected: cocos2d::Timeline* loadTimeline(const rapidjson::Value& json); @@ -76,7 +76,7 @@ protected: typedef std::pair Pair; std::unordered_map _funcs; - cocos2d::Map _animationActions; + cocos2d::Map _animationActions; }; } diff --git a/cocos/editor-support/cocostudio/TimelineAction/CCNodeReader.cpp b/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp similarity index 98% rename from cocos/editor-support/cocostudio/TimelineAction/CCNodeReader.cpp rename to cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp index 713646622a..2b70e8488c 100644 --- a/cocos/editor-support/cocostudio/TimelineAction/CCNodeReader.cpp +++ b/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCNodeReader.h" -#include "CCTimelineActionCache.h" +#include "CCActionTimelineCache.h" #include "../CCSGUIReader.h" @@ -174,7 +174,7 @@ Node* NodeReader::loadNodeWithFile(const std::string& fileName) Node* node = loadNodeWithContent(contentStr); // Load animation data from file - TimelineActionCache::getInstance()->loadAnimationActionWithContent(fileName, contentStr); + ActionTimelineCache::getInstance()->loadAnimationActionWithContent(fileName, contentStr); return node; } @@ -299,7 +299,7 @@ void NodeReader::initNode(Node* node, const rapidjson::Value& json) node->setTag(tag); - node->setUserObject(TimelineActionData::create(actionTag)); + node->setUserObject(ActionTimelineData::create(actionTag)); } Node* NodeReader::loadSimpleNode(const rapidjson::Value& json) @@ -428,7 +428,7 @@ Node* NodeReader::loadWidget(const rapidjson::Value& json) _guiReader->setPropsForAllWidgetFromJsonDictionary(reader, widget, json); int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG); - widget->setUserObject(TimelineActionData::create(actionTag)); + widget->setUserObject(ActionTimelineData::create(actionTag)); return widget; } diff --git a/cocos/editor-support/cocostudio/TimelineAction/CCNodeReader.h b/cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.h similarity index 100% rename from cocos/editor-support/cocostudio/TimelineAction/CCNodeReader.h rename to cocos/editor-support/cocostudio/ActionTimeline/CCNodeReader.h diff --git a/cocos/editor-support/cocostudio/Android.mk b/cocos/editor-support/cocostudio/Android.mk index e9c28b9445..620ef3fd9f 100644 --- a/cocos/editor-support/cocostudio/Android.mk +++ b/cocos/editor-support/cocostudio/Android.mk @@ -53,8 +53,8 @@ WidgetReader/TextAtlasReader/TextAtlasReader.cpp \ WidgetReader/TextBMFontReader/TextBMFontReader.cpp \ WidgetReader/TextFieldReader/TextFieldReader.cpp \ WidgetReader/TextReader/TextReader.cpp \ -TimelineAction/CCNodeReader.cpp \ -TimelineAction/CCTimelineActionCache.cpp \ +ActionTimeline/CCNodeReader.cpp \ +ActionTimeline/CCActionTimelineCache.cpp \ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. \ diff --git a/cocos/editor-support/cocostudio/CocoStudio.h b/cocos/editor-support/cocostudio/CocoStudio.h index 1c38db7fb4..fa26760fd7 100644 --- a/cocos/editor-support/cocostudio/CocoStudio.h +++ b/cocos/editor-support/cocostudio/CocoStudio.h @@ -58,7 +58,7 @@ THE SOFTWARE. #include "cocostudio/CCSGUIReader.h" #include "cocostudio/CCSSceneReader.h" #include "cocostudio/TriggerBase.h" -#include "cocostudio/TimelineAction/CCNodeReader.h" -#include "cocostudio/TimelineAction/CCTimelineActionCache.h" +#include "cocostudio/ActionTimeline/CCNodeReader.h" +#include "cocostudio/ActionTimeline/CCActionTimelineCache.h" #endif diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj index 69e3061ced..850a8e10d4 100644 --- a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj @@ -11,6 +11,8 @@ + + @@ -42,8 +44,6 @@ - - @@ -73,6 +73,8 @@ + + @@ -105,8 +107,6 @@ - - diff --git a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters index bdd04d845e..6cff5ec355 100644 --- a/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters +++ b/cocos/editor-support/cocostudio/proj.win32/libCocosStudio.vcxproj.filters @@ -231,10 +231,10 @@ reader\WidgetReader\PageViewReader - + TimelineAction - + TimelineAction @@ -419,10 +419,10 @@ reader\WidgetReader\PageViewReader - + TimelineAction - + TimelineAction diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioTimelineActionTest/TimelineActionTestScene.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp similarity index 75% rename from tests/cpp-tests/Classes/ExtensionsTest/CocoStudioTimelineActionTest/TimelineActionTestScene.cpp rename to tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp index 64374054e9..c6ac13d00b 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioTimelineActionTest/TimelineActionTestScene.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.cpp @@ -1,4 +1,4 @@ -#include "TimelineActionTestScene.h" +#include "ActionTimelineTestScene.h" #include "../../testResource.h" #include "renderer/CCRenderer.h" #include "renderer/CCCustomCommand.h" @@ -20,7 +20,7 @@ Layer *CreateAnimationLayer(int index) switch(index) { case TEST_ANIMATIONELEMENT: - pLayer = new TestTimelineAction(); + pLayer = new TestActionTimeline(); break; default: break; @@ -62,7 +62,7 @@ Layer *RestartAnimationTest() } -TimelineActionTestScene::TimelineActionTestScene(bool bPortrait) +ActionTimelineTestScene::ActionTimelineTestScene(bool bPortrait) { TestScene::init(); @@ -78,7 +78,7 @@ TimelineActionTestScene::TimelineActionTestScene(bool bPortrait) addChild(bg); } -void TimelineActionTestScene::runThisTest() +void ActionTimelineTestScene::runThisTest() { s_nActionIdx = -1; addChild(NextAnimationTest()); @@ -86,7 +86,7 @@ void TimelineActionTestScene::runThisTest() Director::getInstance()->replaceScene(this); } -void TimelineActionTestScene::MainMenuCallback(Ref *pSender) +void ActionTimelineTestScene::MainMenuCallback(Ref *pSender) { //TestScene::MainMenuCallback(pSender); @@ -95,7 +95,7 @@ void TimelineActionTestScene::MainMenuCallback(Ref *pSender) -void TimelineActionTestLayer::onEnter() +void ActionTimelineTestLayer::onEnter() { Layer::onEnter(); @@ -118,9 +118,9 @@ void TimelineActionTestLayer::onEnter() } // add menu - backItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(TimelineActionTestLayer::backCallback, this) ); - restartItem = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(TimelineActionTestLayer::restartCallback, this) ); - nextItem = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(TimelineActionTestLayer::nextCallback, this) ); + backItem = MenuItemImage::create(s_pathB1, s_pathB2, CC_CALLBACK_1(ActionTimelineTestLayer::backCallback, this) ); + restartItem = MenuItemImage::create(s_pathR1, s_pathR2, CC_CALLBACK_1(ActionTimelineTestLayer::restartCallback, this) ); + nextItem = MenuItemImage::create(s_pathF1, s_pathF2, CC_CALLBACK_1(ActionTimelineTestLayer::nextCallback, this) ); Menu *menu = Menu::create(backItem, restartItem, nextItem, nullptr); @@ -134,58 +134,58 @@ void TimelineActionTestLayer::onEnter() setShaderProgram(ShaderCache::getInstance()->getProgram(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR)); } -void TimelineActionTestLayer::onExit() +void ActionTimelineTestLayer::onExit() { removeAllChildren(); backItem = restartItem = nextItem = nullptr; - TimelineActionCache::getInstance()->purge(); + ActionTimelineCache::getInstance()->purge(); NodeReader::getInstance()->purge(); Layer::onExit(); } -std::string TimelineActionTestLayer::title() const +std::string ActionTimelineTestLayer::title() const { return "Armature Test Bed"; } -std::string TimelineActionTestLayer::subtitle() const +std::string ActionTimelineTestLayer::subtitle() const { return ""; } -void TimelineActionTestLayer::restartCallback(Ref *pSender) +void ActionTimelineTestLayer::restartCallback(Ref *pSender) { - Scene *s = new TimelineActionTestScene(); + Scene *s = new ActionTimelineTestScene(); s->addChild( RestartAnimationTest() ); Director::getInstance()->replaceScene(s); s->release(); } -void TimelineActionTestLayer::nextCallback(Ref *pSender) +void ActionTimelineTestLayer::nextCallback(Ref *pSender) { - Scene *s = new TimelineActionTestScene(); + Scene *s = new ActionTimelineTestScene(); s->addChild( NextAnimationTest() ); Director::getInstance()->replaceScene(s); s->release(); } -void TimelineActionTestLayer::backCallback(Ref *pSender) +void ActionTimelineTestLayer::backCallback(Ref *pSender) { - Scene *s = new TimelineActionTestScene(); + Scene *s = new ActionTimelineTestScene(); s->addChild( BackAnimationTest() ); Director::getInstance()->replaceScene(s); s->release(); } -void TestTimelineAction::onEnter() +void TestActionTimeline::onEnter() { - TimelineActionTestLayer::onEnter(); + ActionTimelineTestLayer::onEnter(); SpriteFrameCache::getInstance()->addSpriteFramesWithFile("armature/Cowboy0.plist", "armature/Cowboy0.png"); - Node* node = NodeReader::getInstance()->createNode("TimelineAction/boy_1.ExportJson"); - TimelineAction* action = TimelineActionCache::getInstance()->createAction("TimelineAction/boy_1.ExportJson"); + Node* node = NodeReader::getInstance()->createNode("ActionTimeline/boy_1.ExportJson"); + ActionTimeline* action = ActionTimelineCache::getInstance()->createAction("ActionTimeline/boy_1.ExportJson"); node->runAction(action); action->gotoFrameAndPlay(0, 60, true); @@ -196,7 +196,7 @@ void TestTimelineAction::onEnter() addChild(node); } -std::string TestTimelineAction::title() const +std::string TestActionTimeline::title() const { return "Test AnimationElement"; } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioTimelineActionTest/TimelineActionTestScene.h b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h similarity index 80% rename from tests/cpp-tests/Classes/ExtensionsTest/CocoStudioTimelineActionTest/TimelineActionTestScene.h rename to tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h index a0501811b1..762eeaa629 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioTimelineActionTest/TimelineActionTestScene.h +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioActionTimelineTest/ActionTimelineTestScene.h @@ -9,10 +9,10 @@ using namespace cocostudio::timeline; -class TimelineActionTestScene : public TestScene +class ActionTimelineTestScene : public TestScene { public: - TimelineActionTestScene(bool bPortrait = false); + ActionTimelineTestScene(bool bPortrait = false); virtual void runThisTest(); @@ -26,7 +26,7 @@ enum { TEST_ANIMATION_LAYER_COUNT }; -class TimelineActionTestLayer : public Layer +class ActionTimelineTestLayer : public Layer { public: virtual std::string title() const; @@ -47,7 +47,7 @@ protected: }; -class TestTimelineAction : public TimelineActionTestLayer +class TestActionTimeline : public ActionTimelineTestLayer { public: virtual void onEnter(); diff --git a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp index d2a9a8d9a0..4d664618f3 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/ExtensionsTest.cpp @@ -9,7 +9,7 @@ #include "TableViewTest/TableViewTestScene.h" #include "CocoStudioArmatureTest/ArmatureScene.h" -#include "CocoStudioTimelineActionTest/TimelineActionTestScene.h" +#include "CocoStudioActionTimelineTest/ActionTimelineTestScene.h" #include "CocoStudioComponentsTest/ComponentsTestScene.h" #include "CocoStudioSceneTest/SceneEditorTest.h" @@ -79,7 +79,7 @@ static struct { scene->release(); } }, - { "CocoStudioTimelineActionTest", [](Ref *sender) { TimelineActionTestScene *scene = new TimelineActionTestScene(); + { "CocoStudioActionTimelineTest", [](Ref *sender) { ActionTimelineTestScene *scene = new ActionTimelineTestScene(); scene->runThisTest(); scene->release(); } diff --git a/tests/cpp-tests/Resources/TimelineAction/boy_1.ExportJson b/tests/cpp-tests/Resources/ActionTimeline/boy_1.ExportJson similarity index 100% rename from tests/cpp-tests/Resources/TimelineAction/boy_1.ExportJson rename to tests/cpp-tests/Resources/ActionTimeline/boy_1.ExportJson diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj index 9c8e8daf26..a5f6d0d258 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj @@ -149,6 +149,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou + @@ -159,7 +160,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou - @@ -330,6 +330,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou + @@ -341,7 +342,6 @@ xcopy /Y /Q "$(ProjectDir)..\..\..\external\websockets\prebuilt\win32\*.*" "$(Ou - diff --git a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters index f1b0a28bd5..4f77ffe13f 100644 --- a/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters +++ b/tests/cpp-tests/proj.win32/cpp-tests.vcxproj.filters @@ -325,7 +325,7 @@ {45e9becf-58e5-424e-903d-9bc7f9999d5b} - + {fa88df83-76d7-4f41-ad48-801dafd44889} @@ -843,8 +843,8 @@ Classes\Sprite3DTest - - Classes\ExtensionsTest\CocoStudioTimelineActionTest + + Classes\ExtensionsTest\CocoStudioActionTimelineTest @@ -1559,8 +1559,8 @@ Classes\Sprite3DTest - - Classes\ExtensionsTest\CocoStudioTimelineActionTest + + Classes\ExtensionsTest\CocoStudioActionTimelineTest \ No newline at end of file