开发者

CCAnimate with sprite file names?

开发者 https://www.devze.com 2023-04-07 04:33 出处:网络
CCAnimate requires CCSpriteFrames, while they require a texture2d. Is it not possible to simply use CCAnimate by providing my开发者_开发问答 file names? Like anim1.png, anim2.png, anim3.png...Not dir

CCAnimate requires CCSpriteFrames, while they require a texture2d.

Is it not possible to simply use CCAnimate by providing my开发者_开发问答 file names? Like anim1.png, anim2.png, anim3.png...


Not directly.

If you are on versions 0.99.*, you can load the files into UIImages, then create CCTexture2Ds using the initWithImage: function, then create CCSpriteFrames.

If you are on version 1.0.0 or later, you can load the textures from files using the CCTextureCache singleton, then create CCSpriteFrames.

However, the whole point behind this API is that you can place all the frames of your animation into one image file, load it as a texture, and then carve out the individual frames using the rect property/argument. This should also improve performance, since the graphics chip only has to load one texture and then perform cheap clipping operation instead of loading multiple textures.

EDIT: Cocos2D has a function for direct CCSpriteFrame loading since version 1.1.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号