我的粒子在模拟器中运行良好,但是当我使用设备(iPhone 4S - iOS 6.1)运行应用程序时,它看起来像一些奇怪的激光(见下图):
设备上的粒子: https ://dl.dropboxusercontent.com/u/58621241/IMG_2287.PNG
模拟器上的粒子: https ://dl.dropboxusercontent.com/u/58621241/Screen%20Shot%202013-06-20%20at%2018.10.15.png
这是我创建粒子系统的代码:
@implementation CCParticleMainDrill
-(id) init
{
return [self initWithTotalParticles:100];
}
-(id) initWithTotalParticles:(NSUInteger) p
{
if( (self=[super initWithTotalParticles:p]) ) {
// _duration
_duration = kCCParticleDurationInfinity;
// Gravity Mode
self.emitterMode = kCCParticleModeGravity;
// Gravity Mode: gravity
self.gravity = ccp(0,100);
// Gravity Mode: speed of particles
self.speed = 400;
self.speedVar = 230;
// Gravity Mode: radial
self.radialAccel = 0;
self.radialAccelVar = 0;
// Gravity Mode: tagential
self.tangentialAccel = 0;
self.tangentialAccelVar = 0;
ccBlendFunc ccbf = {GL_DST_COLOR,GL_DST_ALPHA};//{GL_SRC_ALPHA,GL_SRC_ALPHA_SATURATE};
self.blendFunc = ccbf;
// _angle
_angle = 90;
_angleVar = 60;
// emitter position
//CGSize winSize = [[CCDirector sharedDirector] winSize];
self.positionType = kCCPositionTypeFree;
self.position = ccp(0, 0);// ccp(winSize.width/2, winSize.height/2);
self.posVar = ccp(3, 0);
// _life of particles
_life = 0.06;
_lifeVar = 0.1;
// size, in pixels
_startSize = 5.0f;
_startSizeVar = 1.0f;
_endSize = 3.0f;
_endSizeVar = 0.00f;
// emits per second
_emissionRate = _totalParticles/_life;
// color of particles
_startColor.r = 0.25f;
_startColor.g = 0.14f;
_startColor.b = 0.07f;
_startColor.a = 1.0f;
_startColorVar.r = 0.0f;
_startColorVar.g = 0.0f;
_startColorVar.b = 0.0f;
_startColorVar.a = 0.0f;
_endColor.r = 0.28f;
_endColor.g = 0.19f;
_endColor.b = 0.12f;
_endColor.a = 0.30f;
_endColorVar.r = 0.0f;
_endColorVar.g = 0.0f;
_endColorVar.b = 0.0f;
_endColorVar.a = 0.0f;
self.texture = [[CCTextureCache sharedTextureCache] addImage: @"particle.png"];
// additive
self.blendAdditive = YES;
}
return self;
}
@end
当我将粒子添加到场景中时,这是一个:
Armor = [CCSprite spriteWithFile:@"player.png"];
Armor.position = ccp(16, 16);
[self addChild:Armor];
DrillParticles = [CCParticleMainDrill node];//[CCParticleSmoke node];
[DrillParticles setPosition:ccp(Armor.boundingBox.size.width/2, 0)];
[DrillParticles setTotalParticles:0];
[Armor addChild:DrillParticles z:INT_MAX];