2

I'd like to run a callback/selector when a Cocos2d CCParticleExplosion is completely finished. How do I do this?

I tried using scheduleOnce with the same duration as the emitter, but that finish too soon since I guess the duration of the emitter controls for how long it will emit new particles, but not how long the complete animation lasts.

4

2 に答える 2

0

アクションで (CCSequence を使用して) アクションの順序付けを試みCCCAllFuncます。1 つのアクションが実行された後、別のアクションが実行され、CCCAllFunc を選択したセレクター/メソッドに割り当てることができます。

于 2012-04-21T10:07:49.363 に答える
0

これが受け入れられるかどうかはわかりませんが、テストして「私のMacで動作します」.

CCParticleSystem.h で

// experimental
typedef void (^onCompletedBlock)();
@property (readwrite, copy) onCompletedBlock onComplete;

CCParticleSystem.m で

@synthesize onComplete;

同じファイル更新メソッドで、

_particleCount--;

        if( _particleCount == 0 && self.onComplete)
        {
            [self onComplete]();
            [[self onComplete] release];
        }

if( _particleCount == 0 && _autoRemoveOnFinish ) {
            [self unscheduleUpdate];
            [_parent removeChild:self cleanup:YES];
            return;
}

あなたのコードで

particleSystem.autoRemoveOnFinish = YES;
particleSystem.position = ccp(screenSize.width/2, screenSize.height/4);
particleSystem.onComplete = ^
{
    NSLog(@"completed ..");
};

繰り返しますが、かなり実験的です..

于 2013-06-20T03:43:07.393 に答える