cocos2d-X 节点(CCAnimationCache.h)API

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

cocos2d-X 节点(CCAnimationCache.h)API

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

#ifndef __CC_ANIMATION_CACHE_H__
#define __CC_ANIMATION_CACHE_H__

#include "cocoa/CCObject.h"
#include "cocoa/CCDictionary.h"

#include <string>

NS_CC_BEGIN

class Animation;

/**
 * @addtogroup sprite_nodes
 * @{
 */

/**  管理 Animations 的 Singleton(单例).
他把 animations 存储到 擦车里. 如果你希望在 cache 里面存储你的 animations(cocos2d 把所有的动画统称为 animatiosns),你可以使用这个类

Before v0.99.5, 推荐使用这个方法存储 Sprite. Since v0.99.5, 你应该使用这个类代替

@since v0.99.5
*/
class CC_DLL AnimationCache : public Object
{
public:
    /**
     * @js ctor
     */
    AnimationCache();
    /**
     * @js NA
     * @lua NA
     */
    ~AnimationCache();
    /** Returns 动画缓存的共享实例e */
    static AnimationCache* getInstance();

    /** 清除缓存。它释放所有动画对象和共享实例。
     */
    static void destroyInstance();

    /** @过时不再需要建议使用新的 API 可以使用 getInstance() 代替 */
    CC_DEPRECATED_ATTRIBUTE static AnimationCache* sharedAnimationCache() { return AnimationCache::getInstance(); }

    /** @过时不再需要建议使用新的 API 可以使用 destroyInstance() 代替 */
    CC_DEPRECATED_ATTRIBUTE static void purgeSharedAnimationCache() { return AnimationCache::destroyInstance(); }

    bool init(void);

    /** 使用 name 添加一个 Animation
    */
    void addAnimation(Animation *animation, const char * name);

    /** 从 cache里面删除 一个 Animation
     
     */
    void removeAnimation(const char* name);
    /** @过时不再需要建议使用新的 API 可以使用 removeAnimation() 代替
     * @js NA
     * @lua NA
     */
    CC_DEPRECATED_ATTRIBUTE void removeAnimationByName(const char* name){ removeAnimation(name);}

    /** Returns 先前添加的 Animation
    如果没有找到 name 对应的 animation 返回 nil
    如果你要使用他你应该  retain(保留)返回的副本
    */
    Animation* getAnimation(const char* name);
    /**
     @过时不再需要建议使用新的 API  可以使用 getAnimation() 代替
     * @js NA
     * @lua NA
     */
    CC_DEPRECATED_ATTRIBUTE Animation* animationByName(const char* name){ return getAnimation(name); }

    /** 使用 NSDictionary 添加一个 animaton
    请确保先前的 frames 在 SpriteFrameCache 里面加载成功
     @since v1.1
     */
    void addAnimationsWithDictionary(Dictionary* dictionary);

    /** 从 plist 文件添加 animation
    请确保先前的 frames 在 SpriteFrameCache 里面加载成功
     @since v1.1
     * @js addAnimations
     * @lua addAnimations
     */
    void addAnimationsWithFile(const char* plist);

private:
    void parseVersion1(Dictionary* animations);
    void parseVersion2(Dictionary* animations);

private:
    Dictionary* _animations;
    static AnimationCache* s_pSharedAnimationCache;
};

// end of sprite_nodes group
/// @}

NS_CC_END

#endif // __CC_ANIMATION_CACHE_H__


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值