Cocos2d iphone 我们应该使用哪些API将精灵表和精灵添加到cocos2d游戏中?

Cocos2d iphone 我们应该使用哪些API将精灵表和精灵添加到cocos2d游戏中?,cocos2d-iphone,sprite-sheet,Cocos2d Iphone,Sprite Sheet,创建cocos2d iOS游戏时,有几个选项可以添加精灵表-CCTextureCache::addImageAsync、CCSpriteFrameCache::addSpriteFramesWithFile等-使用这些不同的方法添加精灵表之间有什么区别 类似地,要加载精灵,我们可以调用CCSprite::spritewithpriteframename或CCSprite::spriteWithFile或CCSpriteBatchNode::batchNodeWithTexture等。使用这些技术

创建cocos2d iOS游戏时,有几个选项可以添加精灵表-CCTextureCache::addImageAsync、CCSpriteFrameCache::addSpriteFramesWithFile等-使用这些不同的方法添加精灵表之间有什么区别

类似地,要加载精灵,我们可以调用CCSprite::spritewithpriteframename或CCSprite::spriteWithFile或CCSpriteBatchNode::batchNodeWithTexture等。使用这些技术的区别是什么

谢谢


A和加载精灵帧,这也会加载纹理:

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"file.plist"];
使用精灵框架:

CCSprite* sprite = [CCSprite spriteWithSpriteFrameName:@"frame.png"];
将精灵添加到批处理节点:

CCSpriteBatchNode* batchNode = [CCSpriteBatchNode batchNodeWithTexture:sprite.texture];
[batchNode addChild:sprite];
如果使用相同的精灵图像文件,batchNodeWithFile也可以工作。如果精灵是用spriteframe初始化的,它将是纹理图集图像(即“file.png”)

addImageAsync仅在您希望在另一个线程上加载纹理时才需要,通常用于设置加载屏幕的动画。之后仍然需要添加精灵帧

CCSprite spriteWithFile从单个图像文件创建精灵。这些也可以批量处理,但最好使用带有精灵框架的纹理图集