2014-06-11 11:10:07 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCFRAME_H__
|
|
|
|
#define __CCFRAME_H__
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "CCTimelineMacro.h"
|
2014-06-11 11:10:07 +08:00
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
NS_TIMELINE_BEGIN
|
2014-06-11 11:10:07 +08:00
|
|
|
|
2014-06-13 16:03:03 +08:00
|
|
|
class Timeline;
|
2014-06-11 11:10:07 +08:00
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class Frame : public cocos2d::Ref
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void setFrameIndex(unsigned int frameIndex) { _frameIndex = frameIndex; }
|
2014-06-13 16:03:03 +08:00
|
|
|
virtual unsigned int getFrameIndex() const { return _frameIndex; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
virtual void setTimeline(Timeline* timeline) { _timeline = timeline; }
|
2014-06-13 16:03:03 +08:00
|
|
|
virtual Timeline* getTimeline() const { return _timeline; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
virtual void setNode(cocos2d::Node* node) { _node = node; }
|
2014-06-18 11:22:38 +08:00
|
|
|
virtual cocos2d::Node* getNode() const { return _node; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
virtual void setTween(bool tween) { _tween = tween; }
|
2014-06-13 16:03:03 +08:00
|
|
|
virtual bool isTween() const { return _tween; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) = 0;
|
|
|
|
virtual void apply(float percent) {}
|
|
|
|
|
|
|
|
virtual Frame* clone() = 0;
|
|
|
|
protected:
|
|
|
|
Frame();
|
|
|
|
virtual ~Frame();
|
|
|
|
|
2014-06-13 16:03:03 +08:00
|
|
|
virtual void emitEvent();
|
|
|
|
virtual void cloneProperty(Frame* frame);
|
2014-06-11 11:10:07 +08:00
|
|
|
protected:
|
|
|
|
|
|
|
|
unsigned int _frameIndex;
|
|
|
|
bool _tween;
|
|
|
|
|
|
|
|
Timeline* _timeline;
|
2014-06-13 18:51:32 +08:00
|
|
|
cocos2d::Node* _node;
|
2014-06-11 11:10:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class VisibleFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static VisibleFrame* create();
|
|
|
|
|
|
|
|
VisibleFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setVisible(bool visible) { _visible = visible;}
|
|
|
|
inline bool isVisible() const { return _visible; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool _visible;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class TextureFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static TextureFrame* create();
|
|
|
|
|
|
|
|
TextureFrame();
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
virtual void setNode(cocos2d::Node* node);
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
2014-06-13 19:52:53 +08:00
|
|
|
inline void setTextureName(std::string textureName) { _textureName = textureName;}
|
|
|
|
inline std::string getTextureName() const { return _textureName; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
protected:
|
2014-06-13 18:51:32 +08:00
|
|
|
cocos2d::Sprite* _sprite;
|
2014-06-13 19:52:53 +08:00
|
|
|
std::string _textureName;
|
2014-06-11 11:10:07 +08:00
|
|
|
};
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class RotationFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static RotationFrame* create();
|
|
|
|
|
|
|
|
RotationFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual void apply(float percent) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setRotation(float rotation) { _rotation = rotation; }
|
|
|
|
inline float getRotation() const { return _rotation; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float _rotation;
|
|
|
|
float _betwennRotation;
|
|
|
|
};
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class SkewFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static SkewFrame* create();
|
|
|
|
|
|
|
|
SkewFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual void apply(float percent) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setSkewX(float skewx) { _skewX = skewx; }
|
|
|
|
inline float getSkewX() const { return _skewX; }
|
|
|
|
|
|
|
|
inline void setSkewY(float skewy) { _skewY = skewy; }
|
|
|
|
inline float getSkewY() const { return _skewY; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float _skewX;
|
|
|
|
float _skewY;
|
|
|
|
float _betweenSkewX;
|
|
|
|
float _betweenSkewY;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class RotationSkewFrame : public SkewFrame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static RotationSkewFrame* create();
|
|
|
|
|
|
|
|
RotationSkewFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual void apply(float percent) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class PositionFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static PositionFrame* create();
|
|
|
|
|
|
|
|
PositionFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual void apply(float percent) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
inline void setPosition(const cocos2d::Point& position) { _position = position; }
|
|
|
|
inline cocos2d::Point getPosition() const { return _position; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
inline void setX(float x) { _position.x = x; }
|
|
|
|
inline void setY(float y) { _position.y = y; }
|
|
|
|
|
2014-06-13 16:03:03 +08:00
|
|
|
inline float getX() const { return _position.x; }
|
|
|
|
inline float getY() const { return _position.y; }
|
2014-06-11 11:10:07 +08:00
|
|
|
protected:
|
2014-06-13 18:51:32 +08:00
|
|
|
cocos2d::Point _position;
|
2014-06-11 11:10:07 +08:00
|
|
|
float _betweenX;
|
|
|
|
float _betweenY;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class ScaleFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static ScaleFrame* create();
|
|
|
|
|
|
|
|
ScaleFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual void apply(float percent) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setScale(float scale) { _scaleX = scale; _scaleY = scale; }
|
|
|
|
|
|
|
|
inline void setScaleX(float scaleX) { _scaleX = scaleX; }
|
|
|
|
inline float getScaleX() const { return _scaleX; }
|
|
|
|
|
|
|
|
inline void setScaleY(float scaleY) { _scaleY = scaleY;}
|
|
|
|
inline float getScaleY() const { return _scaleY; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
float _scaleX;
|
|
|
|
float _scaleY;
|
|
|
|
float _betweenScaleX;
|
|
|
|
float _betweenScaleY;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class AnchorPointFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static AnchorPointFrame* create();
|
|
|
|
|
|
|
|
AnchorPointFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
inline void setAnchorPoint(const cocos2d::Point& point) { _anchorPoint = point; }
|
|
|
|
inline cocos2d::Point getAnchorPoint() const { return _anchorPoint; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
protected:
|
2014-06-13 18:51:32 +08:00
|
|
|
cocos2d::Point _anchorPoint;
|
2014-06-11 11:10:07 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum InnerActionType
|
|
|
|
{
|
|
|
|
LoopAction,
|
|
|
|
NoLoopAction,
|
|
|
|
SingleFrame
|
|
|
|
};
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class InnerActionFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static InnerActionFrame* create();
|
|
|
|
InnerActionFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setInnerActionType(InnerActionType type) { _innerActionType = type; }
|
|
|
|
inline InnerActionType getInnerActionType() const { return _innerActionType; }
|
|
|
|
|
|
|
|
inline void setStartFrameIndex(int frameIndex) { _startFrameIndex = frameIndex; }
|
|
|
|
inline int getStartFrameIndex() const { return _startFrameIndex; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
InnerActionType _innerActionType;
|
|
|
|
int _startFrameIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class ColorFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static ColorFrame* create();
|
|
|
|
ColorFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual void apply(float percent) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setAlpha(GLubyte alpha) { _alpha = alpha; }
|
|
|
|
inline GLubyte getAlpha() const { return _alpha; }
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
inline void setColor(const cocos2d::Color3B& color) { _color = color; }
|
|
|
|
inline cocos2d::Color3B getColor() const { return _color; }
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
protected:
|
|
|
|
GLubyte _alpha;
|
2014-06-13 18:51:32 +08:00
|
|
|
cocos2d::Color3B _color;
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
int _betweenAlpha;
|
|
|
|
int _betweenRed;
|
|
|
|
int _betweenGreen;
|
|
|
|
int _betweenBlue;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class EventFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static EventFrame* create();
|
|
|
|
|
|
|
|
EventFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setEvent(std::string event) { _event = event;}
|
|
|
|
inline std::string getEvent() const { return _event; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
std::string _event;
|
|
|
|
};
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
class ZOrderFrame : public Frame
|
2014-06-11 11:10:07 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
static ZOrderFrame* create();
|
|
|
|
|
|
|
|
ZOrderFrame();
|
|
|
|
|
|
|
|
virtual void onEnter(Frame *nextFrame) override;
|
|
|
|
virtual Frame* clone() override;
|
|
|
|
|
|
|
|
inline void setZOrder(int zorder) { _zorder = zorder;}
|
|
|
|
inline int getZOrder() const { return _zorder; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
int _zorder;
|
|
|
|
};
|
|
|
|
|
2014-06-13 18:51:32 +08:00
|
|
|
NS_TIMELINE_END
|
2014-06-11 11:10:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
#endif /*__CCFRAME_H__*/
|