0
此代碼運行良好,但有一些我不明白。發佈在cocos2d
難道
//Release
[_nextProjectile release];
_nextProjectile =nil;
這裏釋放和_player的動作後置_nextProjectile爲零? 如果是這樣,下一個塊如何釋放_nextProjectile?
_nextProjectile = [[CCSprite spriteWithFile:@"projectile2.png"] retain];
_nextProjectile.position = ccp(20, winSize.height/2);
...
[_player runAction:
[CCSequence actions:
[CCRotateTo actionWithDuration:rotateDuration angle:cocosAngle],
[CCCallBlockN actionWithBlock:^(CCNode *node) {
[self addChild:_nextProjectile];
[_projectiles addObject:_nextProjectile];
// Release
[_nextProjectile release];
_nextProjectile =nil;
}],
nil]];
// Move projectile to actual endpoint
[_nextProjectile runAction:
[CCSequence actions:
[CCMoveTo actionWithDuration:realMoveDuration position:realDest],
[CCCallBlockN actionWithBlock:^(CCNode *node) {
[_projectiles removeObject:node];
[node removeFromParentAndCleanup:YES];
}],
nil]];
CCSequence只執行一次。還張貼您的代碼_nextProjectile初始化 – Guru
謝謝,我添加了初始化。 – coolhongly
不用擔心,學會愛ARC炸彈;) – LearnCocos2D