我正在尝试制作我的第一个iOS游戏,我需要批量渲染背景图块。我正在使用cocos2d 3,但我发现的每个精灵绘图示例都使用spriteWithSpriteFrameName
,这不再是一个选项。
我正在成功加载精灵表/ plist:
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"backgrounds.plist"];
CCSpriteBatchNode spriteBatch = [CCSpriteBatchNode batchNodeWithFile:@"backgrounds.png"];
但我无法弄清楚如何正确获取spritesheet的特定部分。 spriteWithSpriteFrameName
不再是CCSprite
CCSprite* tile = [CCSprite spriteWithSpriteFrameName:@"dirt.png"];
答案 0 :(得分:2)
在cocos2d v3.0中你必须制作精灵帧,而不是使用准备好的精灵帧制作CCSprite:
CCSpriteFrame* sampleFrame = [CCSpriteFrame frameWithImageNamed:@"dirt.png" ];
CCSprite* title = [CCSprite spriteWithSpriteFrame:sampleFrame];
希望有所帮助:)
答案 1 :(得分:-1)
这是怎么做的:
CCSprite* spriteFile = [CCSprite spriteWithImageNamed:@"file.png"];