1

これは私が受け取るエラーです:

*キャッチされない例外 'NSInternalInconsistencyException' が原因でアプリを終了します。

アニメーションを実行しようとしているとき。

これが私のアニメーションの作成です:

_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];
}

そして、ここで私はアニメーションを呼び出します-これを前に見たことがないのですか?

GameObject *creditPickup = [_creditPickups nextSprite];

    creditPickup.position = ccp(_creditPosition.x, _creditPosition.y);
    [creditPickup revive];

    [creditPickup runAction:[CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:_tokenAnimation restoreOriginalFrame:NO]]];
    [creditPickup runAction: [CCSequence actions:
                              [CCMoveBy actionWithDuration:5.0 position:ccp(-_winSize.width*1.5, 0)],
                              [CCCallFuncN actionWithTarget:self selector:@selector(invisNode:)], nil]];

CCSpriteBatchNode が悪いという話を聞いたことがありますか? もしそうなら、どうすればスプライトシートの読みを変更できますか??

私が間違っていることは他にありますか?

4

2 に答える 2

2

そこにあなたの問題があります:

CCSprite: CCSpriteBatchNode を使用してスプライトをレンダリングすると、setTexture が機能しない

つまり、CCSpriteBatchNode に子として追加された CCSprite はいずれも setTexture メソッドを実行できないということです。その理由は、それらすべてが親の CCSpriteBatchNode と同じテクスチャを使用する必要があるためです。そのため、cocos2d は、スプライト バッチ処理されたスプライトでそのメソッドを無効にします。

あなたの場合、アニメーションのスプライト フレームの少なくとも 1 つが、子スプライトがそのアニメーションを再生する CCSpriteBatchNode によって使用されるテクスチャにない可能性が最も高いです。

I hear something about CCSpriteBatchNode's being bad?

はい、それは悪いです。とても悪いことに、それはムーンウォークをします。:)

于 2012-09-12T21:05:46.030 に答える
0

これを試して:

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];
于 2012-09-12T16:08:28.230 に答える