Cocos2d iphone 需要帮助解决简单的cocos2d错误吗?
我正在使用以下代码:Cocos2d iphone 需要帮助解决简单的cocos2d错误吗?,cocos2d-iphone,Cocos2d Iphone,我正在使用以下代码: // Add the stuff from below! CCSprite* background = [CCSprite spriteWithFile:@"background-1.png"]; background.tag = 1; background.anchorPoint = CGPointMake(0, 0); [self addChild:background]; [[CCSpriteFrameCache s
// Add the stuff from below!
CCSprite* background = [CCSprite spriteWithFile:@"background-1.png"];
background.tag = 1;
background.anchorPoint = CGPointMake(0, 0);
[self addChild:background];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
@"wave1.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode
batchNodeWithFile:@"wave1.png"];
[self addChild:spriteSheet];
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 8; ++i) {
[walkAnimFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"wave-r-l-000%d.png", i]]];
//wave-r-l-0001
}
CCAnimation *walkAnim = [CCAnimation
animationWithFrames:walkAnimFrames delay:0.1f];
CGSize winSize = [CCDirector sharedDirector].winSize;
self.bear = [CCSprite spriteWithSpriteFrameName:@"bear1.png"];
_bear.position = ccp(winSize.width/2, winSize.height/2);
self.walkAction = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
[_bear runAction:_walkAction];
[spriteSheet addChild:_bear];
请帮忙我知道这个话题有点老了,但它可能会帮助一些人 错误来自以下行:
self.bear = [CCSprite spriteWithSpriteFrameName:@"bear1.png"];
TestBear[205:707]cocos2d:CCSpriteFrameCache:未找到帧'bear1.png'
这意味着CCSpriteFrameCache不包含名为“bear1.png”的sprime帧。这里只添加1个plist文件(“wave1.plist”),并且它不包含名为“bear1.png”的sprime帧。所以,请检查plist文件,并在必要时重新生成它
另一个常见错误是,如果您的精灵不在精灵表中,则使用“SpriteWithPriteFrameName:”而不是“spriteWithFile:”
我希望我能帮上忙。我知道这个话题有点老了,但它可能会帮助一些人 错误来自以下行:
self.bear = [CCSprite spriteWithSpriteFrameName:@"bear1.png"];
TestBear[205:707]cocos2d:CCSpriteFrameCache:未找到帧'bear1.png'
这意味着CCSpriteFrameCache不包含名为“bear1.png”的sprime帧。这里只添加1个plist文件(“wave1.plist”),并且它不包含名为“bear1.png”的sprime帧。所以,请检查plist文件,并在必要时重新生成它
另一个常见错误是,如果您的精灵不在精灵表中,则使用“SpriteWithPriteFrameName:”而不是“spriteWithFile:”
希望我能帮上忙。下面的链接将对您有所帮助-下面的链接将对您有所帮助-