Пример #1
0
        public void performTestsPNG(string filename)
        {
            //struct timeval now;
            DateTime       now;
            CCTexture2D    texture;
            CCTextureCache cache = CCTextureCache.sharedTextureCache();

            CCLog.Log("RGBA 8888");
            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
            //gettimeofday(now);
            texture = cache.addImage(filename);
            //if (texture != null)
            //    CCLog.Log("  ms:%f\n", calculateDeltaTime(now));
            //else
            //    CCLog.Log(" ERROR\n");
            cache.removeTexture(texture);

            CCLog.Log("RGBA 4444");
            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);

            //gettimeofday(now);
            texture = cache.addImage(filename);
            //if (texture != null)
            //    CCLog.Log("  ms:%f\n", calculateDeltaTime(now));
            //else
            //    CCLog.Log(" ERROR\n");
            cache.removeTexture(texture);

            CCLog.Log("RGBA 5551");
            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGB5A1);
            //gettimeofday(now);
            texture = cache.addImage(filename);
            //if (texture != null)
            //    CCLog.Log("  ms:%f\n", calculateDeltaTime(now));
            //else
            //    CCLog.Log(" ERROR\n");
            cache.removeTexture(texture);

            CCLog.Log("RGB 565");
            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGB565);
            //gettimeofday(now);
            texture = cache.addImage(filename);
            //if (texture != null)
            //    CCLog.Log("  ms:%f\n", calculateDeltaTime(now));
            //else
            //    CCLog.Log(" ERROR\n");
            cache.removeTexture(texture);
        }
Пример #2
0
        public CCSprite createSpriteWithTag(int tag)
        {
            Random random = new Random();

            // create
            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);

            CCSprite sprite = null;

            switch (subtestNumber)
            {
            case 1:
            {
                sprite = CCSprite.spriteWithFile("Images/grossinis_sister1");
                parent.addChild(sprite, 0, tag + 100);
                break;
            }

            case 2:
            case 3:
            {
                sprite = CCSprite.spriteWithBatchNode(batchNode, new CCRect(0, 0, 52, 139));
                batchNode.addChild(sprite, 0, tag + 100);
                break;
            }

            case 4:
            {
                int idx = (random.Next() * 1400 / 100) + 1;
                //char str[32] = {0};
                string str;
                //sprintf(str, "Images/grossini_dance_%02d.png", idx);
                str    = string.Format("Images/grossini_dance_{0:2d}.png", idx);
                sprite = CCSprite.spriteWithFile(str);
                parent.addChild(sprite, 0, tag + 100);
                break;
            }

            case 5:
            case 6:
            {
                int y, x;
                int r = (random.Next() * 1400 / 100);

                y = r / 5;
                x = r % 5;

                x     *= 85;
                y     *= 121;
                sprite = CCSprite.spriteWithBatchNode(batchNode, new CCRect(x, y, 85, 121));
                batchNode.addChild(sprite, 0, tag + 100);
                break;
            }

            case 7:
            {
                int y, x;
                int r = (random.Next() * 6400 / 100);

                y = r / 8;
                x = r % 8;

                //char str[40] = {0};
                string str;
                //sprintf(str, "Images/sprites_test/sprite-%d-%d.png", x, y);
                str    = string.Format("Images/sprites_test/sprite-{0:D}-{1:D}.png", x, y);
                sprite = CCSprite.spriteWithFile(str);
                parent.addChild(sprite, 0, tag + 100);
                break;
            }

            case 8:
            case 9:
            {
                int y, x;
                int r = (random.Next() * 6400 / 100);

                y = r / 8;
                x = r % 8;

                x     *= 32;
                y     *= 32;
                sprite = CCSprite.spriteWithBatchNode(batchNode, new CCRect(x, y, 32, 32));
                batchNode.addChild(sprite, 0, tag + 100);
                break;
            }

            default:
                break;
            }

            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_Default);

            return(sprite);
        }
        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);
        }
Пример #4
0
        public void initWithSubTest(int nSubTest, CCNode p)
        {
            subtestNumber = nSubTest;
            parent        = p;
            batchNode     = null;

            /*
             * Tests:
             * 1: 1 (32-bit) PNG sprite of 52 x 139
             * 2: 1 (32-bit) PNG Batch Node using 1 sprite of 52 x 139
             * 3: 1 (16-bit) PNG Batch Node using 1 sprite of 52 x 139
             * 4: 1 (4-bit) PVRTC Batch Node using 1 sprite of 52 x 139
             *
             * 5: 14 (32-bit) PNG sprites of 85 x 121 each
             * 6: 14 (32-bit) PNG Batch Node of 85 x 121 each
             * 7: 14 (16-bit) PNG Batch Node of 85 x 121 each
             * 8: 14 (4-bit) PVRTC Batch Node of 85 x 121 each
             *
             * 9: 64 (32-bit) sprites of 32 x 32 each
             * 10: 64 (32-bit) PNG Batch Node of 32 x 32 each
             * 11: 64 (16-bit) PNG Batch Node of 32 x 32 each
             * 12: 64 (4-bit) PVRTC Batch Node of 32 x 32 each
             */

            // purge textures
            CCTextureCache mgr = CCTextureCache.sharedTextureCache();

            //		[mgr removeAllTextures];
            mgr.removeTexture(mgr.addImage("Images/grossinis_sister1"));
            mgr.removeTexture(mgr.addImage("Images/grossini_dance_atlas"));
            mgr.removeTexture(mgr.addImage("Images/spritesheet1"));

            switch (subtestNumber)
            {
            case 1:
            case 4:
            case 7:
                break;

            ///
            case 2:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
                batchNode = CCSpriteBatchNode.batchNodeWithFile("Images/grossinis_sister1", 100);
                p.addChild(batchNode, 0);
                break;

            case 3:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);
                batchNode = CCSpriteBatchNode.batchNodeWithFile("Images/grossinis_sister1", 100);
                p.addChild(batchNode, 0);
                break;

            ///
            case 5:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
                batchNode = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 100);
                p.addChild(batchNode, 0);
                break;

            case 6:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);
                batchNode = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 100);
                p.addChild(batchNode, 0);
                break;

            ///
            case 8:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA8888);
                batchNode = CCSpriteBatchNode.batchNodeWithFile("Images/spritesheet1", 100);
                p.addChild(batchNode, 0);
                break;

            case 9:
                CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_RGBA4444);
                batchNode = CCSpriteBatchNode.batchNodeWithFile("Images/spritesheet1", 100);
                p.addChild(batchNode, 0);
                break;

            default:
                break;
            }

            //if (batchNode != null)
            //{
            //    batchNode.retain();
            //}

            CCTexture2D.setDefaultAlphaPixelFormat(CCTexture2DPixelFormat.kCCTexture2DPixelFormat_Default);
        }