Quantcast
Channel: snippet Feed
Viewing all articles
Browse latest Browse all 29

How can you cache CCAnimation in Cocos2D?

$
0
0

Cocos2D provides a simple way to cache you Animations using CCAnimationCache class.
The CCAnimationCache is implemented as a singleton which can be accessed using the [CCAnimationCache sharedAnimationCache] method.This approach is particularly useful if the animation steps are common across more than one sprites.

  1. [[CCAnimationCache sharedAnimationCache] addAnimation:animationToCache name:@"NameOfAnimation"];
  2.  
  3.  
  4. CCAnimation *myAnimation =[[CCAnimationCache sharedAnimationCache]
  5. animationByName:@"NameOfAnimation"];

Viewing all articles
Browse latest Browse all 29

Trending Articles