실패,이 늘지을 열심히 프로그램 crashed.And 엑스 코드 로그는 말했다 :에최적화 애니메이션
어설 션 실패 - [CCSpriteBatchNode하는 AddChild : Z : 태그 :]/사용자/hanpengbo/문서/엑스 코드/cocos2d_helloWorld/cocos2d_helloWorld/libs와/코코 S2D/CCSpriteBatchNode.m : CCSpriteBatchNode.m 183
: 183
NSAssert(child.texture.name == textureAtlas_.texture.name, @"CCSprite is not using the same texture id");
존재
여기
// cache
CCSpriteFrameCache *cache=[CCSpriteFrameCache sharedSpriteFrameCache];
[cache addSpriteFramesWithFile:@"birdAtlas.plist"];
// frame array
NSMutableArray *framesArray=[NSMutableArray array];
for (int i=1; i<10; i++) {
NSString *frameName=[NSString stringWithFormat:@"bird%d.png", i];
id frameObject=[cache spriteFrameByName:frameName];
[framesArray addObject:frameObject];
}
// animation object
id animObject=[CCAnimation animationWithFrames:framesArray delay:0.1];
// animation action
id animAction=[CCAnimate actionWithAnimation:animObject restoreOriginalFrame:NO];
animAction=[CCRepeatForever actionWithAction:animAction];
// sprite
cocosGuy = [CCSprite spriteWithFile: @"Icon.png"];//cocosGuy is CCSprite,declared earler
cocosGuy.position = ccp(200, 300);
// batchNode
CCSpriteBatchNode *batchNode=[CCSpriteBatchNode batchNodeWithFile:@"birdAtlas.png"];
[self addChild:batchNode];
[batchNode addChild:cocosGuy];
[cocosGuy runAction:animAction];
UPDATE 내 코드입니다 : 여기 가 수정 된 코드이며, 작동이 잘
// batchNode
CCSpriteBatchNode *batchNode=[CCSpriteBatchNode batchNodeWithFile:@"birdAtlas.png"];
[cocosGuy setTexture:[batchNode texture]];
[self addChild:batchNode];
[batchNode addChild:cocosGuy];
BatchNode에는 몇 가지 요구 사항이 있습니다. 충돌의 일반적인 원인은 다음과 같습니다. inited, 스레드에서 batchnode 호출 또는 batchnode 텍스처가 이미 재활용되었습니다. 귀하의 경우 인스턴스 변수로 어딘가에'batchNode'의 참조를 보관하고 싶을 수도 있습니다. 파괴시키지 마십시오. –
Xcode에서 전역 예외 브레이크 포인트를 사용하도록 설정하면 문제를 파악하는 데 도움이되는 충돌 줄이 표시됩니다 (실패한 Assert 줄을 복사하여 여기에 붙여 넣기). 가장 중요한 것은 모든 애니메이션 프레임이 birdAtlas.png에 있고 다른 텍스처 맵에 있는지 확인합니다. – LearnCocos2D
*** 어설 션 오류 - [CCSpriteBatchNode addChild : z : tag :], /Users/hanpengbo/Documents/Xcode/cocos2d_helloWorld/cocos2d_helloWorld/libs/cocos2d/CCSpriteBatchNode.m:183 –