public override void OnEnter() { base.OnEnter(); m_emitter = new CCParticleSystemQuad(); m_emitter.InitWithTotalParticles(50); //m_emitter.autorelease(); m_background.AddChild(m_emitter, 10); ////m_emitter.release(); // win32 : use this line or remove this line and use autorelease() m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_stars1); m_emitter.Duration = -1; // gravity m_emitter.Gravity = (new CCPoint(0, 0)); // angle m_emitter.Angle = 90; m_emitter.AngleVar = 360; // speed of particles m_emitter.Speed = (160); m_emitter.SpeedVar = (20); // radial m_emitter.RadialAccel = (-120); m_emitter.RadialAccelVar = (0); // tagential m_emitter.TangentialAccel = (30); m_emitter.TangentialAccelVar = (0); // emitter position m_emitter.Position = new CCPoint(160, 240); m_emitter.PosVar = new CCPoint(0, 0); // life of particles m_emitter.Life = 4; m_emitter.LifeVar = 1; // spin of particles m_emitter.StartSpin = 0; m_emitter.StartSizeVar = 0; m_emitter.EndSpin = 0; m_emitter.EndSpinVar = 0; // color of particles var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColor = startColor; var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColorVar = startColorVar; var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColor = endColor; var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColorVar = endColorVar; // size, in pixels m_emitter.StartSize = 80.0f; m_emitter.StartSizeVar = 40.0f; m_emitter.EndSize = CCParticleSystem.kParticleStartSizeEqualToEndSize; // emits per second m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life; // additive m_emitter.BlendAdditive = true; setEmitterPosition(); }
public void createParticleSystem() { CCParticleSystem particleSystem = null; /* * Tests: * 1: Point Particle System using 32-bit textures (PNG) * 2: Point Particle System using 16-bit textures (PNG) * 3: Point Particle System using 8-bit textures (PNG) * 4: Point Particle System using 4-bit textures (PVRTC) * 5: Quad Particle System using 32-bit textures (PNG) * 6: Quad Particle System using 16-bit textures (PNG) * 7: Quad Particle System using 8-bit textures (PNG) * 8: Quad Particle System using 4-bit textures (PVRTC) */ RemoveChildByTag(PerformanceParticleTest.kTagParticleSystem, true); // remove the "fire.png" from the TextureCache cache. CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); CCTextureCache.SharedTextureCache.RemoveTexture(texture); particleSystem = new CCParticleSystemQuad(); switch (subtestNumber) { case 1: CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888; particleSystem.InitWithTotalParticles(quantityParticles); particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); break; case 2: CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444; particleSystem.InitWithTotalParticles(quantityParticles); particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); break; case 3: CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_A8; particleSystem.InitWithTotalParticles(quantityParticles); particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); break; // case 4: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"]; // particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); // break; case 4: CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888; particleSystem.InitWithTotalParticles(quantityParticles); particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); break; case 5: CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444; particleSystem.InitWithTotalParticles(quantityParticles); particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); break; case 6: CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_A8; particleSystem.InitWithTotalParticles(quantityParticles); particleSystem.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); break; // case 8: // particleSystem->initWithTotalParticles(quantityParticles); // ////---- particleSystem.texture = [[CCTextureCache sharedTextureCache] addImage:@"fire.pvr"]; // particleSystem->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); // break; default: particleSystem = null; CCLog.Log("Shall not happen!"); break; } AddChild(particleSystem, 0, PerformanceParticleTest.kTagParticleSystem); doTest(); // restore the default pixel format CCTexture2D.DefaultAlphaPixelFormat = CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888; }
public override void OnEnter() { base.OnEnter(); Color = new CCColor3B(0, 0, 0); RemoveChild(m_background, true); m_background = null; m_emitter = new CCParticleSystemQuad(); m_emitter.InitWithTotalParticles(100); AddChild(m_emitter, 10); m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage("Images/fire"); // duration m_emitter.Duration = CCParticleSystem.kCCParticleDurationInfinity; // radius mode m_emitter.EmitterMode = CCEmitterMode.kCCParticleModeRadius; // radius mode: start and end radius in pixels m_emitter.StartRadius = (50); m_emitter.StartRadiusVar = (0); m_emitter.EndRadius = (CCParticleSystem.kCCParticleStartRadiusEqualToEndRadius); m_emitter.EndRadiusVar = (0); // radius mode: degrees per second m_emitter.RotatePerSecond = (0); m_emitter.RotatePerSecondVar = (0); // angle m_emitter.Angle = 90; m_emitter.AngleVar = 0; // emitter position CCSize size = CCDirector.SharedDirector.WinSize; m_emitter.Position = new CCPoint(size.Width / 2, size.Height / 2); m_emitter.PosVar = new CCPoint(0, 0); // life of particles m_emitter.Life = 5; m_emitter.LifeVar = 0; // spin of particles m_emitter.StartSpin = 0; m_emitter.StartSpinVar = 0; m_emitter.EndSpin = 0; m_emitter.EndSpinVar = 0; // color of particles var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColor = startColor; var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColorVar = startColorVar; var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColor = endColor; var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColorVar = endColorVar; // size, in pixels m_emitter.StartSize = 16; m_emitter.StartSizeVar = 0; m_emitter.EndSize = CCParticleSystem.kCCParticleStartSizeEqualToEndSize; // emits per second m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life; // additive m_emitter.BlendAdditive = false; CCRotateBy rot = new CCRotateBy (16, 360); m_emitter.RunAction(new CCRepeatForever (rot)); }
public override void OnEnter() { base.OnEnter(); m_emitter = new CCParticleSystemQuad(); m_emitter.InitWithTotalParticles(1000); //m_emitter.autorelease(); m_background.AddChild(m_emitter, 10); ////m_emitter.release(); CCSize s = CCDirector.SharedDirector.WinSize; // duration m_emitter.Duration = -1; // gravity m_emitter.Gravity = (new CCPoint(0, 0)); // angle m_emitter.Angle = 0; m_emitter.AngleVar = 360; // radial m_emitter.RadialAccel = (70); m_emitter.RadialAccelVar = (10); // tagential m_emitter.TangentialAccel = (80); m_emitter.TangentialAccelVar = (0); // speed of particles m_emitter.Speed = (50); m_emitter.SpeedVar = (10); // emitter position m_emitter.Position = new CCPoint(s.Width / 2, s.Height / 2); m_emitter.PosVar = new CCPoint(0, 0); // life of particles m_emitter.Life = 2.0f; m_emitter.LifeVar = 0.3f; // emits per frame m_emitter.EmissionRate = m_emitter.TotalParticles / m_emitter.Life; // color of particles var startColor = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColor = startColor; var startColorVar = new CCColor4F(0.5f, 0.5f, 0.5f, 1.0f); m_emitter.StartColorVar = startColorVar; var endColor = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColor = endColor; var endColorVar = new CCColor4F(0.1f, 0.1f, 0.1f, 0.2f); m_emitter.EndColorVar = endColorVar; // size, in pixels m_emitter.StartSize = 1.0f; m_emitter.StartSizeVar = 1.0f; m_emitter.EndSize = 32.0f; m_emitter.EndSizeVar = 8.0f; // texture m_emitter.Texture = CCTextureCache.SharedTextureCache.AddImage(TestResource.s_fire); // additive m_emitter.BlendAdditive = false; setEmitterPosition(); }
public override void OnEnter() { base.OnEnter(); Color = CCTypes.CCBlack; RemoveChild(m_background, true); m_background = null; m_pBatchNode = CCParticleBatchNode.Create("Images/stars-grayscale", 3000); AddChild(m_pBatchNode, 1, 2); for (int i = 0; i < 3; i++) { var particleSystem = new CCParticleSystemQuad(); particleSystem.InitWithTotalParticles(200); particleSystem.Texture = (m_pBatchNode.Texture); // duration particleSystem.Duration = CCParticleSystem.kCCParticleDurationInfinity; // radius mode particleSystem.EmitterMode = CCEmitterMode.kCCParticleModeRadius; // radius mode: 100 pixels from center particleSystem.StartRadius = (100); particleSystem.StartRadiusVar = (0); particleSystem.EndRadius = (CCParticleSystem.kCCParticleStartRadiusEqualToEndRadius); particleSystem.EndRadiusVar = (0); // not used when start == end // radius mode: degrees per second // 45 * 4 seconds of life = 180 degrees particleSystem.RotatePerSecond = (45); particleSystem.RotatePerSecondVar = (0); // angle particleSystem.Angle = (90); particleSystem.AngleVar = (0); // emitter position particleSystem.PosVar = (CCPoint.Zero); // life of particles particleSystem.Life = (4); particleSystem.LifeVar = (0); // spin of particles particleSystem.StartSpin = (0); particleSystem.StartSpinVar = (0); particleSystem.EndSpin = (0); particleSystem.EndSpinVar = (0); // color of particles var color = new float[3] {0, 0, 0}; color[i] = 1; var startColor = new CCColor4F(color[0], color[1], color[2], 1.0f); particleSystem.StartColor = (startColor); var startColorVar = new CCColor4F(0, 0, 0, 0); particleSystem.StartColorVar = (startColorVar); CCColor4F endColor = startColor; particleSystem.EndColor = (endColor); CCColor4F endColorVar = startColorVar; particleSystem.EndColorVar = (endColorVar); // size, in pixels particleSystem.StartSize = (32); particleSystem.StartSizeVar = (0); particleSystem.EndSize = CCParticleSystem.kCCParticleStartSizeEqualToEndSize; // emits per second particleSystem.EmissionRate = (particleSystem.TotalParticles / particleSystem.Life); // additive particleSystem.Position = (new CCPoint(i * 10 + 120, 200)); m_pBatchNode.AddChild(particleSystem); particleSystem.PositionType = CCPositionType.kCCPositionTypeFree; //[pBNode addChild:particleSystem z:10 tag:0); } Schedule(reorderSystem, 2.0f); m_emitter = null; }
public CCParticleSystemQuad Clone() { var p = new CCParticleSystemQuad(); p.InitWithTotalParticles(m_uTotalParticles); // angle p.m_fAngle = m_fAngle; p.m_fAngleVar = m_fAngleVar; // duration p.m_fDuration = m_fDuration; // blend function p.m_tBlendFunc = m_tBlendFunc; // color p.m_tStartColor = m_tStartColor; p.m_tStartColorVar = m_tStartColorVar; p.m_tEndColor = m_tEndColor; p.m_tEndColorVar = m_tEndColorVar; // particle size p.m_fStartSize = m_fStartSize; p.m_fStartSizeVar = m_fStartSizeVar; p.m_fEndSize = m_fEndSize; p.m_fEndSizeVar = m_fEndSizeVar; // position p.Position = Position; p.m_tPosVar = m_tPosVar; // Spinning p.m_fStartSpin = m_fStartSpin; p.m_fStartSpinVar = m_fStartSpinVar; p.m_fEndSpin = m_fEndSpin; p.m_fEndSpinVar = m_fEndSpinVar; p.m_nEmitterMode = m_nEmitterMode; p.modeA = modeA; p.modeB = modeB; // life span p.m_fLife = m_fLife; p.m_fLifeVar = m_fLifeVar; // emission Rate p.m_fEmissionRate = m_fEmissionRate; p.m_bOpacityModifyRGB = m_bOpacityModifyRGB; p.m_pTexture = m_pTexture; p.AutoRemoveOnFinish = AutoRemoveOnFinish; return p; }
public static CCParticleSystemQuad Create(int numberOfParticles) { var pRet = new CCParticleSystemQuad(); pRet.InitWithTotalParticles(numberOfParticles); return pRet; }