【问题标题】:Cocos2d and usage of CCAnimationCacheCocos2d及CCAnimationCache的使用
【发布时间】:2012-11-19 16:47:52
【问题描述】:

我想了解 CCAnimationCache 的用法。

我有一个敌人对象的缓存。每个对象都有两个 CCAnimations 成员变量,一个标准动画和一个特殊动画。动画中的帧根据敌人对象的类型属性而有所不同。

@interface EnemyEntity : Entity
{
    EnemyTypes type;
    CCAnimation * animation;
    CCAnimationCache * animationCache;
}

通常情况下,在屏幕上我确实有几个相同类型敌人的实例,我想知道是否应该使用 CCAnimationCache 而不是 CCAnimation 成员变量。

如果是这样,我应该把 CCAnimationCache 实例放在哪里?

【问题讨论】:

    标签: animation cocos2d-iphone memcached


    【解决方案1】:

    嗯。您不阅读标题中的 cmets 吗?

    /** Singleton that manages the Animations.
     It saves in a cache the animations. You should use this class if you want to save your animations in a cache.
    
     Before v0.99.5, the recommend way was to save them on the CCSprite. Since v0.99.5, you should use this class instead.
    
     @since v0.99.5
     */
    

    此评论位于CCAnimationCache.h 文件中。所以,这是一个 cocos2d 的单例(CCTextureCache、CCSpriteFrameCache)。如果你想使用它,只需调用

    CCAnimationCache* animationCache = [CCAnimationCache sharedAnimationCache];
    

    【讨论】:

    • 天哪,我读过它,但没有意识到这是一个单身人士。哇!这比我想象的要容易得多:)。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多