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);
        }
Example #2
0
        public CameraOrbitTest()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

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

            addChild(p, 0);
            p.position = (new CCPoint(s.width / 2, s.height / 2));
            p.Opacity  = 128;

            CCSprite      sprite;
            CCOrbitCamera orbit;
            CCCamera      cam;
            CCSize        ss;

            // LEFT
            s            = p.contentSize;
            sprite       = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            sprite.scale = (0.5f);
            p.addChild(sprite, 0);
            sprite.position = (new CCPoint(s.width / 4 * 1, s.height / 2));
            cam             = sprite.Camera;
            orbit           = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 360, 0, 0);
            //sprite.runAction(CCRepeatForever.actionWithAction(orbit));

            // CENTER
            sprite       = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            sprite.scale = 1.0f;
            p.addChild(sprite, 0);
            sprite.position = new CCPoint(s.width / 4 * 2, s.height / 2);
            orbit           = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 360, 45, 0);
            //sprite.runAction(CCRepeatForever.actionWithAction(orbit));


            // RIGHT
            sprite       = CCSprite.spriteWithFile(TestResource.s_pPathGrossini);
            sprite.scale = 2.0f;
            p.addChild(sprite, 0);
            sprite.position = new CCPoint(s.width / 4 * 3, s.height / 2);
            ss    = sprite.contentSize;
            orbit = CCOrbitCamera.actionWithDuration(2, 1, 0, 0, 360, 90, -45);
            //sprite.runAction(CCRepeatForever.actionWithAction(orbit));


            // PARENT
            orbit = CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 90);
            //p.runAction(CCRepeatForever.actionWithAction(orbit));
            scale = 1;
        }
Example #3
0
        public Test6()
        {
            CCSprite sp1  = CCSprite.spriteWithFile(TestResource.s_pPathSister1);
            CCSprite sp11 = CCSprite.spriteWithFile(TestResource.s_pPathSister1);

            CCSprite sp2  = CCSprite.spriteWithFile(TestResource.s_pPathSister2);
            CCSprite sp21 = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

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

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

            CCAction forever2  = (CCAction)(forever1.copy());
            CCAction forever21 = (CCAction)(forever1.copy());

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

            sp1.runAction(forever1);
            sp11.runAction(forever11);
            sp2.runAction(forever2);
            sp21.runAction(forever21);

            schedule(new SEL_SCHEDULE(this.addAndRemove), 2.0f);
        }
        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);
        }
        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));
        }
        public CCSprite makeSpriteZ(int aZ)
        {
            CCSprite sprite = CCSprite.spriteWithBatchNode(batchNode, new CCRect(128, 0, 64, 64));

            batchNode.addChild(sprite, aZ + 1, 0);

            //children
            CCSprite spriteShadow = CCSprite.spriteWithBatchNode(batchNode, new CCRect(0, 0, 64, 64));

            spriteShadow.Opacity = 128;
            sprite.addChild(spriteShadow, aZ, 3);

            CCSprite spriteTop = CCSprite.spriteWithBatchNode(batchNode, new CCRect(64, 0, 64, 64));

            sprite.addChild(spriteTop, aZ + 2, 3);

            return(sprite);
        }
Example #7
0
        public override void onEnter()
        {
            base.onEnter();

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

            CCSprite sp1 = CCSprite.spriteWithFile(TestResource.s_pPathSister1);
            CCSprite sp2 = CCSprite.spriteWithFile(TestResource.s_pPathSister2);
            CCSprite sp3 = CCSprite.spriteWithFile(TestResource.s_pPathSister1);
            CCSprite sp4 = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

            sp1.position = (new CCPoint(100, s.height / 2));
            sp2.position = (new CCPoint(380, s.height / 2));
            addChild(sp1);
            addChild(sp2);

            sp3.scale = (0.25f);
            sp4.scale = (0.25f);

            sp1.addChild(sp3);
            sp2.addChild(sp4);

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

            CCAction action1 = CCRepeatForever.actionWithAction(
                (CCActionInterval)(CCSequence.actions(a1, a2, a2.reverse()))
                );
            CCAction action2 = CCRepeatForever.actionWithAction(
                (CCActionInterval)(CCSequence.actions(
                                       (CCActionInterval)(a1.copy()),
                                       (CCActionInterval)(a2.copy()),
                                       a2.reverse()))
                );

            sp2.anchorPoint = (new CCPoint(0, 0));

            sp1.runAction(action1);
            sp2.runAction(action2);
        }
        public SpriteBatchNodeChildren()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // parents
            CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini", 50);

            addChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini");

            CCSprite sprite1 = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");

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

            CCSprite sprite2 = CCSprite.spriteWithSpriteFrameName("grossini_dance_02.png");

            sprite2.position = (new CCPoint(50, 50));

            CCSprite sprite3 = CCSprite.spriteWithSpriteFrameName("grossini_dance_03.png");

            sprite3.position = (new CCPoint(-50, -50));

            batch.addChild(sprite1);
            sprite1.addChild(sprite2);
            sprite1.addChild(sprite3);

            // BEGIN NEW CODE
            List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>();
            string str = "";

            for (int i = 1; i < 15; i++)
            {
                string temp = "";
                if (i < 10)
                {
                    temp = "0" + i;
                }
                else
                {
                    temp = i.ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str);
                animFrames.Add(frame);
            }

            CCAnimation animation = CCAnimation.animationWithFrames(animFrames, 0.2f);

            sprite1.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithAnimation(animation, false)));
            // END NEW CODE

            CCActionInterval action        = CCMoveBy.actionWithDuration(2, new CCPoint(200, 0));
            CCActionInterval action_back   = (CCActionInterval)action.reverse();
            CCActionInterval action_rot    = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval action_s      = CCScaleBy.actionWithDuration(2, 2);
            CCActionInterval action_s_back = (CCActionInterval)action_s.reverse();

            CCActionInterval seq2 = (CCActionInterval)action_rot.reverse();

            sprite2.runAction(CCRepeatForever.actionWithAction(seq2));

            sprite1.runAction((CCAction)(CCRepeatForever.actionWithAction(action_rot)));
            sprite1.runAction((CCAction)(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back)))));
            sprite1.runAction((CCAction)(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action_s, action_s_back)))));
        }
Example #9
0
        public SpriteBatchNodeChildren2()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // parents
            CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini", 50);

            batch.Texture.generateMipmap();

            addChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini");


            CCSprite sprite11 = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");

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

            CCSprite sprite12 = CCSprite.spriteWithSpriteFrameName("grossini_dance_02.png");

            sprite12.position = (new CCPoint(20, 30));
            sprite12.scale    = 0.2f;

            CCSprite sprite13 = CCSprite.spriteWithSpriteFrameName("grossini_dance_03.png");

            sprite13.position = (new CCPoint(-20, 30));
            sprite13.scale    = 0.2f;

            batch.addChild(sprite11);
            sprite11.addChild(sprite12, -2);
            sprite11.addChild(sprite13, 2);

            // don't rotate with it's parent
            sprite12.honorParentTransform = ((ccHonorParentTransform)(sprite12.honorParentTransform & ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_TRANSLATE));

            // don't scale and rotate with it's parent
            sprite13.honorParentTransform = ((ccHonorParentTransform)(sprite13.honorParentTransform & (ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_SCALE | ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_ROTATE)));

            CCActionInterval action        = CCMoveBy.actionWithDuration(2, new CCPoint(200, 0));
            CCActionInterval action_back   = (CCActionInterval)action.reverse();
            CCActionInterval action_rot    = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval action_s      = CCScaleBy.actionWithDuration(2, 2);
            CCActionInterval action_s_back = (CCActionInterval)action_s.reverse();

            sprite11.runAction(CCRepeatForever.actionWithAction(action_rot));
            sprite11.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back))));
            sprite11.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action_s, action_s_back))));

            //
            // another set of parent / children
            //

            CCSprite sprite21 = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");

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

            CCSprite sprite22 = CCSprite.spriteWithSpriteFrameName("grossini_dance_02.png");

            sprite22.position = (new CCPoint(20, 30));
            sprite22.scale    = 0.8f;

            CCSprite sprite23 = CCSprite.spriteWithSpriteFrameName("grossini_dance_03.png");

            sprite23.position = (new CCPoint(-20, 30));
            sprite23.scale    = 0.8f;

            batch.addChild(sprite21);
            sprite21.addChild(sprite22, -2);
            sprite21.addChild(sprite23, 2);

            // don't rotate with it's parent
            sprite22.honorParentTransform = ((ccHonorParentTransform)(sprite22.honorParentTransform & ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_TRANSLATE));

            // don't scale and rotate with it's parent
            sprite23.honorParentTransform = ((ccHonorParentTransform)(sprite23.honorParentTransform & ccHonorParentTransform.CC_HONOR_PARENT_TRANSFORM_SCALE));

            sprite21.runAction(CCRepeatForever.actionWithAction(CCRotateBy.actionWithDuration(1, 360)));
            sprite21.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(CCScaleTo.actionWithDuration(0.5f, 5.0f), CCScaleTo.actionWithDuration(0.5f, 1)))));
        }