/** creates an initializes a CCParticleSystemPoint from a plist file.
        This plist files can be creted manually or with Particle Designer:  
        */
        public static CCParticleSystemPoint particleWithFile(string plistFile)
        { 
            CCParticleSystemPoint pRet = new CCParticleSystemPoint();
            if (pRet != null && pRet.initWithFile(plistFile))
            {
                return pRet;
            }

            return pRet;
        }
        public static CCParticleSystemPoint particleWithFile(string plistFile)
        {
            CCParticleSystemPoint point = new CCParticleSystemPoint();

            if ((point != null) && point.initWithFile(plistFile))
            {
                return(point);
            }
            return(point);
        }
        /** creates an initializes a CCParticleSystemPoint from a plist file.
         * This plist files can be creted manually or with Particle Designer:
         */
        public static CCParticleSystemPoint particleWithFile(string plistFile)
        {
            CCParticleSystemPoint pRet = new CCParticleSystemPoint();

            if (pRet != null && pRet.initWithFile(plistFile))
            {
                return(pRet);
            }

            return(pRet);
        }
        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);

            if (subtestNumber <= 3)
            {
                particleSystem = new CCParticleSystemPoint();
            }
            else
            {
                particleSystem = new CCParticleSystemQuad();
            }

            switch (subtestNumber)
            {
                case 1:
                    CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
                    particleSystem.initWithTotalParticles((uint)quantityParticles);
                    particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                    break;
                case 2:
                    CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);
                    particleSystem.initWithTotalParticles((uint)quantityParticles);
                    particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                    break;
                case 3:
                    CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_A8);
                    particleSystem.initWithTotalParticles((uint)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.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
                    particleSystem.initWithTotalParticles((uint)quantityParticles);
                    particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                    break;
                case 5:
                    CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);
                    particleSystem.initWithTotalParticles((uint)quantityParticles);
                    particleSystem.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
                    break;
                case 6:
                    CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_A8);
                    particleSystem.initWithTotalParticles((uint)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.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
        }
Пример #5
0
        public override void onEnter()
        {
            base.onEnter();

            m_emitter = new CCParticleSystemPoint();
            m_emitter.initWithTotalParticles(1000);
            //m_emitter.autorelease();

            m_background.addChild(m_emitter, 10);
            ////m_emitter.release();

            CCSize s = CCDirector.sharedDirector().getWinSize();

            // duration
            m_emitter.Duration = -1;

            // gravity
            m_emitter.setGravity(new CCPoint(0, 0));

            // angle
            m_emitter.Angle = 0;
            m_emitter.AngleVar = 360;

            // radial
            m_emitter.setRadialAccel(70);
            m_emitter.setRadialAccelVar(10);

            // tagential
            m_emitter.setTangentialAccel(80);
            m_emitter.setTangentialAccelVar(0);

            // speed of particles
            m_emitter.setSpeed(50);
            m_emitter.setSpeedVar(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
            ccColor4F startColor = new ccColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColor = startColor;

            ccColor4F startColorVar = new ccColor4F(0.5f, 0.5f, 0.5f, 1.0f);
            m_emitter.StartColorVar = startColorVar;

            ccColor4F endColor = new ccColor4F(0.1f, 0.1f, 0.1f, 0.2f);
            m_emitter.EndColor = endColor;

            ccColor4F 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.IsBlendAdditive = false;

            setEmitterPosition();
        }