Domanda

I'm running cocos2d with cocosbuilder 2.1 and I use the cocosbuilder animation delegate (CCBAnimationManagerDelegate::completedAnimationSequenceNamed) to get notified when an animation has completed and take actions like firing another cocosbuilder animation.

It runs fine the first time the foodfactoryshow animation is run from the delegate and after the animation is completed it also runs restoration animation correctly. However, when restoration animation is completed, the parameter name for -(void) completedAnimationSequenceNamed method is NULL!?

-(void) completedAnimationSequenceNamed:(NSString*)name
{
if ([name isEqualToString:@"foodfactoryshow"])
{
    [manager runAnimationsForSequenceNamed:@"restoration"];
}
if ([name isEqualToString:@"restoration"])
{
    [self colorLayerChanged];
    self.gameLayer.isLock = true;
}
}

Is this a bug or am I not supposed to run animations from the CCBAnimationManagerDelegate::completedAnimationSequenceNamed method!?

Thanks in advance for your help.

È stato utile?

Soluzione

I believe it is a CCBReader bug. There is an open issue about it in the CocosBuilder github page (https://github.com/cocos2d/CocosBuilder/issues/121). It should be fixed in the latest version of CocosBuilder + CCBReader, however, if you want to use the 2.1 version you can change the "sequenceCompleted" method of CCBAnimationManager to the following:

- (void) sequenceCompleted
{
    NSString *completedSequenceName = [runningSequence.name copy];
    int nextSeqId = runningSequence.chainedSequenceId;
    runningSequence = NULL;

    if (nextSeqId != -1)
    {
        [self runAnimationsForSequenceId:nextSeqId tweenDuration:0];
    }

    [delegate completedAnimationSequenceNamed:completedSequenceName];
    [completedSequenceName release];
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top