很抱歉,这听起来很简单。我使用Texture Packer从Ray Wenderlich的网站上关注making spritesheets的教程。代码似乎运行没有错误,但没有显示精灵。这是一个示例:
-(id)initWithGameLayer: (HelloWorldLayer *)thelayer{
if (self = [super init]) {
//winSize = [CCDirector sharedDirector].winSize;
gameLayer = thelayer;
hasSwitched = YES;
transitionArray = [[NSMutableArray alloc] init];
backgroundBatchNode = [CCSpriteBatchNode batchNodeWithFile:@"testbg.png"];
[self addChild:backgroundBatchNode];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"testbg.plist"];
bg1 = [CCSprite spriteWithSpriteFrameName:@"background01.png"];
bg1.position = ccp(WIDTH/2,HEIGHT/2);
[backgroundBatchNode addChild:bg1 z:0 tag:2];
bg2 = [CCSprite spriteWithSpriteFrameName:@"background02.png"];
bg2.position = ccp(WIDTH/2,HEIGHT/2 + HEIGHT);
[backgroundBatchNode addChild: bg2 z:0 tag:3];
}
return self;
}