Ios CCSprite:setTexture不';使用CCSpriteBatchNode渲染精灵时不工作

Ios CCSprite:setTexture不';使用CCSpriteBatchNode渲染精灵时不工作,ios,cocos2d-iphone,box2d,Ios,Cocos2d Iphone,Box2d,这是我收到的错误: *由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因是:“当使用CCSpriteBatchNode渲染精灵时,CCSprite:setTexture不工作” 当我尝试运行动画时 I hear something about CCSpriteBatchNode's being bad? 以下是我对动画的创作: _tokenAnimation = [[CCAnimation alloc] init]; int frameCo

这是我收到的错误:

*由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因是:“当使用CCSpriteBatchNode渲染精灵时,CCSprite:setTexture不工作”

当我尝试运行动画时

I hear something about CCSpriteBatchNode's being bad?
以下是我对动画的创作:

_tokenAnimation = [[CCAnimation alloc] init];
int frameCount = 12;
for (int i = 1; i <= frameCount; i++)
{
    CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Token Ball 000%d.png", i]];
    [_tokenAnimation addFrame:frame delay:0.1];
}
我听说CCSpriteBatchNode不好?如果是,我如何更改精灵表的读数

还有什么我做错了吗?

试试这个:

CCAnimation* animation;

NSMutableArray *animFrames = [NSMutableArray array]; 
CCSpriteFrameCache *cache = [CCSpriteFrameCache sharedSpriteFrameCache];

for(int i=0;i<=12;i++)
{
    CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Token Ball 000%d.png", i]]
    [animFrames addObject:frame];
}


animation = [CCAnimation animationWithSpriteFrames:animFrames];

animation.delayPerUnit =  0.1f;
animation.restoreOriginalFrame = NO;


CCAnimate *AnimAction  = [CCAnimate actionWithAnimation:animation];

CCRepeatForever *anim = [CCRepeatForever actionWithAction:AnimAction];

[creditPickup runAction:anim];
cAnimation*动画;
NSMutableArray*animFrames=[NSMutableArray];
CCSpriteFrameCache*cache=[CCSpriteFrameCache sharedSpriteFrameCache];

对于(int i=0;i,您的问题就在这里:

CCSprite:setTexture在使用 CCSpriteBatchNode'

这意味着,作为子级添加到CCSpriteBatchNode的任何CCSprite都不能运行setTexture方法。原因是它们都必须使用与其父CCSpriteBatchNode相同的纹理。因此,cocos2d在sprite批处理的sprite上禁用该方法

在您的情况下,很可能动画的至少一个精灵帧不在其子精灵播放该动画的CCSpriteBatchNode使用的纹理中

I hear something about CCSpriteBatchNode's being bad?

是的,很糟糕。太糟糕了,它会进行月球行走。:)

我在token:cAnimate*token=[cAnimate actionWithAnimation:_tokenAnimation]获得EXC_bad_访问权;CCRepeatForever*anim=[CCRepeatForever actionWithAction:token];不确定它是什么,我在预加载中初始化动画,然后在那里使用它。不知怎的,它会迷路吗?谢谢你,巴德;)读SpriteFrames的名字有问题,真的很愚蠢-哦,好吧!谢谢