本文来自http://blog.csdn.net/runaying ,引用必须注明出处!

cocos2d-X 节点(CCActionNode.h)API

温馨提醒:为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记

// 设置帧的时间间隔 ,设置 action 的标记,插入 帧,清除 帧,播放 action更新 action

///cocos2d-x-3.0alpha0/extensions/CocoStudio/Action
// 设置帧的时间间隔 ,设置 action 的标记,插入 帧,清除 帧,播放 action, 更新 action


#ifndef __ActionNODE_H__
#define __ActionNODE_H__

#include "cocos2d.h"
#include "ExtensionMacros.h"
#include "CCActionFrame.h"
#include "../Json/CSContentJsonDictionary.h"

NS_CC_EXT_BEGIN

class ActionNode:public Object
{
public:
    
    /**
     * Default constructor      //构造函数
     */
    ActionNode();

    /**
     * Default destructor       //析构函数
     */
    virtual ~ActionNode();
    /**
     * Sets 帧的时间间隔。
     *
	 * @param fTime  帧的时间间隔。
     */
	void setUnitTime(float fTime);
    
    /**
     * Gets 帧的时间间隔。
     *
	 * @return fTime   帧的时间间隔。
     */
	float getUnitTime();
    /**
     * Sets ActionNode 标记
     *
     * @param tag    ActionNode 标记
     */
	void setActionTag(int tag);
    
    /**
     * Gets  ActionNode 标记
     *
     * @return tag   ActionNode 标记
     */
	int getActionTag();

    /**
     * Sets 将运行 action 的 node
     *
     * @param  node 将运行 action 的 node
     */
	void setObject(Object* node);
	Object* getObject();

    /**
     * 插入一个 ActionFrame 到 ActionNode.
     *
     * @param index  ActionFrame 的 index
     *
     * @param frame  要添加的 ActionFrame
     */
	void insertFrame(int index, ActionFrame* frame);
    
    /**
     * Pushs back a ActionFrame to ActionNode.
     *
     * @param frame  要添加的 ActionFrame
     */
	void addFrame(ActionFrame* frame);
    
    /**
     *  从 ActionNode 里面移除一个 ActionFrame 
     *
     * @param frame  要移除的 ActionFrame
     */
	void deleteFrame(ActionFrame* frame );
    
    /**
     *  从 ActionNode 里面移除所有 ActionFrames
     */
	void clearAllFrame();

    /**
     * 获取第一个 ActionFrame索引。
     *
     * @return  第一个 ActionFrame索引。
     */
	int getFirstFrameIndex();
    
    /**
     * Gets 最后一个 ActionFrame索引。
     *
     * @return  最后一个 ActionFrame索引。
     */
	int getLastFrameIndex();

    /**
     * 以一定的时间,更新 action  状态
     *
     * @param fTime   需要更新的时间
     */
	virtual bool updateActionToTimeLine(float fTime);

    /**
     * 播放一个 action.
     *
     * @param bloop   true the
     */
	virtual void playAction(bool bloop);
    
    /**
     * Stop the action.
     */
	virtual void stopAction();
	
    /* 使用 json 字典初始化属性 */
    virtual void initWithDictionary(cs::JsonDictionary* dic,Object* root);
protected:
	int _currentFrameIndex;
	int _destFrameIndex;
	
	float _fUnitTime;
    
	int _actionTag;
	Spawn * _actionSpawn;
	Action* _action;
	Object* _object;
    
	Array* _frameArray;
	int _frameArrayNum;

protected:
	virtual Node* getActionNode();
	virtual Spawn * refreshActionProperty();
	virtual void runAction();
	virtual void initActionNodeFromRoot(Object* root);
	virtual void easingToFrame(float duration,float delayTime,ActionFrame* destFrame);
};

NS_CC_EXT_END

#endif



Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐