2012-11-19 4 views
1

CCAnimationCache의 사용법을 알고 싶습니다.Cocos2d 및 CCAnimationCache의 사용

적 대상 개체의 캐시가 있습니다. 각 객체에는 두 개의 CCAnimations 멤버 변수, 표준 애니메이션 및 특수 애니메이션이 있습니다. 애니메이션의 프레임은 적 개체의 유형 속성에 따라 다릅니다. 종종 화면에 내가 대신 CCAnimationCache CCAnimation 멤버 변수를 사용하는 경우는 내가 궁금 같은 적 유형의 여러 인스턴스를 할 경우와 마찬가지로

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

.

그렇다면 CCAnimationCache 인스턴스를 어디에 배치해야합니까?

답변

3

허. 헤더의 주석을 읽지 않습니까?

/** 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]; 
+0

오, 나는 그것을 읽었지만 그것이 싱글 톤이라는 것을 깨닫지 못했다. 와우! 그것은 내가 생각했던 것보다 훨씬 쉽다. :) 감사! – mm24

+0

당신을 환영합니다 =) – Morion