How to implement the Sprite Animation by using Cocos2D in Android (JAVA VERSION)?

1.3k Views Asked by At

I know there is "the simple game sample of Android Cocos2D" and "how-to-animate-sprites-in-cocos2d". I use the "space shooter" Android source code as sample, create a simple card game.

But there is the big problem that I don't know how to use CCSpriteFrame to create the sprite animation for the cards. The space shooter does not have any animation code.

So I am here to asking the code sample about how to create sprite animation by using Cocos2D Android (JAVA VERSION).

1

There are 1 best solutions below

0
On

This is the way which i use for my animation hope it will helpfull for you.

ArrayList<CCSpriteFrame> animFrames = new ArrayList<CCSpriteFrame>();
              CCSpriteFrameCache.sharedSpriteFrameCache();
              for (int i = 1;i <= 4; i++)
              { CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName( "sparkle." + i +".png");
              animFrames.add(frame);
              }