[英]CCSpriteBatchNode is deprecated Cocos2d 3.1
我在按照cocos2d 3.1中的cocos2d 3.0教程进行操作时遇到问题...当编译完成时显示警告“ CCSpriteBatchNode已弃用”,我现在如何使用plist? 还是现在不在cocos2d 3.1中使用? 你能写一个例子,会很有帮助:)
@implementation GameScene
{
CCSpriteBatchNode *_batchNode; // WARNING 1 HERE
Hunter *_hunter;
Bird *_bird;
}
-(void)addBackground
{
//1
CGSize viewSize = [CCDirector sharedDirector].viewSize;
//2
CCSprite *background = [CCSprite spriteWithImageNamed:@"game_scene_bg.png"];
//3
background.position = ccp(viewSize.width * 0.5f, viewSize.height * 0.5f);
//4
[self addChild:background];
}
-(void)createBatchNode {
//1
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"Cocohunt.plist"];
//2
_batchNode = [CCSpriteBatchNode batchNodeWithFile:@"Cocohunt.png"]; // WARNING 2 HERE
//3
[self addChild:_batchNode z:1];
}
在3.1版中,重新制作了cocos2d渲染器以自动批处理绘制的精灵。 因此,不再需要CCSpriteBatchNode,只需使用CCNode。
@implementation GameScene
{
CCNode *_batchNode; // WARNING 1 HERE
Hunter *_hunter;
Bird *_bird;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.