mirror of https://github.com/axmolengine/axmol.git
change TimelineAction to cocos/2d folder
This commit is contained in:
parent
75ff67c0ec
commit
e0f6ae9db4
|
@ -22,14 +22,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CCFrame.h"
|
||||
#include "CCTimeLine.h"
|
||||
#include "CCTimelineAction.h"
|
||||
#include "2d/CCFrame.h"
|
||||
#include "2d/CCTimeLine.h"
|
||||
#include "2d/CCTimelineAction.h"
|
||||
#include "2d/CCSprite.h"
|
||||
#include "2d/CCSpriteFrameCache.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
NS_CC_BEGIN
|
||||
|
||||
// Frame
|
||||
Frame::Frame()
|
||||
|
@ -105,7 +104,7 @@ TextureFrame::TextureFrame()
|
|||
{
|
||||
}
|
||||
|
||||
void TextureFrame::setNode(cocos2d::Node* node)
|
||||
void TextureFrame::setNode(Node* node)
|
||||
{
|
||||
Frame::setNode(node);
|
||||
|
||||
|
@ -526,7 +525,7 @@ void ColorFrame::onEnter(Frame *nextFrame)
|
|||
{
|
||||
_betweenAlpha = static_cast<ColorFrame*>(nextFrame)->_alpha - _alpha;
|
||||
|
||||
const cocos2d::Color3B& color = static_cast<ColorFrame*>(nextFrame)->_color;
|
||||
const Color3B& color = static_cast<ColorFrame*>(nextFrame)->_color;
|
||||
_betweenRed = color.r - _color.r;
|
||||
_betweenGreen = color.g - _color.g;
|
||||
_betweenBlue = color.b - _color.b;
|
||||
|
@ -542,7 +541,7 @@ void ColorFrame::apply(float percent)
|
|||
{
|
||||
GLubyte alpha = _alpha + _betweenAlpha * percent;
|
||||
|
||||
cocos2d::Color3B color;
|
||||
Color3B color;
|
||||
color.r = _color.r+ _betweenRed * percent;
|
||||
color.g = _color.g+ _betweenGreen * percent;
|
||||
color.b = _color.b+ _betweenBlue * percent;
|
||||
|
@ -637,5 +636,4 @@ Frame* ZOrderFrame::clone()
|
|||
return frame;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
NS_CC_END
|
|
@ -27,11 +27,11 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCTimeLine.h"
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Sprite;
|
||||
|
||||
class Frame : public cocos2d::Ref
|
||||
class CC_DLL Frame : public Ref
|
||||
{
|
||||
public:
|
||||
|
||||
|
@ -41,8 +41,8 @@ public:
|
|||
virtual void setTimeline(Timeline* timeline) { _timeline = timeline; }
|
||||
virtual Timeline* getTimeline() { return _timeline; }
|
||||
|
||||
virtual void setNode(cocos2d::Node* node) { _node = node; }
|
||||
virtual cocos2d::Node* getTimelineNode() const { return _node; }
|
||||
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; }
|
||||
|
@ -63,11 +63,11 @@ protected:
|
|||
bool _tween;
|
||||
|
||||
Timeline* _timeline;
|
||||
cocos2d::Node* _node;
|
||||
Node* _node;
|
||||
};
|
||||
|
||||
|
||||
class VisibleFrame : public Frame
|
||||
class CC_DLL VisibleFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static VisibleFrame* create();
|
||||
|
@ -85,14 +85,14 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class TextureFrame : public Frame
|
||||
class CC_DLL TextureFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static TextureFrame* create();
|
||||
|
||||
TextureFrame();
|
||||
|
||||
virtual void setNode(cocos2d::Node* node);
|
||||
virtual void setNode(Node* node);
|
||||
|
||||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
@ -101,11 +101,11 @@ public:
|
|||
inline std::string getTexture() const { return _texture; }
|
||||
|
||||
protected:
|
||||
cocos2d::Sprite* _sprite;
|
||||
Sprite* _sprite;
|
||||
std::string _texture;
|
||||
};
|
||||
|
||||
class RotationFrame : public Frame
|
||||
class CC_DLL RotationFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static RotationFrame* create();
|
||||
|
@ -124,7 +124,7 @@ protected:
|
|||
float _betwennRotation;
|
||||
};
|
||||
|
||||
class SkewFrame : public Frame
|
||||
class CC_DLL SkewFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static SkewFrame* create();
|
||||
|
@ -149,7 +149,7 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class RotationSkewFrame : public SkewFrame
|
||||
class CC_DLL RotationSkewFrame : public SkewFrame
|
||||
{
|
||||
public:
|
||||
static RotationSkewFrame* create();
|
||||
|
@ -162,7 +162,7 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class PositionFrame : public Frame
|
||||
class CC_DLL PositionFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static PositionFrame* create();
|
||||
|
@ -173,8 +173,8 @@ public:
|
|||
virtual void apply(float percent) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setPosition(const cocos2d::Point& position) { _position = position; }
|
||||
inline cocos2d::Point getPosition() const { return _position; }
|
||||
inline void setPosition(const Point& position) { _position = position; }
|
||||
inline Point getPosition() const { return _position; }
|
||||
|
||||
inline void setX(float x) { _position.x = x; }
|
||||
inline void setY(float y) { _position.y = y; }
|
||||
|
@ -182,13 +182,13 @@ public:
|
|||
inline float getX() { return _position.x; }
|
||||
inline float getY() { return _position.y; }
|
||||
protected:
|
||||
cocos2d::Point _position;
|
||||
Point _position;
|
||||
float _betweenX;
|
||||
float _betweenY;
|
||||
};
|
||||
|
||||
|
||||
class ScaleFrame : public Frame
|
||||
class CC_DLL ScaleFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static ScaleFrame* create();
|
||||
|
@ -215,7 +215,7 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class AnchorPointFrame : public Frame
|
||||
class CC_DLL AnchorPointFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static AnchorPointFrame* create();
|
||||
|
@ -225,11 +225,11 @@ public:
|
|||
virtual void onEnter(Frame *nextFrame) override;
|
||||
virtual Frame* clone() override;
|
||||
|
||||
inline void setAnchorPoint(const cocos2d::Point& point) { _anchorPoint = point; }
|
||||
inline cocos2d::Point getAnchorPoint() const { return _anchorPoint; }
|
||||
inline void setAnchorPoint(const Point& point) { _anchorPoint = point; }
|
||||
inline Point getAnchorPoint() const { return _anchorPoint; }
|
||||
|
||||
protected:
|
||||
cocos2d::Point _anchorPoint;
|
||||
Point _anchorPoint;
|
||||
};
|
||||
|
||||
|
||||
|
@ -241,7 +241,7 @@ enum InnerActionType
|
|||
SingleFrame
|
||||
};
|
||||
|
||||
class InnerActionFrame : public Frame
|
||||
class CC_DLL InnerActionFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static InnerActionFrame* create();
|
||||
|
@ -262,7 +262,7 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class ColorFrame : public Frame
|
||||
class CC_DLL ColorFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static ColorFrame* create();
|
||||
|
@ -275,12 +275,12 @@ public:
|
|||
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
|
||||
inline GLubyte getAlpha() const { return _alpha; }
|
||||
|
||||
inline void setColor(const cocos2d::Color3B& color) { _color = color; }
|
||||
inline cocos2d::Color3B getColor() const { return _color; }
|
||||
inline void setColor(const Color3B& color) { _color = color; }
|
||||
inline Color3B getColor() const { return _color; }
|
||||
|
||||
protected:
|
||||
GLubyte _alpha;
|
||||
cocos2d::Color3B _color;
|
||||
Color3B _color;
|
||||
|
||||
int _betweenAlpha;
|
||||
int _betweenRed;
|
||||
|
@ -289,7 +289,7 @@ protected:
|
|||
};
|
||||
|
||||
|
||||
class EventFrame : public Frame
|
||||
class CC_DLL EventFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static EventFrame* create();
|
||||
|
@ -306,7 +306,7 @@ protected:
|
|||
std::string _event;
|
||||
};
|
||||
|
||||
class ZOrderFrame : public Frame
|
||||
class CC_DLL ZOrderFrame : public Frame
|
||||
{
|
||||
public:
|
||||
static ZOrderFrame* create();
|
||||
|
@ -323,8 +323,7 @@ protected:
|
|||
int _zorder;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
|
||||
#endif /*__CCFRAME_H__*/
|
|
@ -26,10 +26,7 @@ THE SOFTWARE.
|
|||
#include "CCTimelineAction.h"
|
||||
#include "CCFrame.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
NS_CC_BEGIN
|
||||
|
||||
Timeline* Timeline::create()
|
||||
{
|
||||
|
@ -109,7 +106,7 @@ void Timeline::removeFrame(Frame* frame)
|
|||
frame->setTimeline(NULL);
|
||||
}
|
||||
|
||||
void Timeline::setNode(cocos2d::Node* node)
|
||||
void Timeline::setNode(Node* node)
|
||||
{
|
||||
for (auto frame : _frames)
|
||||
{
|
||||
|
@ -117,7 +114,7 @@ void Timeline::setNode(cocos2d::Node* node)
|
|||
}
|
||||
}
|
||||
|
||||
cocos2d::Node* Timeline::getNode()
|
||||
Node* Timeline::getNode()
|
||||
{
|
||||
return _node;
|
||||
}
|
||||
|
@ -248,5 +245,4 @@ void Timeline::updateCurrentKeyFrame(int frameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
NS_CC_END
|
|
@ -25,15 +25,14 @@ THE SOFTWARE.
|
|||
#ifndef __CCTIMELINE_H__
|
||||
#define __CCTIMELINE_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "2d/CCNode.h"
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
NS_CC_BEGIN
|
||||
|
||||
class Frame;
|
||||
class TimelineAction;
|
||||
|
||||
class Timeline : public cocos2d::Ref
|
||||
class CC_DLL Timeline : public Ref
|
||||
{
|
||||
public:
|
||||
static Timeline* create();
|
||||
|
@ -44,8 +43,8 @@ public:
|
|||
virtual void gotoFrame(int frameIndex);
|
||||
virtual void stepToFrame(int frameIndex);
|
||||
|
||||
virtual cocos2d::Vector<Frame*>& getFrames() { return _frames; }
|
||||
virtual const cocos2d::Vector<Frame*>& getFrames() const { return _frames; }
|
||||
virtual Vector<Frame*>& getFrames() { return _frames; }
|
||||
virtual const Vector<Frame*>& getFrames() const { return _frames; }
|
||||
|
||||
virtual void addFrame(Frame* frame);
|
||||
virtual void insertFrame(Frame* frame, int index);
|
||||
|
@ -54,8 +53,8 @@ public:
|
|||
virtual void setActionTag(int tag) { _actionTag = tag; }
|
||||
virtual int getActionTag() { return _actionTag; }
|
||||
|
||||
virtual void setNode(cocos2d::Node* node);
|
||||
virtual cocos2d::Node* getNode();
|
||||
virtual void setNode(Node* node);
|
||||
virtual Node* getNode();
|
||||
|
||||
virtual void setTimelineAction(TimelineAction* action) { _timelineAction = action; }
|
||||
virtual TimelineAction* getTimelineAction() { return _timelineAction; }
|
||||
|
@ -69,7 +68,7 @@ protected:
|
|||
virtual void binarySearchKeyFrame (int frameIndex);
|
||||
virtual void updateCurrentKeyFrame(int frameIndex);
|
||||
|
||||
cocos2d::Vector<Frame*> _frames;
|
||||
Vector<Frame*> _frames;
|
||||
Frame* _currentKeyFrame;
|
||||
int _currentKeyFrameIndex;
|
||||
|
||||
|
@ -79,11 +78,10 @@ protected:
|
|||
int _actionTag;
|
||||
|
||||
TimelineAction* _timelineAction;
|
||||
cocos2d::Node* _node;
|
||||
Node* _node;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
|
||||
#endif /*__CCTIMELINE_H__*/
|
|
@ -23,13 +23,38 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCTimelineAction.h"
|
||||
#include "CCNodeReader.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
|
||||
// TimelineActionData
|
||||
TimelineActionData* TimelineActionData::create(int actionTag)
|
||||
{
|
||||
TimelineActionData * ret = new TimelineActionData();
|
||||
if (ret && ret->init(actionTag))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TimelineActionData::TimelineActionData()
|
||||
: _actionTag(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool TimelineActionData::init(int actionTag)
|
||||
{
|
||||
_actionTag = actionTag;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// TimelineAction
|
||||
TimelineAction* TimelineAction::create()
|
||||
{
|
||||
TimelineAction* object = new TimelineAction();
|
||||
|
@ -194,7 +219,7 @@ void TimelineAction::addTimeline(Timeline* timeline)
|
|||
int tag = timeline->getActionTag();
|
||||
if (_timelineMap.find(tag) == _timelineMap.end())
|
||||
{
|
||||
_timelineMap[tag] = cocos2d::Vector<Timeline*>();
|
||||
_timelineMap[tag] = Vector<Timeline*>();
|
||||
}
|
||||
|
||||
if (!_timelineMap[tag].contains(timeline))
|
||||
|
@ -256,5 +281,4 @@ void TimelineAction::stepToFrame(int frameIndex)
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
NS_CC_END
|
|
@ -25,17 +25,33 @@ THE SOFTWARE.
|
|||
#ifndef __CCTIMELINE_ACTION_H__
|
||||
#define __CCTIMELINE_ACTION_H__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include "CCTimeLine.h"
|
||||
#include "2d/CCNode.h"
|
||||
#include "2d/CCAction.h"
|
||||
#include "2d/CCTimeLine.h"
|
||||
#include "base/CCRef.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
NS_CC_BEGIN
|
||||
|
||||
typedef void (cocos2d::Ref::*SEL_FrameEventCallFunc)(Frame *);
|
||||
#define frameEvent_selector(_SELECTOR) (cocostudio::SEL_FrameEventCallFunc)(&_SELECTOR)
|
||||
typedef void (Ref::*SEL_FrameEventCallFunc)(Frame *);
|
||||
#define frameEvent_selector(_SELECTOR) (SEL_FrameEventCallFunc)(&_SELECTOR)
|
||||
|
||||
class TimelineAction : public cocos2d::Action
|
||||
class CC_DLL TimelineActionData : public Ref
|
||||
{
|
||||
public:
|
||||
static TimelineActionData* create(int actionTag);
|
||||
|
||||
virtual void setActionTag(int actionTag) { _actionTag = actionTag; }
|
||||
virtual int getActionTag() { return _actionTag; }
|
||||
protected:
|
||||
TimelineActionData();
|
||||
virtual bool init(int actionTag);
|
||||
|
||||
int _actionTag;
|
||||
};
|
||||
|
||||
|
||||
class CC_DLL TimelineAction : public Action
|
||||
{
|
||||
public:
|
||||
static TimelineAction* create();
|
||||
|
@ -105,7 +121,7 @@ public:
|
|||
/** emit frame event, call it when enter a frame*/
|
||||
void emitFrameEvent(Frame* frame);
|
||||
|
||||
/** Inherit from cocos2d::Action. */
|
||||
/** Inherit from Action. */
|
||||
|
||||
/** Returns a clone of TimelineAction */
|
||||
virtual TimelineAction* clone() const override;
|
||||
|
@ -116,14 +132,14 @@ public:
|
|||
virtual TimelineAction* reverse() const override { return nullptr; }
|
||||
|
||||
virtual void step(float delta) override;
|
||||
virtual void startWithTarget(cocos2d::Node *target) override;
|
||||
virtual void startWithTarget(Node *target) override;
|
||||
virtual bool isDone() const override { return false; }
|
||||
protected:
|
||||
virtual void gotoFrame(int frameIndex);
|
||||
virtual void stepToFrame(int frameIndex);
|
||||
|
||||
std::map<int, cocos2d::Vector<Timeline*>> _timelineMap;
|
||||
cocos2d::Vector<Timeline*> _timelineList;
|
||||
std::map<int, Vector<Timeline*>> _timelineMap;
|
||||
Vector<Timeline*> _timelineList;
|
||||
|
||||
int _duration;
|
||||
double _time;
|
||||
|
@ -137,8 +153,7 @@ protected:
|
|||
std::function<void(Frame*)> _frameEventListener;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
NS_CC_END
|
||||
|
||||
|
||||
#endif /*__CCTIMELINE_ACTION_H__*/
|
|
@ -303,6 +303,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClCompile Include="CCFontCharMap.cpp" />
|
||||
<ClCompile Include="CCFontFNT.cpp" />
|
||||
<ClCompile Include="CCFontFreeType.cpp" />
|
||||
<ClCompile Include="CCFrame.cpp" />
|
||||
<ClCompile Include="CCGLBufferedNode.cpp" />
|
||||
<ClCompile Include="CCGrabber.cpp" />
|
||||
<ClCompile Include="CCGrid.cpp" />
|
||||
|
@ -331,6 +332,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClCompile Include="CCSpriteFrameCache.cpp" />
|
||||
<ClCompile Include="CCTextFieldTTF.cpp" />
|
||||
<ClCompile Include="CCTileMapAtlas.cpp" />
|
||||
<ClCompile Include="CCTimeLine.cpp" />
|
||||
<ClCompile Include="CCTimelineAction.cpp" />
|
||||
<ClCompile Include="CCTMXLayer.cpp" />
|
||||
<ClCompile Include="CCTMXObjectGroup.cpp" />
|
||||
<ClCompile Include="CCTMXTiledMap.cpp" />
|
||||
|
@ -499,6 +502,7 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClInclude Include="CCFontCharMap.h" />
|
||||
<ClInclude Include="CCFontFNT.h" />
|
||||
<ClInclude Include="CCFontFreeType.h" />
|
||||
<ClInclude Include="CCFrame.h" />
|
||||
<ClInclude Include="CCGLBufferedNode.h" />
|
||||
<ClInclude Include="CCGrabber.h" />
|
||||
<ClInclude Include="CCGrid.h" />
|
||||
|
@ -527,6 +531,8 @@ xcopy /Y /Q "$(ProjectDir)..\..\external\win32-specific\gles\prebuilt\*.*" "$(Ou
|
|||
<ClInclude Include="CCSpriteFrameCache.h" />
|
||||
<ClInclude Include="CCTextFieldTTF.h" />
|
||||
<ClInclude Include="CCTileMapAtlas.h" />
|
||||
<ClInclude Include="CCTimeLine.h" />
|
||||
<ClInclude Include="CCTimelineAction.h" />
|
||||
<ClInclude Include="CCTMXLayer.h" />
|
||||
<ClInclude Include="CCTMXObjectGroup.h" />
|
||||
<ClInclude Include="CCTMXTiledMap.h" />
|
||||
|
|
|
@ -568,6 +568,15 @@
|
|||
<ClCompile Include="..\base\ObjectFactory.cpp">
|
||||
<Filter>base</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCFrame.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCTimeLine.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CCTimelineAction.cpp">
|
||||
<Filter>2d</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\physics\CCPhysicsBody.h">
|
||||
|
@ -1150,6 +1159,15 @@
|
|||
<ClInclude Include="..\base\ObjectFactory.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCFrame.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCTimeLine.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CCTimelineAction.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\math\Mat4.inl">
|
||||
|
|
|
@ -104,6 +104,9 @@ THE SOFTWARE.
|
|||
#include "2d/CCActionTween.h"
|
||||
#include "2d/CCActionCatmullRom.h"
|
||||
#include "2d/CCTweenFunction.h"
|
||||
#include "2d/CCFrame.h"
|
||||
#include "2d/CCTimeLine.h"
|
||||
#include "2d/CCTimelineAction.h"
|
||||
|
||||
// 2d nodes
|
||||
#include "2d/CCNode.h"
|
||||
|
|
|
@ -58,10 +58,7 @@ THE SOFTWARE.
|
|||
#include "cocostudio/CCSGUIReader.h"
|
||||
#include "cocostudio/CCSSceneReader.h"
|
||||
#include "cocostudio/TriggerBase.h"
|
||||
#include "cocostudio/TimelineAction/CCFrame.h"
|
||||
#include "cocostudio/TimelineAction/CCNodeReader.h"
|
||||
#include "cocostudio/TimelineAction/CCTimeLine.h"
|
||||
#include "cocostudio/TimelineAction/CCTimelineAction.h"
|
||||
#include "cocostudio/TimelineAction/CCTimelineActionCache.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -24,12 +24,11 @@ THE SOFTWARE.
|
|||
|
||||
#include "CCNodeReader.h"
|
||||
#include "CCTimelineActionCache.h"
|
||||
#include "CCFrame.h"
|
||||
|
||||
#include "../CCSGUIReader.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
using namespace cocos2d::ui;
|
||||
using namespace ui;
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
|
@ -40,7 +39,7 @@ static const char* ClassName_SubGraph = "SubGraph";
|
|||
static const char* ClassName_Sprite = "Sprite";
|
||||
static const char* ClassName_Particle = "Particle";
|
||||
|
||||
static const char* ClassName_Panel = "Panel";
|
||||
static const char* ClassName_Panel = "Panel";
|
||||
static const char* ClassName_Button = "Button";
|
||||
static const char* ClassName_CheckBox = "CheckBox";
|
||||
static const char* ClassName_ImageView = "ImageView";
|
||||
|
@ -89,32 +88,6 @@ static const char* PARTICLE_NUM = "particleNum";
|
|||
static const char* TEXTURES = "textures";
|
||||
static const char* TEXTURES_PNG = "texturesPng";
|
||||
|
||||
// TimelineActionData
|
||||
TimelineActionData* TimelineActionData::create(int actionTag)
|
||||
{
|
||||
TimelineActionData * ret = new TimelineActionData();
|
||||
if (ret && ret->init(actionTag))
|
||||
{
|
||||
ret->autorelease();
|
||||
}
|
||||
else
|
||||
{
|
||||
CC_SAFE_DELETE(ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
TimelineActionData::TimelineActionData()
|
||||
: _actionTag(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool TimelineActionData::init(int actionTag)
|
||||
{
|
||||
_actionTag = actionTag;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// NodeReader
|
||||
static NodeReader* _sharedNodeReader = nullptr;
|
||||
|
@ -173,7 +146,7 @@ void NodeReader::init()
|
|||
_guiReader = new WidgetPropertiesReader0300();
|
||||
}
|
||||
|
||||
cocos2d::Node* NodeReader::createNode(const std::string& filename)
|
||||
Node* NodeReader::createNode(const std::string& filename)
|
||||
{
|
||||
if(_recordJsonPath)
|
||||
{
|
||||
|
@ -188,17 +161,17 @@ cocos2d::Node* NodeReader::createNode(const std::string& filename)
|
|||
_jsonPath = "";
|
||||
}
|
||||
|
||||
cocos2d::Node* node = loadNodeWithFile(filename);
|
||||
Node* node = loadNodeWithFile(filename);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
cocos2d::Node* NodeReader::loadNodeWithFile(const std::string& fileName)
|
||||
Node* NodeReader::loadNodeWithFile(const std::string& fileName)
|
||||
{
|
||||
// Read content from file
|
||||
std::string contentStr = FileUtils::getInstance()->getStringFromFile(fileName);
|
||||
|
||||
cocos2d::Node* node = loadNodeWithContent(contentStr);
|
||||
Node* node = loadNodeWithContent(contentStr);
|
||||
|
||||
// Load animation data from file
|
||||
TimelineActionCache::getInstance()->loadAnimationActionWithContent(fileName, contentStr);
|
||||
|
@ -206,7 +179,7 @@ cocos2d::Node* NodeReader::loadNodeWithFile(const std::string& fileName)
|
|||
return node;
|
||||
}
|
||||
|
||||
cocos2d::Node* NodeReader::loadNodeWithContent(const std::string& content)
|
||||
Node* NodeReader::loadNodeWithContent(const std::string& content)
|
||||
{
|
||||
rapidjson::Document doc;
|
||||
doc.Parse<0>(content.c_str());
|
||||
|
@ -229,15 +202,15 @@ cocos2d::Node* NodeReader::loadNodeWithContent(const std::string& content)
|
|||
|
||||
// decode node tree
|
||||
const rapidjson::Value& subJson = DICTOOL->getSubDictionary_json(doc, NODE);
|
||||
cocos2d::Node* root = loadNode(subJson);
|
||||
Node* root = loadNode(subJson);
|
||||
root->release();
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
cocos2d::Node* NodeReader::loadNode(const rapidjson::Value& json)
|
||||
Node* NodeReader::loadNode(const rapidjson::Value& json)
|
||||
{
|
||||
cocos2d::Node* node = nullptr;
|
||||
Node* node = nullptr;
|
||||
std::string nodeType = DICTOOL->getStringValue_json(json, CLASSNAME);
|
||||
|
||||
NodeCreateFunc func = _funcs.at(nodeType);
|
||||
|
@ -253,7 +226,7 @@ cocos2d::Node* NodeReader::loadNode(const rapidjson::Value& json)
|
|||
for (int i = 0; i<length; i++)
|
||||
{
|
||||
const rapidjson::Value &dic = DICTOOL->getSubDictionary_json(json, CHILDREN, i);
|
||||
cocos2d::Node* child = loadNode(dic);
|
||||
Node* child = loadNode(dic);
|
||||
if (child)
|
||||
{
|
||||
node->addChild(child);
|
||||
|
@ -269,7 +242,7 @@ cocos2d::Node* NodeReader::loadNode(const rapidjson::Value& json)
|
|||
return node;
|
||||
}
|
||||
|
||||
void NodeReader::initNode(cocos2d::Node* node, const rapidjson::Value& json)
|
||||
void NodeReader::initNode(Node* node, const rapidjson::Value& json)
|
||||
{
|
||||
float width = DICTOOL->getFloatValue_json(json, WIDTH);
|
||||
float height = DICTOOL->getFloatValue_json(json, HEIGHT);
|
||||
|
@ -338,7 +311,7 @@ Node* NodeReader::loadSimpleNode(const rapidjson::Value& json)
|
|||
return node;
|
||||
}
|
||||
|
||||
cocos2d::Node* NodeReader::loadSubGraph(const rapidjson::Value& json)
|
||||
Node* NodeReader::loadSubGraph(const rapidjson::Value& json)
|
||||
{
|
||||
const char* filePath = DICTOOL->getStringValue_json(json, FILE_PATH);
|
||||
|
||||
|
@ -411,7 +384,7 @@ Node* NodeReader::loadParticle(const rapidjson::Value& json)
|
|||
return particle;
|
||||
}
|
||||
|
||||
cocos2d::Node* NodeReader::loadWidget(const rapidjson::Value& json)
|
||||
Node* NodeReader::loadWidget(const rapidjson::Value& json)
|
||||
{
|
||||
const char* str = DICTOOL->getStringValue_json(json, CLASSNAME);
|
||||
if(str == nullptr)
|
||||
|
|
|
@ -25,9 +25,8 @@ THE SOFTWARE.
|
|||
#ifndef __CC_NODE_CACHE_H__
|
||||
#define __CC_NODE_CACHE_H__
|
||||
|
||||
#include "CCTimeLine.h"
|
||||
#include "cocostudio/DictionaryHelper.h"
|
||||
|
||||
#include "cocos2d.h"
|
||||
|
||||
namespace cocostudio {
|
||||
|
||||
|
@ -35,20 +34,6 @@ class WidgetPropertiesReader0300;
|
|||
|
||||
namespace timeline{
|
||||
|
||||
class TimelineActionData : public cocos2d::Ref
|
||||
{
|
||||
public:
|
||||
static TimelineActionData* create(int actionTag);
|
||||
|
||||
virtual void setActionTag(int actionTag) { _actionTag = actionTag; }
|
||||
virtual int getActionTag() { return _actionTag; }
|
||||
protected:
|
||||
TimelineActionData();
|
||||
virtual bool init(int actionTag);
|
||||
|
||||
int _actionTag;
|
||||
};
|
||||
|
||||
class NodeReader
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -23,8 +23,6 @@ THE SOFTWARE.
|
|||
****************************************************************************/
|
||||
|
||||
#include "CCTimelineActionCache.h"
|
||||
#include "CCTimelineAction.h"
|
||||
#include "CCFrame.h"
|
||||
#include "CCNodeReader.h"
|
||||
|
||||
using namespace cocos2d;
|
||||
|
|
|
@ -28,12 +28,9 @@ THE SOFTWARE.
|
|||
#include "cocos2d.h"
|
||||
#include "cocostudio/DictionaryHelper.h"
|
||||
|
||||
#include "CCTimeLine.h"
|
||||
|
||||
namespace cocostudio {
|
||||
namespace timeline{
|
||||
|
||||
class TimelineAction;
|
||||
|
||||
class TimelineActionCache
|
||||
{
|
||||
|
@ -52,34 +49,34 @@ public:
|
|||
void removeAction(const std::string& fileName);
|
||||
|
||||
/** Clone a action with the specified name from the container. */
|
||||
TimelineAction* createAction(const std::string& fileName);
|
||||
cocos2d::TimelineAction* createAction(const std::string& fileName);
|
||||
|
||||
TimelineAction* loadAnimationActionWithFile(const std::string& fileName);
|
||||
TimelineAction* loadAnimationActionWithContent(const std::string&fileName, const std::string& content);
|
||||
cocos2d::TimelineAction* loadAnimationActionWithFile(const std::string& fileName);
|
||||
cocos2d::TimelineAction* loadAnimationActionWithContent(const std::string&fileName, const std::string& content);
|
||||
protected:
|
||||
|
||||
Timeline* loadTimeline(const rapidjson::Value& json);
|
||||
cocos2d::Timeline* loadTimeline(const rapidjson::Value& json);
|
||||
|
||||
Frame* loadVisibleFrame (const rapidjson::Value& json);
|
||||
Frame* loadPositionFrame (const rapidjson::Value& json);
|
||||
Frame* loadScaleFrame (const rapidjson::Value& json);
|
||||
Frame* loadSkewFrame (const rapidjson::Value& json);
|
||||
Frame* loadRotationSkewFrame(const rapidjson::Value& json);
|
||||
Frame* loadRotationFrame (const rapidjson::Value& json);
|
||||
Frame* loadAnchorPointFrame (const rapidjson::Value& json);
|
||||
Frame* loadInnerActionFrame (const rapidjson::Value& json);
|
||||
Frame* loadColorFrame (const rapidjson::Value& json);
|
||||
Frame* loadTextureFrame (const rapidjson::Value& json);
|
||||
Frame* loadEventFrame (const rapidjson::Value& json);
|
||||
Frame* loadZOrderFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadVisibleFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadPositionFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadScaleFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadSkewFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadRotationSkewFrame(const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadRotationFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadAnchorPointFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadInnerActionFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadColorFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadTextureFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadEventFrame (const rapidjson::Value& json);
|
||||
cocos2d::Frame* loadZOrderFrame (const rapidjson::Value& json);
|
||||
|
||||
protected:
|
||||
|
||||
typedef std::function<Frame*(const rapidjson::Value& json)> FrameCreateFunc;
|
||||
typedef std::function<cocos2d::Frame*(const rapidjson::Value& json)> FrameCreateFunc;
|
||||
typedef std::pair<std::string, FrameCreateFunc> Pair;
|
||||
|
||||
std::unordered_map<std::string, FrameCreateFunc> _funcs;
|
||||
cocos2d::Map<std::string, TimelineAction*> _animationActions;
|
||||
cocos2d::Map<std::string, cocos2d::TimelineAction*> _animationActions;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -42,10 +42,7 @@
|
|||
<ClCompile Include="..\CCTween.cpp" />
|
||||
<ClCompile Include="..\CCUtilMath.cpp" />
|
||||
<ClCompile Include="..\DictionaryHelper.cpp" />
|
||||
<ClCompile Include="..\TimelineAction\CCFrame.cpp" />
|
||||
<ClCompile Include="..\TimelineAction\CCNodeReader.cpp" />
|
||||
<ClCompile Include="..\TimelineAction\CCTimeLine.cpp" />
|
||||
<ClCompile Include="..\TimelineAction\CCTimelineAction.cpp" />
|
||||
<ClCompile Include="..\TimelineAction\CCTimelineActionCache.cpp" />
|
||||
<ClCompile Include="..\TriggerBase.cpp" />
|
||||
<ClCompile Include="..\TriggerMng.cpp" />
|
||||
|
@ -108,10 +105,7 @@
|
|||
<ClInclude Include="..\CCTween.h" />
|
||||
<ClInclude Include="..\CCUtilMath.h" />
|
||||
<ClInclude Include="..\DictionaryHelper.h" />
|
||||
<ClInclude Include="..\TimelineAction\CCFrame.h" />
|
||||
<ClInclude Include="..\TimelineAction\CCNodeReader.h" />
|
||||
<ClInclude Include="..\TimelineAction\CCTimeLine.h" />
|
||||
<ClInclude Include="..\TimelineAction\CCTimelineAction.h" />
|
||||
<ClInclude Include="..\TimelineAction\CCTimelineActionCache.h" />
|
||||
<ClInclude Include="..\TriggerBase.h" />
|
||||
<ClInclude Include="..\TriggerMng.h" />
|
||||
|
|
|
@ -231,15 +231,6 @@
|
|||
<ClCompile Include="..\WidgetReader\PageViewReader\PageViewReader.cpp">
|
||||
<Filter>reader\WidgetReader\PageViewReader</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\TimelineAction\CCFrame.cpp">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\TimelineAction\CCTimeLine.cpp">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\TimelineAction\CCTimelineAction.cpp">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\TimelineAction\CCTimelineActionCache.cpp">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClCompile>
|
||||
|
@ -428,15 +419,6 @@
|
|||
<ClInclude Include="..\WidgetReader\PageViewReader\PageViewReader.h">
|
||||
<Filter>reader\WidgetReader\PageViewReader</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\TimelineAction\CCFrame.h">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\TimelineAction\CCTimeLine.h">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\TimelineAction\CCTimelineAction.h">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\TimelineAction\CCTimelineActionCache.h">
|
||||
<Filter>TimelineAction</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in New Issue