2014-02-11 59 views
0

我想在我的Cocos2d項目中使用粒子效果。粒子效果顯示良好。但是當我把粒子顯示功能放到線程中時,我很困惑,它只顯示微小的黑色方塊而不是正確的紋理。 thanx提前。如何在Cocos2d中顯示粒子線程

// thread caller 
[self performSelectorInBackground:@selector(showParticleThrd:) withObject:nil]; 

// it works good when i call it directly 

-(void) showParticleThrd{ 
    CCParticleSystem * system = [[ParticleEffectSelfMade alloc] initWithTotalParticles:1]; 
    [aLayer removeChildByTag:R_TAG cleanup:YES]; 
    system.position = ccp(self.position.x,self.position.y); 
    [self.parent addChild:system z:R_ORDER tag:R_TAG]; 
    [system release]; 
} 
+0

PS:請開始使用ARC – LearnCocos2D

回答

2

你不能在後臺線程中修改任何與cocos2d相關的東西。 Cocos2d要求您對主線程中的節點進行更改,其中創建了OpenGL上下文。

+0

這很有幫助。我只是擔心主線承受了負擔。 Thanx無論如何。 – user3201493

+1

首先,分析。然後,優化。大多數iOS遊戲在扼殺CPU週期之前受限於有限的填充率。 – LearnCocos2D