我创建了一个类似下面的线程:
[NSThread detachNewThreadSelector:@selector(connectionFinishedThread) toTarget:self withObject:nil];
在这个方法中,我创建了一个精灵并为这个精灵提供了动画。动画不可见。
我在 Thread 方法中的代码:
CCSprite *aniSprite = [CCSprite spriteWithSpriteFrameName:@"r_anim01.png"];
aniSprite.position = ccp(50, 50);
[self addChild:aniSprite z:22];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"r_anim1.plist"];
CCSpriteBatchNode *animSheet = [CCSpriteBatchNode batchNodeWithFile:@"r_anim1.png"];
[self addChild:animSheet];
NSMutableArray *animFrames = [NSMutableArray array];
for (int i=1; i<=6; i++) {
[animFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"r_anim1%d.png",i]]];
}
CCAnimation *anim = [CCAnimation animationWithSpriteFrames:animFrames delay:0.1f];
CCAction *spriteAction = [CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:anim]];
[sprite runAction:spriteAction];
为什么它会这样?