简体   繁体   English

如何在Android(JAVA版本)中使用Cocos2D来实现Sprite动画?

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

I know there is "the simple game sample of Android Cocos2D" and "how-to-animate-sprites-in-cocos2d". 我知道有“ Android Cocos2D的简单游戏示例”和“如何在cocos2d中动画精灵”。 I use the "space shooter" Android source code as sample, create a simple card game. 我使用“太空射击游戏” Android源代码作为示例,创建一个简单的纸牌游戏。

But there is the big problem that I don't know how to use CCSpriteFrame to create the sprite animation for the cards. 但是有一个很大的问题,我不知道如何使用CCSpriteFrame为卡创建精灵动画。 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). 因此,我在这里向代码示例询问有关如何使用Cocos2D Android(JAVA版本)创建精灵动画的代码示例。

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);
              } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM