Пример #1
0
        public override bool init()
        {
            if (base.init())
            {
                CCSize s = CCDirector.sharedDirector().getWinSize();

                CCLayerColor background = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 255, 255));
                addChild(background);

                CCLayerColor sprite_a = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(255, 0, 0, 255), 700, 700);
                sprite_a.anchorPoint           = new CCPoint(0.5f, 0.5f);
                sprite_a.isRelativeAnchorPoint = true;
                sprite_a.position = new CCPoint(0.0f, s.height / 2);
                addChild(sprite_a);

                sprite_a.runAction(CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions(
                                                                        CCMoveTo.actionWithDuration(1.0f, new CCPoint(1024.0f, 384.0f)),
                                                                        CCMoveTo.actionWithDuration(1.0f, new CCPoint(0.0f, 384.0f)))));

                CCLayerColor sprite_b = CCLayerColor.layerWithColorWidthHeight(new ccColor4B(0, 0, 255, 255), 400, 400);
                sprite_b.anchorPoint           = new CCPoint(0.5f, 0.5f);
                sprite_b.isRelativeAnchorPoint = true;
                sprite_b.position = new CCPoint(s.width / 2, s.height / 2);
                addChild(sprite_b);

                CCMenuItemLabel label = CCMenuItemLabel.itemWithLabel(CCLabelTTF.labelWithString("Flip Me", "Helvetica", 24), this, callBack);
                CCMenu          menu  = CCMenu.menuWithItems(label);
                menu.position = new CCPoint(s.width - 200.0f, 50.0f);
                addChild(menu);

                return(true);
            }

            return(false);
        }
Пример #2
0
        public override void onEnter()
        {
            base.onEnter();

            CCActionInterval effect = (CCActionInterval)(CCSequence.actions(CCDelayTime.actionWithDuration(2.0f), CCShaky3D.actionWithRange(16, false, new ccGridSize(5, 5), 5.0f)));

            // cleanup
            CCNode bg = getChildByTag(EffectAdvanceScene.kTagBackground);

            removeChild(bg, true);

            // background
            CCLayerColor layer = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255));

            addChild(layer, -10);
            CCSprite sprite = CCSprite.spriteWithFile("Images/grossini");

            sprite.position = new CCPoint(50, 80);
            layer.addChild(sprite, 10);

            // foreground
            CCLayerColor layer2 = CCLayerColor.layerWithColor(new ccColor4B(0, 255, 0, 255));
            CCSprite     fog    = CCSprite.spriteWithFile("Images/Fog");

            ccBlendFunc bf = new ccBlendFunc {
                src = 0x0302, dst = 0x0303
            };

            fog.BlendFunc = bf;
            layer2.addChild(fog, 1);
            addChild(layer2, 1);

            layer2.runAction(CCRepeatForever.actionWithAction(effect));
        }
        public TMXUncompressedTest()
        {
            CCLayerColor color = CCLayerColor.layerWithColor(new ccColor4B(64, 64, 64, 255));

            addChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test2-uncompressed");

            addChild(map, 0, TileMapTestScene.kTagTileMap);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            // move map to the center of the screen
            CCSize ms = map.MapSize;
            CCSize ts = map.TileSize;

            map.runAction(CCMoveTo.actionWithDuration(1.0f, new CCPoint(-ms.width * ts.width / 2, -ms.height * ts.height / 2)));

            // testing release map
            CCTMXLayer layer;

            foreach (var pObject in map.children)
            {
                layer = (CCTMXLayer)pObject;

                if (layer == null)
                {
                    break;
                }

                layer.releaseMap();
            }
        }
        public override bool init()
        {
            // always call "super" init
            // Apple recommends to re-assign "self" with the "super" return value
            if (base.init())
            {
                isTouchEnabled = true;
                // ask director the the window size
                CCSize       size = CCDirector.sharedDirector().getWinSize();
                CCLayerColor layer;
                CCUserDefault.sharedUserDefault().setBoolForKey("bool", true);
                for (int i = 0; i < 5; i++)
                {
                    ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255);
                    CCUserDefault.sharedUserDefault().setStringForKey("i" + i, c.ToString());
                }
                CCUserDefault.sharedUserDefault().flush();
                bool testValue = CCUserDefault.sharedUserDefault().getBoolForKey("bool", false);
                if (!testValue)
                {
                    CCLog.Log("CCUserDefault: Test failed b/c the 'bool' value was not true when it was expected.");
                }
                for (int i = 0; i < 5; i++)
                {
                    string cstr = CCUserDefault.sharedUserDefault().getStringForKey("i" + i, null);
                    if (cstr == null)
                    {
                        CCLog.Log("CCUserDefault: The color for iteration #" + i + " is null.");
                        continue;
                    }
                    ccColor4B c = new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255);
                    layer                       = CCLayerColor.layerWithColor(c);
                    layer.contentSize           = new CCSize(i * 100, i * 100);
                    layer.position              = new CCPoint(size.width / 2, size.height / 2);
                    layer.anchorPoint           = new CCPoint(0.5f, 0.5f);
                    layer.isRelativeAnchorPoint = true;
                    addChild(layer, -1 - i);
                }

                // create and initialize a Label
                CCLabelTTF label = CCLabelTTF.labelWithString("ccUserDefault Test", "Arial", 14);
                CCMenuItem item1 = CCMenuItemFont.itemFromString("restart", this, restart);

                CCMenu menu = CCMenu.menuWithItems(item1);
                menu.alignItemsVertically();
                menu.position = new CCPoint(size.width / 2, 100);
                addChild(menu);

                // position the label on the center of the screen
                label.position = new CCPoint(size.width / 2, size.height / 2);

                // add the label as a child to this Layer
                addChild(label);
                return(true);
            }
            return(false);
        }
        public RenderTextureIssue937()
        {
            /*
             *     1    2
             * A: A1   A2
             *
             * B: B1   B2
             *
             *  A1: premulti sprite
             *  A2: premulti render
             *
             *  B1: non-premulti sprite
             *  B2: non-premulti render
             */
            CCLayerColor background = CCLayerColor.layerWithColor(new ccColor4B(200, 200, 200, 255));

            addChild(background);

            CCSprite spr_premulti = CCSprite.spriteWithFile("Images/fire.png");

            spr_premulti.position = new CCPoint(16, 48);

            CCSprite spr_nonpremulti = CCSprite.spriteWithFile("Images/fire.png");

            spr_nonpremulti.position = new CCPoint(16, 16);


            /* A2 & B2 setup */
            CCRenderTexture rend = CCRenderTexture.renderTextureWithWidthAndHeight(32, 64);

            if (null == rend)
            {
                return;
            }

            // It's possible to modify the RenderTexture blending function by
            //		[[rend sprite] setBlendFunc:(ccBlendFunc) {GL_ONE, GL_ONE_MINUS_SRC_ALPHA}];
            rend.begin();
            spr_premulti.visit();
            spr_nonpremulti.visit();
            rend.end();

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

            /* A1: setup */
            spr_premulti.position = new CCPoint(s.width / 2 - 16, s.height / 2 + 16);
            /* B1: setup */
            spr_nonpremulti.position = new CCPoint(s.width / 2 - 16, s.height / 2 - 16);

            rend.position = new CCPoint(s.width / 2 + 16, s.height / 2);

            addChild(spr_nonpremulti);
            addChild(spr_premulti);
            addChild(rend);
        }
Пример #6
0
        public TMXHexTest()
        {
            CCLayerColor color = CCLayerColor.layerWithColor(new ccColor4B(64, 64, 64, 255));

            addChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/hexa-test1");

            addChild(map, 0, 1);

            CCSize s = map.contentSize;
            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);
        }
Пример #7
0
        public LabelGlyphDesigner()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCLayerColor layer = CCLayerColor.layerWithColor(new ccColor4B(128, 128, 128, 255));

            addChild(layer, -10);

            // CCLabelBMFont
            CCLabelBMFont label1 = CCLabelBMFont.labelWithString("Testing Glyph Designer", "fonts/fnt/futura-48");

            addChild(label1);
            label1.position = new CCPoint(s.width / 2, s.height / 2);
        }
Пример #8
0
        public Atlas3()
        {
            m_time = 0;

            CCLayerColor col = CCLayerColor.layerWithColor(new ccColor4B(128, 128, 128, 255));

            addChild(col, -10);

            CCLabelBMFont label1 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2");

            // testing anchors
            label1.anchorPoint = new CCPoint(0, 0);
            addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            CCActionInterval   fade    = CCFadeOut.actionWithDuration(1.0f);
            CCFiniteTimeAction fade_in = fade.reverse();
            CCFiniteTimeAction seq     = CCSequence.actions(fade, fade_in);
            CCAction           repeat  = CCRepeatForever.actionWithAction((CCActionInterval)seq);

            label1.runAction(repeat);


            // VERY IMPORTANT
            // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
            // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
            // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
            CCLabelBMFont label2 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2");

            // testing anchors
            label2.anchorPoint = new CCPoint(0.5f, 0.5f);
            label2.Color       = ccRED;
            addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.runAction((CCAction)(repeat.copy()));

            CCLabelBMFont label3 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2");

            // testing anchors
            label3.anchorPoint = new CCPoint(1, 1);
            addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);


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

            label1.position = new CCPoint();
            label2.position = new CCPoint(s.width / 2, s.height / 2);
            label3.position = new CCPoint(s.width, s.height);

            base.schedule(step);//:@selector(step:)];
        }
Пример #9
0
        public TMXIsoTest1()
        {
            CCLayerColor color = CCLayerColor.layerWithColor(new ccColor4B(64, 64, 64, 255));

            addChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test11");

            addChild(map, 0, 1);

            CCSize s = map.contentSize;

            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);

            map.anchorPoint = new CCPoint(0.5f, 0.5f);
        }
Пример #10
0
        public TMXIsoTest()
        {
            CCLayerColor color = CCLayerColor.layerWithColor(new ccColor4B(new Color(64, 64, 64, 255)));

            addChild(color, -1);

            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test01");

            addChild(map, 0, 1);

            // move map to the center of the screen
            CCSize ms = map.MapSize;
            CCSize ts = map.TileSize;

            map.runAction(CCMoveTo.actionWithDuration(1.0f, new CCPoint(-ms.width * ts.width / 2, -ms.height * ts.height / 2)));
        }
Пример #11
0
        public LayerTestBlend()
        {
            CCSize       s      = CCDirector.sharedDirector().getWinSize();
            CCLayerColor layer1 = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 255, 80));

            CCSprite sister1 = CCSprite.spriteWithFile(s_pPathSister1);
            CCSprite sister2 = CCSprite.spriteWithFile(s_pPathSister2);

            addChild(sister1);
            addChild(sister2);
            addChild(layer1, 100, kTagLayer);

            sister1.position = new CCPoint(160, s.height / 2);
            sister2.position = new CCPoint(320, s.height / 2);

            schedule(newBlend, 1.0f);
        }
Пример #12
0
        public override void onEnter()
        {
            // todo: CCLayerColor hasn't been implemented

            base.onEnter();

            m_tamara.removeFromParentAndCleanup(true);
            m_grossini.removeFromParentAndCleanup(true);
            m_kathia.removeFromParentAndCleanup(true);

            CCSize boxSize = new CCSize(100.0f, 100.0f);

            CCLayerColor box = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255));

            box.anchorPoint = new CCPoint(0, 0);
            box.position    = new CCPoint(190, 110);
            box.contentSize = boxSize;

            CCLayerColor uL = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255));

            box.addChild(uL);
            uL.contentSize = new CCSize(markrside, markrside);
            uL.position    = new CCPoint(0.0f, boxSize.height - markrside);
            uL.anchorPoint = new CCPoint(0, 0);

            CCLayerColor uR = CCLayerColor.layerWithColor(new ccColor4B(0, 0, 255, 255));

            box.addChild(uR);
            uR.contentSize = new CCSize(markrside, markrside);
            uR.position    = new CCPoint(boxSize.width - markrside, boxSize.height - markrside);
            uR.anchorPoint = new CCPoint(0, 0);
            addChild(box);

            CCActionInterval actionTo      = CCSkewTo.actionWithDuration(2, 0.0f, 2.0f);
            CCActionInterval rotateTo      = CCRotateTo.actionWithDuration(2, 61.0f);
            CCActionInterval actionScaleTo = CCScaleTo.actionWithDuration(2, -0.44f, 0.47f);

            CCActionInterval actionScaleToBack = CCScaleTo.actionWithDuration(2, 1.0f, 1.0f);
            CCActionInterval rotateToBack      = CCRotateTo.actionWithDuration(2, 0);
            CCActionInterval actionToBack      = CCSkewTo.actionWithDuration(2, 0, 0);

            box.runAction(CCSequence.actions(actionTo, actionToBack));
            box.runAction(CCSequence.actions(rotateTo, rotateToBack));
            box.runAction(CCSequence.actions(actionScaleTo, actionScaleToBack));
        }
Пример #13
0
        public override void onEnter()
        {
            base.onEnter();

            float x, y;

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

            x = size.width;
            y = size.height;

            CCNode blue  = CCLayerColor.layerWithColor(new ccColor4B(0, 0, 255, 255));
            CCNode red   = CCLayerColor.layerWithColor(new ccColor4B(255, 0, 0, 255));
            CCNode green = CCLayerColor.layerWithColor(new ccColor4B(0, 255, 0, 255));
            CCNode white = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 255, 255));

            blue.scale    = (0.5f);
            blue.position = (new CCPoint(-x / 4, -y / 4));
            blue.addChild(SpriteLayer.node());

            red.scale    = (0.5f);
            red.position = (new CCPoint(x / 4, -y / 4));

            green.scale    = (0.5f);
            green.position = (new CCPoint(-x / 4, y / 4));
            green.addChild(TestLayer.node());

            white.scale    = (0.5f);
            white.position = (new CCPoint(x / 4, y / 4));

            addChild(blue, -1);
            addChild(white);
            addChild(green);
            addChild(red);

            CCAction rot = CCRotateBy.actionWithDuration(8, 720);

            blue.runAction(rot);
            red.runAction((CCAction)(rot.copy()));
            green.runAction((CCAction)(rot.copy()));
            white.runAction((CCAction)(rot.copy()));
        }
Пример #14
0
        public MainLayer()
        {
            base.isTouchEnabled = true;

            CCSprite sprite = CCSprite.spriteWithFile(ClickAndMoveTest.s_pPathGrossini);

            CCLayer layer = CCLayerColor.layerWithColor(new ccColor4B(255, 255, 0, 255));

            addChild(layer, -1);

            addChild(sprite, 0, ClickAndMoveTest.kTagSprite);
            sprite.position = new CCPoint(20, 150);

            sprite.runAction(CCJumpTo.actionWithDuration(4, new CCPoint(300, 48), 100, 4));

            layer.runAction(CCRepeatForever.actionWithAction(
                                (CCActionInterval)(CCSequence.actions(
                                                       CCFadeIn.actionWithDuration(1),
                                                       CCFadeOut.actionWithDuration(1)))
                                ));
        }
Пример #15
0
        public override bool init()
        {
            // always call "super" init
            // Apple recommends to re-assign "self" with the "super" return value
            if (base.init())
            {
                isTouchEnabled = true;
                // ask director the the window size
                CCSize       size = CCDirector.sharedDirector().getWinSize();
                CCLayerColor layer;
                for (int i = 0; i < 5; i++)
                {
                    layer                       = CCLayerColor.layerWithColor(new ccColor4B((byte)(i * 20), (byte)(i * 20), (byte)(i * 20), 255));
                    layer.contentSize           = new CCSize(i * 100, i * 100);
                    layer.position              = new CCPoint(size.width / 2, size.height / 2);
                    layer.anchorPoint           = new CCPoint(0.5f, 0.5f);
                    layer.isRelativeAnchorPoint = true;
                    addChild(layer, -1 - i);
                }

                // create and initialize a Label
                CCLabelTTF label = CCLabelTTF.labelWithString("Hello World", "Marker Felt", 64);
                CCMenuItem item1 = CCMenuItemFont.itemFromString("restart", this, restart);

                CCMenu menu = CCMenu.menuWithItems(item1);
                menu.alignItemsVertically();
                menu.position = new CCPoint(size.width / 2, 100);
                addChild(menu);

                // position the label on the center of the screen
                label.position = new CCPoint(size.width / 2, size.height / 2);

                // add the label as a child to this Layer
                addChild(label);
                return(true);
            }
            return(false);
        }