public CCParticleMeteor(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(150, emitterMode) { Duration = ParticleDurationInfinity; Life = 2; LifeVar = 1; Position = position; PositionVar = CCPoint.Zero; Angle = 90; AngleVar = 360; StartSize = 60.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.2f, 0.4f, 0.7f, 1.0f); StartColorVar = new CCColor4F(0.0f, 0.0f, 0.2f, 0.1f); EndColor = new CCColor4F(0.0f, 0.0f, 0.0f, 1.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(-200, 200); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 15; gravityMode.SpeedVar = 5; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 0; GravityMode = gravityMode; BlendAdditive = true; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSun(CCPoint position, int num, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(num, emitterMode) { Duration = ParticleDurationInfinity; Life = 1; LifeVar = 0.5f; Position = position; PositionVar = CCPoint.Zero; Angle = 90; AngleVar = 360; StartSize = 30.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.76f, 0.25f, 0.12f, 1.0f); StartColorVar = new CCColor4F(); EndColor = new CCColor4F(0.0f, 0.0f, 0.0f, 1.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 20; gravityMode.SpeedVar = 5; GravityMode = gravityMode; BlendAdditive = true; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSpiral(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(500, emitterMode) { Duration = ParticleDurationInfinity; Position = position; PositionVar = CCPoint.Zero; Life = 12; LifeVar = 0; Angle = 90; AngleVar = 0; StartSize = 20.0f; StartSizeVar = 0.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); StartColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); EndColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); EndColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = -380; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 150; gravityMode.SpeedVar = 0; gravityMode.TangentialAccel = 45; gravityMode.TangentialAccelVar = 0; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleExplosion(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(700, emitterMode) { Duration = 0.1f; Life = 5.0f; LifeVar = 2; Position = new CCPoint(position); PositionVar = CCPoint.Zero; Angle = 90; AngleVar = 360; StartSize = 15.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Duration; StartColor = new CCColor4F(0.7f, 0.1f, 0.2f, 1.0f); StartColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); EndColor = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); EndColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 70; gravityMode.SpeedVar = 40; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 0; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSmoke(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(200, emitterMode) { Duration = ParticleDurationInfinity; Life = 4; LifeVar = 1; Position = position; PositionVar = new CCPoint(20, 0); Angle = 90; AngleVar = 5; StartSize = 60.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.8f, 0.8f, 0.8f, 1.0f); StartColorVar = new CCColor4F(0.02f, 0.02f, 0.02f, 0.0f); EndColor = new CCColor4F(0.0f, 0.0f, 0.0f, 1.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 25; gravityMode.SpeedVar = 10; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleRain(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(1000, emitterMode) { Duration = ParticleDurationInfinity; Position = position; PositionVar = new CCPoint(position.X, 0); Life = 4.5f; LifeVar = 0; Angle = -90; AngleVar = 5; StartSize = 4.0f; StartSizeVar = 2.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = 20; StartColor = new CCColor4F(0.7f, 0.8f, 1.0f, 1.0f); StartColorVar = new CCColor4F(); EndColor = new CCColor4F(0.7f, 0.8f, 1.0f, 0.5f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(10, -10); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 1; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 1; gravityMode.Speed = 130; gravityMode.SpeedVar = 30; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSnow(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(700, emitterMode) { Duration = ParticleDurationInfinity; Life = 45; LifeVar = 15; Position = position; PositionVar = new CCPoint(position.X, 0); Angle = -90; AngleVar = 5; StartSize = 10.0f; StartSizeVar = 5.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = 10; StartColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f); StartColorVar = new CCColor4F(); EndColor = new CCColor4F(1.0f, 1.0f, 1.0f, 0.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, -1); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 1; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 1; gravityMode.Speed = 5; gravityMode.SpeedVar = 1; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleFireworks(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(1500, emitterMode) { Duration = ParticleDurationInfinity; Life = 3.5f; LifeVar = 1; Position = position; Angle = 90; AngleVar = 20; StartSize = 8.0f; StartSizeVar = 2.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); CCColor4F startColorVar = new CCColor4F(); startColorVar.R = 0.5f; startColorVar.G = 0.5f; startColorVar.B = 0.5f; startColorVar.A = 0.1f; StartColorVar = startColorVar; CCColor4F endColor = new CCColor4F(); endColor.R = 0.1f; endColor.G = 0.1f; endColor.B = 0.1f; endColor.A = 0.2f; EndColor = endColor; CCColor4F endColorVar = new CCColor4F(); endColorVar.R = 0.1f; endColorVar.G = 0.1f; endColorVar.B = 0.1f; endColorVar.A = 0.2f; EndColorVar = endColorVar; GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, -90); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 180; gravityMode.SpeedVar = 50; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public virtual bool InitWithTotalParticles(int numberOfParticles) { m_uTotalParticles = numberOfParticles; m_pParticles = new CCParticle[m_uTotalParticles]; m_uAllocatedParticles = numberOfParticles; if (m_pBatchNode != null) { for (int i = 0; i < m_uTotalParticles; i++) { m_pParticles[i].atlasIndex = i; } } // default, active m_bIsActive = true; // default blend function m_tBlendFunc.Source = CCMacros.CCDefaultSourceBlending; m_tBlendFunc.Destination = CCMacros.CCDefaultDestinationBlending; // default movement type; m_ePositionType = CCPositionType.kCCPositionTypeFree; // by default be in mode A: m_nEmitterMode = CCEmitterMode.kCCParticleModeGravity; // default: modulate // XXX: not used // colorModulate = YES; m_bIsAutoRemoveOnFinish = false; // Optimization: compile udpateParticle method //updateParticleSel = @selector(updateQuadWithParticle:newPosition:); //updateParticleImp = (CC_UPDATE_PARTICLE_IMP) [self methodForSelector:updateParticleSel]; //for batchNode m_bTransformSystemDirty = false; return(true); }
CCParticleSystem(int numberOfParticles, bool shouldAllocParticles, CCEmitterMode emitterMode = CCEmitterMode.Gravity) { TotalParticles = numberOfParticles; AllocatedParticles = numberOfParticles; PositionType = CCPositionType.Free; EmitterMode = emitterMode; IsActive = true; AutoRemoveOnFinish = false; if (shouldAllocParticles) { if (emitterMode == CCEmitterMode.Gravity) { GravityParticles = new CCParticleGravity[numberOfParticles]; } else { RadialParticles = new CCParticleRadial[numberOfParticles]; } } }
public CCParticleMeteor(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(150, emitterMode) { Duration = ParticleDurationInfinity; Life = 2; LifeVar = 1; Position = position; PositionVar = CCPoint.Zero; Angle = 90; AngleVar = 360; StartSize = 60.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.2f, 0.4f, 0.7f, 1.0f); StartColorVar = new CCColor4F(0.0f, 0.0f, 0.2f, 0.1f); EndColor = new CCColor4F(0.0f, 0.0f, 0.0f, 1.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(-200, 200); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 15; gravityMode.SpeedVar = 5; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 0; GravityMode = gravityMode; BlendAdditive = true; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSpiral(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(500, emitterMode) { Duration = ParticleDurationInfinity; Position = position; PositionVar = CCPoint.Zero; Life = 12; LifeVar = 0; Angle = 90; AngleVar = 0; StartSize = 20.0f; StartSizeVar = 0.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); StartColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); EndColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); EndColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = -380; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 150; gravityMode.SpeedVar = 0; gravityMode.TangentialAccel = 45; gravityMode.TangentialAccelVar = 0; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleExplosion(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(700, emitterMode) { Duration = 0.1f; Life = 2.0f; LifeVar = 2; Position = new CCPoint(position); PositionVar = CCPoint.Zero; Angle = 90; AngleVar = 360; StartSize = 15.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Duration; StartColor = new CCColor4F(0.7f, 0.1f, 0.2f, 1.0f); StartColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); EndColor = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); EndColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 0.0f); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 70; gravityMode.SpeedVar = 40; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 0; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSmoke(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(200, emitterMode) { Duration = ParticleDurationInfinity; Life = 4; LifeVar = 1; Position = position; PositionVar = new CCPoint(20, 0); Angle = 90; AngleVar = 5; StartSize = 60.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.8f, 0.8f, 0.8f, 1.0f); StartColorVar = new CCColor4F(0.02f, 0.02f, 0.02f, 0.0f); EndColor = new CCColor4F(0.0f, 0.0f, 0.0f, 1.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 25; gravityMode.SpeedVar = 10; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSun(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : this(position, 350, emitterMode) { }
public CCParticleSnow(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(700, emitterMode) { Duration = ParticleDurationInfinity; Life = 45; LifeVar = 15; Position = position; PositionVar = new CCPoint(position.X, 0); Angle = -90; AngleVar = 5; StartSize = 10.0f; StartSizeVar = 5.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = 10; StartColor = new CCColor4F(1.0f, 1.0f, 1.0f, 1.0f); StartColorVar = new CCColor4F(); EndColor = new CCColor4F(1.0f, 1.0f, 1.0f, 0.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, -1); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 1; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 1; gravityMode.Speed = 5; gravityMode.SpeedVar = 1; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSystemQuad(int numberOfParticles, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(numberOfParticles, emitterMode) { }
protected CCParticleSystem(int numberOfParticles, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : this(numberOfParticles, true, emitterMode) { }
public CCParticleSystemQuad(int numberOfParticles = 0, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(numberOfParticles, emitterMode) { InitRenderCommand(); }
public CCParticleSun(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : this(position, 350, emitterMode) { }
public bool InitWithDictionary(PlistDictionary dictionary) { bool bRet = false; do { int maxParticles = dictionary["maxParticles"].AsInt; // self, not super if (InitWithTotalParticles(maxParticles)) { // angle m_fAngle = dictionary["angle"].AsFloat; m_fAngleVar = dictionary["angleVariance"].AsFloat; // duration m_fDuration = dictionary["duration"].AsFloat; // blend function m_tBlendFunc.Source = dictionary["blendFuncSource"].AsInt; m_tBlendFunc.Destination = dictionary["blendFuncDestination"].AsInt; // color m_tStartColor.R = dictionary["startColorRed"].AsFloat; m_tStartColor.G = dictionary["startColorGreen"].AsFloat; m_tStartColor.B = dictionary["startColorBlue"].AsFloat; m_tStartColor.A = dictionary["startColorAlpha"].AsFloat; m_tStartColorVar.R = dictionary["startColorVarianceRed"].AsFloat; m_tStartColorVar.G = dictionary["startColorVarianceGreen"].AsFloat; m_tStartColorVar.B = dictionary["startColorVarianceBlue"].AsFloat; m_tStartColorVar.A = dictionary["startColorVarianceAlpha"].AsFloat; m_tEndColor.R = dictionary["finishColorRed"].AsFloat; m_tEndColor.G = dictionary["finishColorGreen"].AsFloat; m_tEndColor.B = dictionary["finishColorBlue"].AsFloat; m_tEndColor.A = dictionary["finishColorAlpha"].AsFloat; m_tEndColorVar.R = dictionary["finishColorVarianceRed"].AsFloat; m_tEndColorVar.G = dictionary["finishColorVarianceGreen"].AsFloat; m_tEndColorVar.B = dictionary["finishColorVarianceBlue"].AsFloat; m_tEndColorVar.A = dictionary["finishColorVarianceAlpha"].AsFloat; // particle size m_fStartSize = dictionary["startParticleSize"].AsFloat; m_fStartSizeVar = dictionary["startParticleSizeVariance"].AsFloat; m_fEndSize = dictionary["finishParticleSize"].AsFloat; m_fEndSizeVar = dictionary["finishParticleSizeVariance"].AsFloat; // position float x = dictionary["sourcePositionx"].AsFloat; float y = dictionary["sourcePositiony"].AsFloat; Position = new CCPoint(x, y); m_tPosVar.X = dictionary["sourcePositionVariancex"].AsFloat; m_tPosVar.Y = dictionary["sourcePositionVariancey"].AsFloat; // Spinning m_fStartSpin = dictionary["rotationStart"].AsFloat; m_fStartSpinVar = dictionary["rotationStartVariance"].AsFloat; m_fEndSpin = dictionary["rotationEnd"].AsFloat; m_fEndSpinVar = dictionary["rotationEndVariance"].AsFloat; m_nEmitterMode = (CCEmitterMode)dictionary["emitterType"].AsInt; // Mode A: Gravity + tangential accel + radial accel if (m_nEmitterMode == CCEmitterMode.kCCParticleModeGravity) { // gravity modeA.gravity.X = dictionary["gravityx"].AsFloat; modeA.gravity.Y = dictionary["gravityy"].AsFloat; // speed modeA.speed = dictionary["speed"].AsFloat; modeA.speedVar = dictionary["speedVariance"].AsFloat; // radial acceleration modeA.radialAccel = dictionary["radialAcceleration"].AsFloat; modeA.radialAccelVar = dictionary["radialAccelVariance"].AsFloat; // tangential acceleration modeA.tangentialAccel = dictionary["tangentialAcceleration"].AsFloat; modeA.tangentialAccelVar = dictionary["tangentialAccelVariance"].AsFloat; } // or Mode B: radius movement else if (m_nEmitterMode == CCEmitterMode.kCCParticleModeRadius) { modeB.startRadius = dictionary["maxRadius"].AsFloat; modeB.startRadiusVar = dictionary["maxRadiusVariance"].AsFloat; modeB.endRadius = dictionary["minRadius"].AsFloat; modeB.endRadiusVar = 0.0f; modeB.rotatePerSecond = dictionary["rotatePerSecond"].AsFloat; modeB.rotatePerSecondVar = dictionary["rotatePerSecondVariance"].AsFloat; } else { Debug.Assert(false, "Invalid emitterType in config file"); break; } // life span m_fLife = dictionary["particleLifespan"].AsFloat; m_fLifeVar = dictionary["particleLifespanVariance"].AsFloat; // emission Rate m_fEmissionRate = m_uTotalParticles / m_fLife; //don't get the internal texture if a batchNode is used if (m_pBatchNode == null) { // Set a compatible default for the alpha transfer m_bOpacityModifyRGB = false; // texture // Try to get the texture from the cache string textureName = dictionary["textureFileName"].AsString; string fullpath = CCFileUtils.FullPathFromRelativeFile(textureName, m_sPlistFile); CCTexture2D tex = null; if (!string.IsNullOrEmpty(textureName)) { // set not pop-up message box when load image failed bool bNotify = CCFileUtils.IsPopupNotify; CCFileUtils.IsPopupNotify = false; try { tex = CCTextureCache.SharedTextureCache.AddImage(fullpath); } catch (Exception) { tex = null; } // reset the value of UIImage notify CCFileUtils.IsPopupNotify = bNotify; } if (tex != null) { Texture = tex; } else { string textureData = dictionary["textureImageData"].AsString; Debug.Assert(textureData != null && textureData.Length > 0, string.Format("CCParticleSystem: textureData does not exist : {0}", textureName)); int dataLen = textureData.Length; if (dataLen != 0) { var dataBytes = Convert.FromBase64String(textureData); Debug.Assert(dataBytes != null, string.Format("CCParticleSystem: error decoding textureImageData : {0}", textureName)); var imageBytes = Inflate(dataBytes); Debug.Assert(imageBytes != null, string.Format("CCParticleSystem: error init image with Data for texture : {0}", textureName)); using (var imageStream = new MemoryStream(imageBytes)) { try { Texture = CCTextureCache.SharedTextureCache.AddImage(imageStream, textureName); } catch (Exception ex) { CCLog.Log(ex.ToString()); throw (new NotSupportedException("Embedded textureImageData is a format that this platform does not understand. Use PNG, GIF, or JPEG for your particle systems.")); } } } } Debug.Assert(Texture != null, string.Format("CCParticleSystem: error loading the texture : {0}", textureName)); } bRet = true; } } while (false); return(bRet); }
public CCParticleRain(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(1000, emitterMode) { Duration = ParticleDurationInfinity; Position = position; PositionVar = new CCPoint(position.X, 0); Life = 4.5f; LifeVar = 0; Angle = -90; AngleVar = 5; StartSize = 4.0f; StartSizeVar = 2.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = 20; StartColor = new CCColor4F(0.7f, 0.8f, 1.0f, 1.0f); StartColorVar = new CCColor4F(); EndColor = new CCColor4F(0.7f, 0.8f, 1.0f, 0.5f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(10, -10); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 1; gravityMode.TangentialAccel = 0; gravityMode.TangentialAccelVar = 1; gravityMode.Speed = 130; gravityMode.SpeedVar = 30; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }
public bool InitWithDictionary(PlistDictionary dictionary) { bool bRet = false; do { int maxParticles = dictionary["maxParticles"].AsInt; // self, not super if (InitWithTotalParticles(maxParticles)) { // angle m_fAngle = dictionary["angle"].AsFloat; m_fAngleVar = dictionary["angleVariance"].AsFloat; // duration m_fDuration = dictionary["duration"].AsFloat; // blend function m_tBlendFunc.Source = dictionary["blendFuncSource"].AsInt; m_tBlendFunc.Destination = dictionary["blendFuncDestination"].AsInt; // color m_tStartColor.R = dictionary["startColorRed"].AsFloat; m_tStartColor.G = dictionary["startColorGreen"].AsFloat; m_tStartColor.B = dictionary["startColorBlue"].AsFloat; m_tStartColor.A = dictionary["startColorAlpha"].AsFloat; m_tStartColorVar.R = dictionary["startColorVarianceRed"].AsFloat; m_tStartColorVar.G = dictionary["startColorVarianceGreen"].AsFloat; m_tStartColorVar.B = dictionary["startColorVarianceBlue"].AsFloat; m_tStartColorVar.A = dictionary["startColorVarianceAlpha"].AsFloat; m_tEndColor.R = dictionary["finishColorRed"].AsFloat; m_tEndColor.G = dictionary["finishColorGreen"].AsFloat; m_tEndColor.B = dictionary["finishColorBlue"].AsFloat; m_tEndColor.A = dictionary["finishColorAlpha"].AsFloat; m_tEndColorVar.R = dictionary["finishColorVarianceRed"].AsFloat; m_tEndColorVar.G = dictionary["finishColorVarianceGreen"].AsFloat; m_tEndColorVar.B = dictionary["finishColorVarianceBlue"].AsFloat; m_tEndColorVar.A = dictionary["finishColorVarianceAlpha"].AsFloat; // particle size m_fStartSize = dictionary["startParticleSize"].AsFloat; m_fStartSizeVar = dictionary["startParticleSizeVariance"].AsFloat; m_fEndSize = dictionary["finishParticleSize"].AsFloat; m_fEndSizeVar = dictionary["finishParticleSizeVariance"].AsFloat; // position float x = dictionary["sourcePositionx"].AsFloat; float y = dictionary["sourcePositiony"].AsFloat; Position = new CCPoint(x, y); m_tPosVar.X = dictionary["sourcePositionVariancex"].AsFloat; m_tPosVar.Y = dictionary["sourcePositionVariancey"].AsFloat; // Spinning m_fStartSpin = dictionary["rotationStart"].AsFloat; m_fStartSpinVar = dictionary["rotationStartVariance"].AsFloat; m_fEndSpin = dictionary["rotationEnd"].AsFloat; m_fEndSpinVar = dictionary["rotationEndVariance"].AsFloat; m_nEmitterMode = (CCEmitterMode) dictionary["emitterType"].AsInt; // Mode A: Gravity + tangential accel + radial accel if (m_nEmitterMode == CCEmitterMode.kCCParticleModeGravity) { // gravity modeA.gravity.X = dictionary["gravityx"].AsFloat; modeA.gravity.Y = dictionary["gravityy"].AsFloat; // speed modeA.speed = dictionary["speed"].AsFloat; modeA.speedVar = dictionary["speedVariance"].AsFloat; // radial acceleration modeA.radialAccel = dictionary["radialAcceleration"].AsFloat; modeA.radialAccelVar = dictionary["radialAccelVariance"].AsFloat; // tangential acceleration modeA.tangentialAccel = dictionary["tangentialAcceleration"].AsFloat; modeA.tangentialAccelVar = dictionary["tangentialAccelVariance"].AsFloat; } // or Mode B: radius movement else if (m_nEmitterMode == CCEmitterMode.kCCParticleModeRadius) { modeB.startRadius = dictionary["maxRadius"].AsFloat; modeB.startRadiusVar = dictionary["maxRadiusVariance"].AsFloat; modeB.endRadius = dictionary["minRadius"].AsFloat; modeB.endRadiusVar = 0.0f; modeB.rotatePerSecond = dictionary["rotatePerSecond"].AsFloat; modeB.rotatePerSecondVar = dictionary["rotatePerSecondVariance"].AsFloat; } else { Debug.Assert(false, "Invalid emitterType in config file"); break; } // life span m_fLife = dictionary["particleLifespan"].AsFloat; m_fLifeVar = dictionary["particleLifespanVariance"].AsFloat; // emission Rate m_fEmissionRate = m_uTotalParticles / m_fLife; //don't get the internal texture if a batchNode is used if (m_pBatchNode == null) { // Set a compatible default for the alpha transfer m_bOpacityModifyRGB = false; // texture // Try to get the texture from the cache string textureName = dictionary["textureFileName"].AsString; string fullpath = CCFileUtils.FullPathFromRelativeFile(textureName, m_sPlistFile); CCTexture2D tex = null; if (!string.IsNullOrEmpty(textureName)) { // set not pop-up message box when load image failed bool bNotify = CCFileUtils.IsPopupNotify; CCFileUtils.IsPopupNotify = false; try { tex = CCTextureCache.SharedTextureCache.AddImage(fullpath); } catch (Exception) { tex = null; } // reset the value of UIImage notify CCFileUtils.IsPopupNotify = bNotify; } if (tex != null) { Texture = tex; } else { string textureData = dictionary["textureImageData"].AsString; Debug.Assert(textureData != null && textureData.Length > 0, string.Format("CCParticleSystem: textureData does not exist : {0}",textureName)); int dataLen = textureData.Length; if (dataLen != 0) { var dataBytes = Convert.FromBase64String(textureData); Debug.Assert(dataBytes != null, string.Format("CCParticleSystem: error decoding textureImageData : {0}",textureName)); var imageBytes = Inflate(dataBytes); Debug.Assert(imageBytes != null, string.Format("CCParticleSystem: error init image with Data for texture : {0}",textureName)); using (var imageStream = new MemoryStream(imageBytes)) { try { Texture = CCTextureCache.SharedTextureCache.AddImage(imageStream, textureName); } catch (Exception ex) { CCLog.Log(ex.ToString()); throw (new NotSupportedException("Embedded textureImageData is a format that this platform does not understand. Use PNG, GIF, or JPEG for your particle systems.")); } } } } Debug.Assert(Texture != null, string.Format("CCParticleSystem: error loading the texture : {0}", textureName)); } bRet = true; } } while (false); return bRet; }
public CCParticleGalaxy(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(200, emitterMode) { Duration = ParticleDurationInfinity; Life = 4; LifeVar = 1; Position = position; PositionVar = CCPoint.Zero; Angle = 90; AngleVar = 360; StartSize = 37.0f; StartSizeVar = 10.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F(0.12f, 0.25f, 0.76f, 1.0f); StartColorVar = new CCColor4F(); EndColor = new CCColor4F(0.0f, 0.0f, 0.0f, 1.0f); EndColorVar = new CCColor4F(); GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(0, 0); gravityMode.RadialAccel = -80; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 60; gravityMode.SpeedVar = 10; gravityMode.TangentialAccel = 80; gravityMode.TangentialAccelVar = 0; GravityMode = gravityMode; // additive BlendAdditive = true; Texture = CCParticleExample.DefaultTexture; }
public CCParticleSystemQuad(int numberOfParticles, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(numberOfParticles, emitterMode) { }
public virtual bool InitWithTotalParticles(int numberOfParticles) { m_uTotalParticles = numberOfParticles; m_pParticles = new CCParticle[m_uTotalParticles]; m_uAllocatedParticles = numberOfParticles; if (m_pBatchNode != null) { for (int i = 0; i < m_uTotalParticles; i++) { m_pParticles[i].atlasIndex = i; } } // default, active m_bIsActive = true; // default blend function m_tBlendFunc.Source = CCMacros.CCDefaultSourceBlending; m_tBlendFunc.Destination = CCMacros.CCDefaultDestinationBlending; // default movement type; m_ePositionType = CCPositionType.kCCPositionTypeFree; // by default be in mode A: m_nEmitterMode = CCEmitterMode.kCCParticleModeGravity; // default: modulate // XXX: not used // colorModulate = YES; m_bIsAutoRemoveOnFinish = false; // Optimization: compile udpateParticle method //updateParticleSel = @selector(updateQuadWithParticle:newPosition:); //updateParticleImp = (CC_UPDATE_PARTICLE_IMP) [self methodForSelector:updateParticleSel]; //for batchNode m_bTransformSystemDirty = false; return true; }
public CCParticleFire(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(250, emitterMode) { if (config == null) { config = new CCParticleSystemConfig (); config.ParticleSystemType = CCParticleSystemType.Internal; config.Duration = ParticleDurationInfinity; config.Life = 3; config.LifeVar = 0.25f; config.Position = position; config.PositionVar = new CCPoint(40, 20); config.Angle = 90; config.AngleVar = 10; config.StartSize = 54.0f; config.StartSizeVar = 10.0f; config.EndSize = ParticleStartSizeEqualToEndSize; config.EmitterMode = CCEmitterMode.Gravity; CCColor4F cstartColor = new CCColor4F(); cstartColor.R = 0.76f; cstartColor.G = 0.25f; cstartColor.B = 0.12f; cstartColor.A = 1.0f; config.StartColor = cstartColor; CCColor4F cstartColorVar = new CCColor4F(); cstartColorVar.R = 0.0f; cstartColorVar.G = 0.0f; cstartColorVar.B = 0.0f; cstartColorVar.A = 0.0f; config.StartColorVar = cstartColorVar; CCColor4F cendColor = new CCColor4F(); cendColor.R = 0.0f; cendColor.G = 0.0f; cendColor.B = 0.0f; cendColor.A = 1.0f; config.EndColor = cendColor; CCColor4F cendColorVar = new CCColor4F(); cendColorVar.R = 0.0f; cendColorVar.G = 0.0f; cendColorVar.B = 0.0f; cendColorVar.A = 0.0f; config.EndColorVar = cendColorVar; config.Gravity = new CCPoint(0, 0); config.GravityRadialAccel = 0; config.GravityRadialAccelVar = 0; config.GravitySpeed = 60; config.GravitySpeedVar = 20; config.Texture = CCParticleExample.DefaultTexture; } Duration = config.Duration; Life = config.Life; LifeVar = config.LifeVar; Position = config.Position; PositionVar = config.PositionVar; Angle = config.Angle; AngleVar = config.AngleVar; StartSize = config.StartSize; StartSizeVar = config.StartSizeVar; EndSize = config.EndSize; EmissionRate = TotalParticles / Life; CCColor4F startColor = new CCColor4F(); startColor.R = config.StartColor.R; startColor.G = config.StartColor.G; startColor.B = config.StartColor.B; startColor.A = config.StartColor.A; StartColor = startColor; CCColor4F startColorVar = new CCColor4F(); startColorVar.R = config.StartColorVar.R; startColorVar.G = config.StartColorVar.G; startColorVar.B = config.StartColorVar.B; startColorVar.A = config.StartColorVar.A; StartColorVar = startColorVar; CCColor4F endColor = new CCColor4F(); endColor.R = config.EndColor.R; endColor.G = config.EndColor.G; endColor.B = config.EndColor.B; endColor.A = config.EndColor.A; EndColor = endColor; CCColor4F endColorVar = new CCColor4F(); endColorVar.R = config.EndColorVar.R; endColorVar.G = config.EndColorVar.G; endColorVar.B = config.EndColorVar.B; endColorVar.A = config.EndColorVar.A; EndColorVar = endColorVar; GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(config.Gravity); gravityMode.RadialAccel = config.GravityRadialAccel; gravityMode.RadialAccelVar = config.GravityRadialAccelVar; gravityMode.Speed = config.GravitySpeed; gravityMode.SpeedVar = config.GravitySpeedVar; GravityMode = gravityMode; BlendAdditive = true; Texture = config.Texture; }
public CCParticleFire(CCPoint position, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : base(250, emitterMode) { if (config == null) { config = new CCParticleSystemConfig(); config.ParticleSystemType = CCParticleSystemType.Internal; config.Duration = ParticleDurationInfinity; config.Life = 3; config.LifeVar = 0.25f; config.Position = position; config.PositionVar = new CCPoint(40, 20); config.Angle = 90; config.AngleVar = 10; config.StartSize = 54.0f; config.StartSizeVar = 10.0f; config.EndSize = ParticleStartSizeEqualToEndSize; config.EmitterMode = CCEmitterMode.Gravity; CCColor4F cstartColor = new CCColor4F(); cstartColor.R = 0.76f; cstartColor.G = 0.25f; cstartColor.B = 0.12f; cstartColor.A = 1.0f; config.StartColor = cstartColor; CCColor4F cstartColorVar = new CCColor4F(); cstartColorVar.R = 0.0f; cstartColorVar.G = 0.0f; cstartColorVar.B = 0.0f; cstartColorVar.A = 0.0f; config.StartColorVar = cstartColorVar; CCColor4F cendColor = new CCColor4F(); cendColor.R = 0.0f; cendColor.G = 0.0f; cendColor.B = 0.0f; cendColor.A = 1.0f; config.EndColor = cendColor; CCColor4F cendColorVar = new CCColor4F(); cendColorVar.R = 0.0f; cendColorVar.G = 0.0f; cendColorVar.B = 0.0f; cendColorVar.A = 0.0f; config.EndColorVar = cendColorVar; config.Gravity = new CCPoint(0, 0); config.GravityRadialAccel = 0; config.GravityRadialAccelVar = 0; config.GravitySpeed = 60; config.GravitySpeedVar = 20; config.Texture = CCParticleExample.DefaultTexture; } Duration = config.Duration; Life = config.Life; LifeVar = config.LifeVar; Position = config.Position; PositionVar = config.PositionVar; Angle = config.Angle; AngleVar = config.AngleVar; StartSize = config.StartSize; StartSizeVar = config.StartSizeVar; EndSize = config.EndSize; EmissionRate = TotalParticles / Life; CCColor4F startColor = new CCColor4F(); startColor.R = config.StartColor.R; startColor.G = config.StartColor.G; startColor.B = config.StartColor.B; startColor.A = config.StartColor.A; StartColor = startColor; CCColor4F startColorVar = new CCColor4F(); startColorVar.R = config.StartColorVar.R; startColorVar.G = config.StartColorVar.G; startColorVar.B = config.StartColorVar.B; startColorVar.A = config.StartColorVar.A; StartColorVar = startColorVar; CCColor4F endColor = new CCColor4F(); endColor.R = config.EndColor.R; endColor.G = config.EndColor.G; endColor.B = config.EndColor.B; endColor.A = config.EndColor.A; EndColor = endColor; CCColor4F endColorVar = new CCColor4F(); endColorVar.R = config.EndColorVar.R; endColorVar.G = config.EndColorVar.G; endColorVar.B = config.EndColorVar.B; endColorVar.A = config.EndColorVar.A; EndColorVar = endColorVar; GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint(config.Gravity); gravityMode.RadialAccel = config.GravityRadialAccel; gravityMode.RadialAccelVar = config.GravityRadialAccelVar; gravityMode.Speed = config.GravitySpeed; gravityMode.SpeedVar = config.GravitySpeedVar; GravityMode = gravityMode; BlendAdditive = true; Texture = config.Texture; }
protected CCParticleSystem(int numberOfParticles, CCEmitterMode emitterMode = CCEmitterMode.Gravity) : this(numberOfParticles, true, emitterMode) { }
CCParticleSystem(int numberOfParticles, bool shouldAllocParticles, CCEmitterMode emitterMode = CCEmitterMode.Gravity) { TotalParticles = numberOfParticles; AllocatedParticles = numberOfParticles; PositionType = CCPositionType.Free; EmitterMode = emitterMode; IsActive = true; AutoRemoveOnFinish = false; if(shouldAllocParticles) { if (emitterMode == CCEmitterMode.Gravity) { GravityParticles = new CCParticleGravity[numberOfParticles]; } else { RadialParticles = new CCParticleRadial[numberOfParticles]; } } }
public CCParticleFireworks(CCPoint position, CCEmitterMode emitterMode=CCEmitterMode.Gravity) : base(1500, emitterMode) { Duration = ParticleDurationInfinity; Life = 3.5f; LifeVar = 1; Position = position; Angle = 90; AngleVar = 20; StartSize = 8.0f; StartSizeVar = 2.0f; EndSize = ParticleStartSizeEqualToEndSize; EmissionRate = TotalParticles / Life; StartColor = new CCColor4F (0.5f, 0.5f, 0.5f, 1.0f); CCColor4F startColorVar = new CCColor4F(); startColorVar.R = 0.5f; startColorVar.G = 0.5f; startColorVar.B = 0.5f; startColorVar.A = 0.1f; StartColorVar = startColorVar; CCColor4F endColor = new CCColor4F(); endColor.R = 0.1f; endColor.G = 0.1f; endColor.B = 0.1f; endColor.A = 0.2f; EndColor = endColor; CCColor4F endColorVar = new CCColor4F(); endColorVar.R = 0.1f; endColorVar.G = 0.1f; endColorVar.B = 0.1f; endColorVar.A = 0.2f; EndColorVar = endColorVar; GravityMoveMode gravityMode = new GravityMoveMode(); gravityMode.Gravity = new CCPoint (0, -90); gravityMode.RadialAccel = 0; gravityMode.RadialAccelVar = 0; gravityMode.Speed = 180; gravityMode.SpeedVar = 50; GravityMode = gravityMode; BlendAdditive = false; Texture = CCParticleExample.DefaultTexture; }