Esempio n. 1
0
        public TMXIsoZorder()
        {
            CCTMXTiledMap map = CCTMXTiledMap.tiledMapWithTMXFile("TileMaps/iso-test-zorder");

            addChild(map, 0, 1);

            CCSize s = map.contentSize;

            ////----UXLOG("ContentSize: %f, %f", s.width,s.height);
            map.position = (new CCPoint(-s.width / 2, 0));

            m_tamara = CCSprite.spriteWithFile(s_pPathSister1);
            map.addChild(m_tamara, map.children.Count);
            int mapWidth = (int)(map.MapSize.width * map.TileSize.width);

            m_tamara.positionInPixels = new CCPoint(mapWidth / 2, 0);
            m_tamara.anchorPoint      = new CCPoint(0.5f, 0);


            CCActionInterval   move = CCMoveBy.actionWithDuration(10, new CCPoint(300 * 1 / CCDirector.sharedDirector().ContentScaleFactor, 250 * 1 / CCDirector.sharedDirector().ContentScaleFactor));
            CCActionInterval   back = (CCActionInterval)move.reverse();
            CCFiniteTimeAction seq  = CCSequence.actions(move, back);

            m_tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));

            schedule((this.repositionSprite));
        }
Esempio n. 2
0
        public NodeToWorld()
        {
            //
            // This code tests that nodeToParent works OK:
            //  - It tests different anchor Points
            //  - It tests different children anchor points

            CCSprite back = CCSprite.spriteWithFile(TestResource.s_back3);

            addChild(back, -10);
            back.anchorPoint = (new CCPoint(0, 0));
            CCSize backSize = back.contentSize;

            CCMenuItem item = CCMenuItemImage.itemFromNormalImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
            CCMenu     menu = CCMenu.menuWithItems(item);

            menu.alignItemsVertically();
            menu.position = (new CCPoint(backSize.width / 2, backSize.height / 2));
            back.addChild(menu);

            CCActionInterval rot = CCRotateBy.actionWithDuration(5, 360);
            CCAction         fe  = CCRepeatForever.actionWithAction(rot);

            item.runAction(fe);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(3, new CCPoint(200, 0));
            CCActionInterval   move_back = (CCActionInterval)move.reverse();
            CCFiniteTimeAction seq       = CCSequence.actions(move, move_back);
            CCAction           fe2       = CCRepeatForever.actionWithAction((CCActionInterval)seq);

            back.runAction(fe2);
        }
Esempio n. 3
0
        public RenderTextureSave()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // create a render texture, this is what we are going to draw into
            m_pTarget = CCRenderTexture.renderTextureWithWidthAndHeight((int)s.width, (int)s.height);
            //m_pTarget->retain();
            m_pTarget.position = new CCPoint(s.width / 2, s.height / 2);

            // note that the render texture is a CCNode, and contains a sprite of its texture for convience,
            // so we can just parent it to the scene like any other CCNode
            this.addChild(m_pTarget, -1);

            // create a brush image to draw into the texture with
            m_pBrush = CCSprite.spriteWithFile("Images/fire.png");
            //m_pBrush->retain();
            m_pBrush.Opacity = 20;
            //this->setIsTouchEnabled(true);
            isTouchEnabled = true;

            // Save Image menu
            CCMenuItemFont.FontSize = 16;
            CCMenuItem item1 = CCMenuItemFont.itemFromString("Save Image", this, saveImage);
            CCMenuItem item2 = CCMenuItemFont.itemFromString("Clear", this, clearImage);
            CCMenu     menu  = CCMenu.menuWithItems(item1, item2);

            this.addChild(menu);
            menu.alignItemsVertically();
            menu.position = new CCPoint(s.width - 80, s.height - 30);
        }
Esempio n. 4
0
        public override void onEnter()
        {
            base.onEnter();

            m_background.parent.removeChild(m_background, true);
            m_background = null;

            CCParallaxNode p = CCParallaxNode.node();

            addChild(p, 5);

            CCSprite p1 = CCSprite.spriteWithFile(TestResource.s_back3);
            CCSprite p2 = CCSprite.spriteWithFile(TestResource.s_back3);

            p.addChild(p1, 1, new CCPoint(0.5f, 1), new CCPoint(0, 0));
            p.addChild(p2, 2, new CCPoint(1.5f, 1), new CCPoint(0, 0));

            m_emitter = CCParticleFlower.node();

            m_emitter.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_fire);

            p1.addChild(m_emitter, 10);
            m_emitter.position = new CCPoint(250, 200);

            CCParticleSun par = CCParticleSun.node();

            p2.addChild(par, 10);
            par.Texture = CCTextureCache.sharedTextureCache().addImage(TestResource.s_fire);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.reverse();
            CCFiniteTimeAction seq       = CCSequence.actions(move, move_back);

            p.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));
        }
Esempio n. 5
0
        public override void onEnter()
        {
            //
            // This test MUST be done in 'onEnter' and not on 'init'
            // otherwise the paused action will be resumed at 'onEnter' time
            //
            base.onEnter();

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

            CCLabelTTF l = CCLabelTTF.labelWithString("After 5 seconds grossini should move", "Arial", 16);

            addChild(l);
            l.position = (new CCPoint(s.width / 2, 245));


            //
            // Also, this test MUST be done, after [super onEnter]
            //
            CCSprite grossini = CCSprite.spriteWithFile(s_pPathGrossini);

            addChild(grossini, 0, kTagGrossini);
            grossini.position = (new CCPoint(200, 200));

            CCAction action = CCMoveBy.actionWithDuration(1, new CCPoint(150, 0));

            CCActionManager.sharedManager().addAction(action, grossini, true);

            schedule(unpause, 3);
        }
Esempio n. 6
0
        public Starscene()
        {
            base.init();
            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile(@"plist/allimage");
            //取得屏幕大小
            CCSize size = CCDirector.sharedDirector().getWinSize();
            //背景图
            CCSprite background = CCSprite.spriteWithFile("background//start");

            background.position = new CCPoint(size.width / 2, size.height / 2);

            this.addChild(background);
            //两个按钮
            CCMenuItemSprite btn_start = CCMenuItemSprite.itemFromNormalSprite(
                CCSprite.spriteWithSpriteFrameName("playbutton01.png"),
                CCSprite.spriteWithSpriteFrameName("playbutton03.png"),
                this, click_start);
            CCMenuItemSprite btn_back = CCMenuItemSprite.itemFromNormalSprite(
                CCSprite.spriteWithSpriteFrameName("quitbutton01.png"),
                CCSprite.spriteWithSpriteFrameName("quitbutton03.png"),
                this, click_people);
            //MenuItem需要通过CCMenu组合
            CCMenu menu_star = CCMenu.menuWithItems(btn_start);
            CCMenu menu_back = CCMenu.menuWithItems(btn_back);

            // 设置开始和结束按钮
            menu_star.position = new CCPoint(size.width / 4 * 3 - 60, 70);
            this.addChild(menu_star);
            menu_back.position = new CCPoint(size.width / 4 * 3 + 70, 150);
            this.addChild(menu_back);
        }
        public override void onEnter()
        {
            base.onEnter();

            float x, y;

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

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

            CCSprite bg = CCSprite.spriteWithFile("Images/background3");

            addChild(bg, 0, EffectAdvanceScene.kTagBackground);
            bg.position = new CCPoint(x / 2, y / 2);

            grossini = CCSprite.spriteWithFile("Images/grossinis_sister2");
            bg.addChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            grossini.position = new CCPoint(x / 3.0f, 200);
            CCActionInterval   sc      = CCScaleBy.actionWithDuration(2, 5);
            CCFiniteTimeAction sc_back = sc.reverse();

            grossini.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc, sc_back))));

            tamara = CCSprite.spriteWithFile("Images/grossinis_sister1");
            bg.addChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            tamara.position = new CCPoint(2 * x / 3.0f, 200);
            CCActionInterval   sc2      = CCScaleBy.actionWithDuration(2, 5);
            CCFiniteTimeAction sc2_back = sc2.reverse();

            tamara.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(sc2, sc2_back))));

            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28);

            label.position = new CCPoint(x / 2, y - 80);
            addChild(label);
            label.tag = EffectAdvanceScene.kTagLabel;

            string strSubtitle = subtitle();

            if (strSubtitle != null)
            {
                CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 16);
                addChild(l, 101);
                l.position = new CCPoint(size.width / 2, size.height - 80);
            }

            CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage("Images/b1", "Images/b2", this, backCallback);
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage("Images/r1", "Images/r2", this, restartCallback);
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage("Images/f1", "Images/f2", this, nextCallback);

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3);

            menu.position  = new CCPoint(0, 0);
            item1.position = new CCPoint(size.width / 2 - 100, 30);
            item2.position = new CCPoint(size.width / 2, 30);
            item3.position = new CCPoint(size.width / 2 + 100, 30);

            addChild(menu, 1);
        }
Esempio n. 8
0
        public StressTest2()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCLayer sublayer = CCLayer.node();

            CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1);

            sp1.position = (new CCPoint(80, s.height / 2));

            CCActionInterval   move                  = CCMoveBy.actionWithDuration(3, new CCPoint(350, 0));
            CCActionInterval   move_ease_inout3      = CCEaseInOut.actionWithAction((CCActionInterval)(move.copy()), 2.0f);
            CCActionInterval   move_ease_inout_back3 = (CCActionInterval)move_ease_inout3.reverse();
            CCFiniteTimeAction seq3                  = CCSequence.actions(move_ease_inout3, move_ease_inout_back3);

            sp1.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq3));
            sublayer.addChild(sp1, 1);

            CCParticleFire fire = CCParticleFire.node();

            fire.Texture  = (CCTextureCache.sharedTextureCache().addImage("Images/fire"));
            fire.position = (new CCPoint(80, s.height / 2 - 50));

            CCActionInterval copy_seq3 = (CCActionInterval)(seq3.copy());

            fire.runAction(CCRepeatForever.actionWithAction(copy_seq3));
            sublayer.addChild(fire, 2);

            schedule((shouldNotLeak), 6.0f);

            addChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1);
        }
        public CameraZoomTest()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCSprite sprite;
            CCCamera cam;

            // LEFT
            sprite = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            addChild(sprite, 0);
            sprite.position = (new CCPoint(s.width / 4 * 1, s.height / 2));
            cam             = sprite.Camera;
            cam.setEyeXYZ(0, 0, 415);

            // CENTER
            sprite = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            addChild(sprite, 0, 40);
            sprite.position = (new CCPoint(s.width / 4 * 2, s.height / 2));
            //		cam = [sprite camera);
            //		[cam setEyeX:0 eyeY:0 eyeZ:415/2);

            // RIGHT
            sprite = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            addChild(sprite, 0, 20);
            sprite.position = (new CCPoint(s.width / 4 * 3, s.height / 2));
            //		cam = [sprite camera);
            //		[cam setEyeX:0 eyeY:0 eyeZ:-485);
            //		[cam setCenterX:0 centerY:0 centerZ:0);

            m_z = 0;
            base.scheduleUpdate();
        }
Esempio n. 10
0
        private void AddSpriteBackground()
        {
            CCSprite pSprite = CCSprite.spriteWithFile("Images\\HelloWorld");

            pSprite.position = new CCPoint(size.width / 2, size.height / 2);
            this.addChild(pSprite, 0);
        }
Esempio n. 11
0
        public Test5()
        {
            CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1);
            CCSprite sp2 = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

            sp1.position = (new CCPoint(100, 160));
            sp2.position = (new CCPoint(380, 160));

            CCRotateBy       rot      = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval rot_back = rot.reverse() as CCActionInterval;
            CCAction         forever  = CCRepeatForever.actionWithAction(
                (CCActionInterval)(CCSequence.actions(rot, rot_back))
                );
            CCAction forever2 = (CCAction)(forever.copy());

            forever.tag  = (101);
            forever2.tag = (102);

            addChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);
            addChild(sp2, 0, CocosNodeTestStaticLibrary.kTagSprite2);

            sp1.runAction(forever);
            sp2.runAction(forever2);

            schedule(new SEL_SCHEDULE(this.addAndRemove), 2.0f);
        }
Esempio n. 12
0
        public SceneTestLayer2()
        {
            m_timeCounter = 0;

            CCMenuItemFont item1 = CCMenuItemFont.itemFromString("replaceScene", this, onReplaceScene);
            CCMenuItemFont item2 = CCMenuItemFont.itemFromString("replaceScene w/transition", this, onReplaceSceneTran);
            CCMenuItemFont item3 = CCMenuItemFont.itemFromString("Go Back", this, onGoBack);

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3);

            menu.alignItemsVertically();

            addChild(menu);

            CCSize   s      = CCDirector.sharedDirector().getWinSize();
            CCSprite sprite = CCSprite.spriteWithFile(s_pPathGrossini);

            addChild(sprite);
            sprite.position = new CCPoint(s.width - 40, s.height / 2);
            CCActionInterval rotate = CCRotateBy.actionWithDuration(2, 360);
            CCAction         repeat = CCRepeatForever.actionWithAction(rotate);

            sprite.runAction(repeat);

            schedule(testDealloc);
        }
Esempio n. 13
0
        public override void onEnter()
        {
            base.onEnter();

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

            // the root object just rotates around
            m_root = CCSprite.spriteWithFile(s_pPathR1);
            addChild(m_root, 1);
            m_root.position = (new CCPoint(s.width / 2, s.height / 2));

            // the target object is offset from root, and the streak is moved to follow it
            m_target = CCSprite.spriteWithFile(s_pPathR1);
            m_root.addChild(m_target);
            m_target.position = (new CCPoint(100, 0));

            // create the streak object and add it to the scene
            //m_streak = CCMotionStreak.streakWithFade(2, 3, s_streak, 32, 32, new ccColor4B(0,255,0,255) );
            addChild(m_streak);
            // schedule an update on each frame so we can syncronize the streak with the target
            schedule(onUpdate);

            CCActionInterval a1 = CCRotateBy.actionWithDuration(2, 360);

            CCAction         action1 = CCRepeatForever.actionWithAction(a1);
            CCActionInterval motion  = CCMoveBy.actionWithDuration(2, new CCPoint(100, 0));

            m_root.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(motion, motion.reverse()))));
            m_root.runAction(action1);
        }
Esempio n. 14
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));
        }
Esempio n. 15
0
        public SelectScene()
        {
            base.init();
            //取得屏幕大小
            CCSize size = CCDirector.sharedDirector().getWinSize();
            //背景图
            CCSprite background = CCSprite.spriteWithFile("background//select");

            background.position = new CCPoint(size.width / 2, size.height / 2);
            this.addChild(background);
            // 两个人物的选择
            CCMenuItemSprite button_uncle = CCMenuItemSprite.itemFromNormalSprite(
                CCSprite.spriteWithSpriteFrameName("selectM01.png"),
                CCSprite.spriteWithSpriteFrameName("selectM02.png"),
                this, click_start);
            //两个按钮
            CCMenuItemSprite button_kfc = CCMenuItemSprite.itemFromNormalSprite(
                CCSprite.spriteWithSpriteFrameName("selectK01.png"),
                CCSprite.spriteWithSpriteFrameName("selectK02.png"),
                this, click_start);
            //MenuItem需要通过CCMenu组合
            CCMenu menu = CCMenu.menuWithItems(button_uncle, button_kfc);

            //设置到界面中间偏下
            menu.alignItemsHorizontallyWithPadding(120);
            menu.position = new CCPoint(size.width / 2, size.height / 2 - 20);
            this.addChild(menu);
        }
Esempio n. 16
0
        public override void onEnter()
        {
            base.onEnter();
            m_grossini = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            m_tamara   = CCSprite.spriteWithFile(TestResource.s_pPathSister1);
            m_kathia   = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

            addChild(m_grossini, 3);
            addChild(m_kathia, 2);
            addChild(m_tamara, 1);

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

            m_grossini.position = new CCPoint(60, 50);
            m_kathia.position   = new CCPoint(60, 150);
            m_tamara.position   = new CCPoint(60, 250);

            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 32);

            addChild(label);
            label.position = new CCPoint(s.width / 2, s.height - 50);

            CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, backCallback);
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, restartCallback);
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, nextCallback);

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3);

            menu.position  = CCPoint.Zero;
            item1.position = new CCPoint(s.width / 2 - 100, 30);
            item2.position = new CCPoint(s.width / 2, 30);
            item3.position = new CCPoint(s.width / 2 + 100, 30);

            addChild(menu, 1);
        }
Esempio n. 17
0
        public SpriteZOrder()
        {
            m_dir = 1;

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

            float step = s.width / 11;

            for (int i = 0; i < 5; i++)
            {
                CCSprite sprite = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
                sprite.position = (new CCPoint((i + 1) * step, s.height / 2));
                addChild(sprite, i);
            }

            for (int i = 5; i < 10; i++)
            {
                CCSprite sprite = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 0, 85, 121));
                sprite.position = new CCPoint((i + 1) * step, s.height / 2);
                addChild(sprite, 14 - i);
            }

            CCSprite sprite1 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 0, 85, 121));

            addChild(sprite1, -1, (int)kTagSprite.kTagSprite1);
            sprite1.position = (new CCPoint(s.width / 2, s.height / 2 - 20));
            sprite1.scale    = 6;
            sprite1.Color    = new ccColor3B(Color.Red);

            schedule(reorderSprite, 1);
        }
Esempio n. 18
0
        public ParticleDemo()
        {
            initWithColor(ccTypes.ccc4(127, 127, 127, 255));

            m_emitter = null;

            isTouchEnabled = true;

            CCSize     s     = CCDirector.sharedDirector().getWinSize();
            CCLabelTTF label = CCLabelTTF.labelWithString(title(), "Arial", 28);

            addChild(label, 100, 1000);
            label.position = new CCPoint(s.width / 2, s.height - 50);

            CCLabelTTF tapScreen = CCLabelTTF.labelWithString("(Tap the Screen)", "Arial", 20);

            tapScreen.position = new CCPoint(s.width / 2, s.height - 80);
            addChild(tapScreen, 100);

            CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, new SEL_MenuHandler(backCallback));
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, new SEL_MenuHandler(restartCallback));
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, new SEL_MenuHandler(nextCallback));

            CCMenuItemToggle item4 = CCMenuItemToggle.itemWithTarget(this,
                                                                     new SEL_MenuHandler(toggleCallback),
                                                                     CCMenuItemFont.itemFromString("Free Movement"),
                                                                     CCMenuItemFont.itemFromString("Relative Movement"),
                                                                     CCMenuItemFont.itemFromString("Grouped Movement"));

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3, item4);

            menu.position     = new CCPoint(0, 0);
            item1.position    = new CCPoint(s.width / 2 - 100, 30);
            item2.position    = new CCPoint(s.width / 2, 30);
            item3.position    = new CCPoint(s.width / 2 + 100, 30);
            item4.position    = new CCPoint(0, 100);
            item4.anchorPoint = new CCPoint(0, 0);

            addChild(menu, 100);

            CCLabelAtlas labelAtlas = CCLabelAtlas.labelWithString("0000", "fonts/fnt/images/fps_images", 16, 24, '.');

            addChild(labelAtlas, 100, ParticleTestScene.kTagLabelAtlas);
            labelAtlas.position = new CCPoint(s.width - 66, 50);

            // moving background
            m_background = CCSprite.spriteWithFile(TestResource.s_back3);
            addChild(m_background, 5);
            m_background.position = new CCPoint(s.width / 2 - 120, s.height - 240);

            CCActionInterval   move      = CCMoveBy.actionWithDuration(4, new CCPoint(300, 0));
            CCFiniteTimeAction move_back = move.reverse();
            CCFiniteTimeAction seq       = CCSequence.actions(move, move_back);

            m_background.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));


            schedule(new SEL_SCHEDULE(step));
        }
Esempio n. 19
0
        public IntervalLayer()
        {
            m_time0 = m_time1 = m_time2 = m_time3 = m_time4 = 0.0f;

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

            // sun
            //CCParticleSystem sun = CCParticleSun.node();
            //sun.Texture = CCTextureCache.sharedTextureCache().addImage("Images/fire");
            //sun.position = (new CCPoint(s.width - 32, s.height - 32));

            ////sun.setTotalParticles(130);
            //sun.Life = (0.6f);
            //this.addChild(sun);

            // timers
            m_label0 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4");
            m_label1 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4");
            m_label2 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4");
            m_label3 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4");
            m_label4 = CCLabelBMFont.labelWithString("0", "fonts/fnt/bitmapFontTest4");

            base.scheduleUpdate();
            schedule(step1);
            schedule(step2, 0);
            schedule(step3, 1.0f);
            schedule(step4, 2.0f);

            m_label1.position = new CCPoint(s.width * 2 / 6, s.height / 2);
            m_label2.position = new CCPoint(s.width * 3 / 6, s.height / 2);
            m_label3.position = new CCPoint(s.width * 4 / 6, s.height / 2);
            m_label4.position = new CCPoint(s.width * 5 / 6, s.height / 2);

            addChild(m_label0);
            addChild(m_label1);
            addChild(m_label2);
            addChild(m_label3);
            addChild(m_label4);

            // Sprite
            CCSprite sprite = CCSprite.spriteWithFile(s_pPathGrossini);

            sprite.position = new CCPoint(40, 50);

            CCJumpBy jump = CCJumpBy.actionWithDuration(3, new CCPoint(s.width - 80, 0), 50, 4);

            addChild(sprite);
            sprite.runAction(CCRepeatForever.actionWithAction(
                                 (CCActionInterval)(CCSequence.actions(jump, jump.reverse()))
                                 )
                             );
            // pause button
            CCMenuItem item1 = CCMenuItemFont.itemFromString("Pause", this, onPause);
            CCMenu     menu  = CCMenu.menuWithItems(item1);

            menu.position = new CCPoint(s.width / 2, s.height - 50);

            addChild(menu);
        }
Esempio n. 20
0
        /// <summary>
        ///  Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
        /// </summary>
        public override bool init()
        {
            CCDirector.sharedDirector().deviceOrientation = ccDeviceOrientation.CCDeviceOrientationLandscapeLeft;

            //////////////////////////////
            // 1. super init first
            if (!base.init())
            {
                return(false);
            }

            this.m_bIsTouchEnabled = true;
            /////////////////////////////
            // 2. add a menu item with "X" image, which is clicked to quit the program
            //    you may modify it.

            // add a "close" icon to exit the progress. it's an autorelease object
            CCMenuItemImage pCloseItem = CCMenuItemImage.itemFromNormalImage(
                "CloseNormal",
                "CloseSelected",
                this,
                new SEL_MenuHandler(menuCloseCallback));

            pCloseItem.position = new CCPoint(CCDirector.sharedDirector().getWinSize().width - 20, 20);

            // create menu, it's an autorelease object
            CCMenu pMenu = CCMenu.menuWithItems(pCloseItem);

            pMenu.position = new CCPoint(0, 0);
            this.addChild(pMenu, 1);

            /////////////////////////////
            // 3. add your codes below...

            // add a label shows "Hello World"
            // create and initialize a label
            CCLabelTTF pLabel = CCLabelTTF.labelWithString("Hello World", "Arial", 24);
            // ask director the window size
            CCSize size = CCDirector.sharedDirector().getWinSize();

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

            // add the label as a child to this layer
            this.addChild(pLabel, 1);

            // add "HelloWorld" splash screen"
            CCSprite pSprite = CCSprite.spriteWithFile("HelloWorld");

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

            // add the sprite as a child to this layer
            this.addChild(pSprite, 0);

            return(true);
        }
Esempio n. 21
0
        public override void onEnter()
        {
            base.onEnter();
            CCSize   size   = CCDirector.sharedDirector().getWinSize();
            CCSprite sprite = CCSprite.spriteWithFile("Images/bugs/picture");

            addChild(sprite);
            sprite.position = (new CCPoint(size.width / 2, size.height / 2));
        }
Esempio n. 22
0
        public Parallax1()
        {
            // Top Layer, a simple image
            CCSprite cocosImage = CCSprite.spriteWithFile(s_Power);

            // scale the image (optional)
            cocosImage.scale = 2.5f;
            // change the transform anchor point to 0,0 (optional)
            cocosImage.anchorPoint = new CCPoint(0, 0);


            // Middle layer: a Tile map atlas
            //CCTileMapAtlas tilemap = CCTileMapAtlas.tileMapAtlasWithTileFile(s_TilesPng, s_LevelMapTga, 16, 16);
            //tilemap.releaseMap();

            // change the transform anchor to 0,0 (optional)
            //tilemap.anchorPoint( new CCPoint(0, 0) );

            //// Anti Aliased images
            //tilemap.Texture.AntiAliasTexParameters();


            // background layer: another image
            //CCSprite background = CCSprite.spriteWithFile(s_back);
            //// scale the image (optional)
            //background->setScale( 1.5f );G:\cocos2d-xna\xna\cocos2d-xna\CCDisplayLinkDirector.cs
            //// change the transform anchor point (optional)
            //background->setAnchorPoint( ccp(0,0) );


            //// create a void node, a parent node
            //CCParallaxNode* voidNode = CCParallaxNode::node();

            //// NOW add the 3 layers to the 'void' node

            //// background image is moved at a ratio of 0.4x, 0.5y
            //voidNode->addChild(background, -1, ccp(0.4f,0.5f), CCPointZero);

            //// tiles are moved at a ratio of 2.2x, 1.0y
            //voidNode->addChild(tilemap, 1, ccp(2.2f,1.0f), ccp(0,-200) );

            //// top image is moved at a ratio of 3.0x, 2.5y
            //voidNode->addChild(cocosImage, 2, ccp(3.0f,2.5f), ccp(200,800) );


            //// now create some actions that will move the 'void' node
            //// and the children of the 'void' node will move at different
            //// speed, thus, simulation the 3D environment
            //CCActionInterval* goUp = CCMoveBy::actionWithDuration(4, ccp(0,-500) );
            //CCActionInterval* goDown = goUp->reverse();
            //CCActionInterval* go = CCMoveBy::actionWithDuration(8, ccp(-1000,0) );
            //CCActionInterval* goBack = go->reverse();
            //CCFiniteTimeAction* seq = CCSequence::actions(goUp, go, goDown, goBack, NULL);
            //voidNode->runAction( (CCRepeatForever::actionWithAction((CCActionInterval*) seq) ));

            //addChild( voidNode );
        }
Esempio n. 23
0
        public SpriteColorOpacity()
        {
            CCSprite sprite1 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
            CCSprite sprite2 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121));
            CCSprite sprite3 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121));
            CCSprite sprite4 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121));

            CCSprite sprite5 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 0, 121 * 1, 85, 121));
            CCSprite sprite6 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 1, 121 * 1, 85, 121));
            CCSprite sprite7 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 2, 121 * 1, 85, 121));
            CCSprite sprite8 = CCSprite.spriteWithFile("Images/grossini_dance_atlas", new CCRect(85 * 3, 121 * 1, 85, 121));

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

            sprite1.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 1);
            sprite2.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 1);
            sprite3.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 1);
            sprite4.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 1);
            sprite5.position = new CCPoint((s.width / 5) * 1, (s.height / 3) * 2);
            sprite6.position = new CCPoint((s.width / 5) * 2, (s.height / 3) * 2);
            sprite7.position = new CCPoint((s.width / 5) * 3, (s.height / 3) * 2);
            sprite8.position = new CCPoint((s.width / 5) * 4, (s.height / 3) * 2);

            CCActionInterval action      = CCFadeIn.actionWithDuration(2);
            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCAction         fade        = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back)));

            CCActionInterval tintred      = CCTintBy.actionWithDuration(2, 0, -255, -255);
            CCActionInterval tintred_back = (CCActionInterval)tintred.reverse();
            CCAction         red          = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintred, tintred_back)));

            CCActionInterval tintgreen      = CCTintBy.actionWithDuration(2, -255, 0, -255);
            CCActionInterval tintgreen_back = (CCActionInterval)tintgreen.reverse();
            CCAction         green          = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintgreen, tintgreen_back)));

            CCActionInterval tintblue      = CCTintBy.actionWithDuration(2, -255, -255, 0);
            CCActionInterval tintblue_back = (CCActionInterval)tintblue.reverse();
            CCAction         blue          = CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(tintblue, tintblue_back)));

            sprite5.runAction(red);
            sprite6.runAction(green);
            sprite7.runAction(blue);
            sprite8.runAction(fade);

            // late add: test dirtyColor and dirtyPosition
            addChild(sprite1, 0, (int)kTagSprite.kTagSprite1);
            addChild(sprite2, 0, (int)kTagSprite.kTagSprite2);
            addChild(sprite3, 0, (int)kTagSprite.kTagSprite3);
            addChild(sprite4, 0, (int)kTagSprite.kTagSprite4);
            addChild(sprite5, 0, (int)kTagSprite.kTagSprite5);
            addChild(sprite6, 0, (int)kTagSprite.kTagSprite6);
            addChild(sprite7, 0, (int)kTagSprite.kTagSprite7);
            addChild(sprite8, 0, (int)kTagSprite.kTagSprite8);

            schedule(removeAndAddSprite, 2);
        }
        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);
        }
Esempio n. 25
0
        // 加入麦当劳叔叔


        public GameScene()
        {
            CCSize size = CCDirector.sharedDirector().getWinSize();

            base.init();
            CCSprite background = CCSprite.spriteWithFile("background//background");

            background.position = new CCPoint(size.width / 2, size.height / 2);
            this.addChild(background);
            this.addChild(gameplay.node());
        }
Esempio n. 26
0
        public StressTest1()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1);

            addChild(sp1, 0, CocosNodeTestStaticLibrary.kTagSprite1);

            sp1.position = (new CCPoint(s.width / 2, s.height / 2));

            schedule((shouldNotCrash), 1.0f);
        }
Esempio n. 27
0
        public override void onEnter()
        {
            base.onEnter();

            // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too
            m_grossini = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);

            m_tamara = CCSprite.spriteWithFile(TestResource.s_pPathSister1);

            m_kathia = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

            addChild(m_grossini, 1);
            addChild(m_tamara, 2);
            addChild(m_kathia, 3);

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

            m_grossini.position = new CCPoint(s.width / 2, s.height / 3);
            m_tamara.position   = new CCPoint(s.width / 2, 2 * s.height / 3);
            m_kathia.position   = new CCPoint(s.width / 2, s.height / 2);

            // add title and subtitle
            string     str    = title();
            string     pTitle = str;
            CCLabelTTF label  = CCLabelTTF.labelWithString(pTitle, "Arial", 18);

            addChild(label, 1);
            label.position = new CCPoint(s.width / 2, s.height - 30);

            string strSubtitle = subtitle();

            if (!strSubtitle.Equals(""))
            {
                CCLabelTTF l = CCLabelTTF.labelWithString(strSubtitle, "Arial", 22);
                addChild(l, 1);
                l.position = new CCPoint(s.width / 2, s.height - 60);
            }

            // add menu
            CCMenuItemImage item1 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathB1, TestResource.s_pPathB2, this, new SEL_MenuHandler(backCallback));
            CCMenuItemImage item2 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathR1, TestResource.s_pPathR2, this, new SEL_MenuHandler(restartCallback));
            CCMenuItemImage item3 = CCMenuItemImage.itemFromNormalImage(TestResource.s_pPathF1, TestResource.s_pPathF2, this, new SEL_MenuHandler(nextCallback));

            CCMenu menu = CCMenu.menuWithItems(item1, item2, item3);

            menu.position  = new CCPoint(0, 0);
            item1.position = new CCPoint(s.width / 2 - 100, 30);
            item2.position = new CCPoint(s.width / 2, 30);
            item3.position = new CCPoint(s.width / 2 + 100, 30);

            addChild(menu, 1);
        }
Esempio n. 28
0
        public override bool init()
        {
            CCDirector.sharedDirector().enableRetinaDisplay(true);
            if (base.init())
            {
                CCSprite bg = CCSprite.spriteWithFile("Images/bugs/RetinaDisplay");
                addChild(bg, 0);
                bg.anchorPoint = new CCPoint(0, 0);

                return(true);
            }
            return(false);
        }
Esempio n. 29
0
        public virtual bool init()
        {
            if (base.init())
            {
                CCSize   size       = CCDirector.sharedDirector().getWinSize();
                CCSprite background = CCSprite.spriteWithFile("Hello");
                background.position = new CCPoint(size.width / 2, size.height / 2);
                addChild(background);
                return(true);
            }

            return(false);
        }
Esempio n. 30
0
        public override void onEnter()
        {
            base.onEnter();

            CCSprite grossini = CCSprite.spriteWithFile(s_pPathGrossini);

            addChild(grossini, 0, 2);
            grossini.position = (new CCPoint(200, 200));

            grossini.runAction(CCSequence.actions(
                                   CCMoveBy.actionWithDuration(1, new CCPoint(150, 0)),
                                   CCCallFuncN.actionWithTarget(this, bugMe))
                               );
        }