Cocos动画系统

动画系统也是Cocos的UI中一个重要的模块,今天对它的运作进行解析。
一个动画的基类是Action,其声明如下:

class CC_DLL Action : public Ref, public Clonable
{
public:
    virtual std::string description() const;
    virtual bool isDone() const;
    virtual void startWithTarget(Node *target);
    virtual void stop();
    virtual void step(float dt);
    virtual void update(float time);
    Node* getTarget() const { return _target; }
    void setTarget(Node *target) { _target = target; }
    Node* getOriginalTarget() const { return _originalTarget; }
    void setOriginalTarget(Node *originalTarget) { _originalTarget = originalTarget; }
    int getTag() const { return _tag; }
    void setTag(int tag) { _tag = tag; }
    unsigned int getFlags() const { return _flags; }
    void setFlags(unsigned int flags) { _flags = flags; }

CC_CONSTRUCTOR_ACCESS:
    Action();
    virtual ~Action();

protected:
    Node    *_originalTarget;
    Node    *_target;
    int     _tag;
    unsigned int _flags;
};

基类中主要包含播放动画的节点_target,用于记录动画信息的_tag,以及step、update等虚函数。

猜你喜欢

转载自www.cnblogs.com/wickedpriest/p/12242421.html
今日推荐