1
我正在使用纹理包生成不同的动画图像集成。CCSpriteFrameCache在cocos2d中加载黑色图像?
我在我的代码中使用了.plist和.png文件,如下所示。有时它工作正常,但有时显示动画图像是黑色的。我也清除/重建我的项目并运行,但也有时会得到黑色动画图像。
TexturePacker产生的.plist和.png如下如下
代码。
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"sheetPng-ipadhd-hd.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"sheetPng-ipadhd-hd.png"];
[self addChild:spriteSheet];
/* Gather the list of frames(sprite) */
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for (int i=1; i<=3; i++) {
[walkAnimFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"M0%d.png",i]]];
}
CCAnimation *walkAnim = [CCAnimation animationWithSpriteFrames:walkAnimFrames delay:2.0f];
manSprite=[CCSprite spriteWithSpriteFrameName:@"M01.png"];
[self resizeSprite:manSprite toWidth:180 toHeight:250];
manSprite.position=ccp(375, 0);
id firstRepeat = [CCRepeat actionWithAction:[CCAnimate actionWithAnimation:walkAnim] times:3];
[manSprite runAction:firstRepeat];
[background addChild:manSprite];
// add the label as a child to this Layer
[self addChild: background];
OK做工精细。我有保存taht文件的箴言。 –