Ejemplo n.º 1
0
        public override void ccTouchesEnded(List <CCTouch> touches, CCEvent event_)
        {
            //base.ccTouchesEnded(touches, event_);
            object  it    = touches.First();
            CCTouch touch = (CCTouch)(it);

            CCPoint location          = touch.locationInView(touch.view());
            CCPoint convertedLocation = CCDirector.sharedDirector().convertToGL(location);

            CCNode s = getChildByTag(ClickAndMoveTest.kTagSprite);

            s.stopAllActions();
            s.runAction(CCMoveTo.actionWithDuration(1, new CCPoint(convertedLocation.x, convertedLocation.y)));
            float o  = convertedLocation.x - s.position.x;
            float a  = convertedLocation.y - s.position.y;
            float at = (float)(Math.Atan(o / a) * 57.29577951f);

            if (a < 0)
            {
                if (o < 0)
                {
                    at = 180 + Math.Abs(at);
                }
                else
                {
                    at = 180 - Math.Abs(at);
                }
            }

            s.runAction(CCRotateTo.actionWithDuration(1, at));
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public override void onEnter()
        {
            base.onEnter();

            CCNode target = getChildByTag(EffectAdvanceScene.kTagBackground);

            // To reuse a grid the grid size and the grid type must be the same.
            // in this case:
            //     ShakyTiles is TiledGrid3D and it's size is (15,10)
            //     Shuffletiles is TiledGrid3D and it's size is (15,10)
            //	   TurnOfftiles is TiledGrid3D and it's size is (15,10)
            CCActionInterval   shaky   = CCShakyTiles3D.actionWithRange(4, false, new ccGridSize(15, 10), 5);
            CCActionInterval   shuffle = CCShuffleTiles.actionWithSeed(0, new ccGridSize(15, 10), 3);
            CCActionInterval   turnoff = CCTurnOffTiles.actionWithSeed(0, new ccGridSize(15, 10), 3);
            CCFiniteTimeAction turnon  = turnoff.reverse();

            // reuse 2 times:
            //   1 for shuffle
            //   2 for turn off
            //   turnon tiles will use a new grid
            CCFiniteTimeAction reuse = CCReuseGrid.actionWithTimes(2);

            CCActionInterval delay = CCDelayTime.actionWithDuration(1);

            //	id orbit = [OrbitCamera::actionWithDuration:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90];
            //	id orbit_back = [orbit reverse];
            //
            //	[target runAction: [RepeatForever::actionWithAction: [Sequence actions: orbit, orbit_back, nil]]];
            target.runAction((CCActionInterval)(CCSequence.actions(shaky, delay, reuse, shuffle, delay, turnoff, turnon)));
        }
Ejemplo n.º 4
0
        public override void onEnter()
        {
            base.onEnter();

            CCNode target = getChildByTag(EffectAdvanceScene.kTagBackground);

            // To reuse a grid the grid size and the grid type must be the same.
            // in this case:
            //     Lens3D is Grid3D and it's size is (15,10)
            //     Waves3D is Grid3D and it's size is (15,10)

            CCSize           size  = CCDirector.sharedDirector().getWinSize();
            CCActionInterval lens  = CCLens3D.actionWithPosition(new CCPoint(size.width / 2, size.height / 2), 240, new ccGridSize(15, 10), 0.0f);
            CCActionInterval waves = CCWaves3D.actionWithWaves(18, 15, new ccGridSize(15, 10), 10);

            CCFiniteTimeAction reuse = CCReuseGrid.actionWithTimes(1);
            CCActionInterval   delay = CCDelayTime.actionWithDuration(8);

            CCActionInterval   orbit      = CCOrbitCamera.actionWithDuration(5, 1, 2, 0, 180, 0, -90);
            CCFiniteTimeAction orbit_back = orbit.reverse();

            target.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(orbit, orbit_back))));
            target.runAction(CCSequence.actions(lens, delay, reuse, waves));
        }
Ejemplo n.º 5
0
        public MenuLayer3()
        {
            CCMenuItemFont.FontName = "Arial";
            CCMenuItemFont.FontSize = 28;

            CCLabelBMFont   label = CCLabelBMFont.labelWithString("Enable AtlasItem", "fonts/fnt/bitmapFontTest3");
            CCMenuItemLabel item1 = CCMenuItemLabel.itemWithLabel(label, this, this.menuCallback2);
            CCMenuItemFont  item2 = CCMenuItemFont.itemFromString("--- Go Back ---", this, this.menuCallback);

            m_item2 = item2;
            m_item1 = item1;
            CCSprite spriteNormal   = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            CCSprite spriteSelected = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = CCSprite.spriteWithFile(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


            CCMenuItemSprite item3 = CCMenuItemSprite.itemFromNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, this.menuCallback3);

            m_disabledItem         = item3;
            m_disabledItem.Enabled = false;
            m_item3 = item3;

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

            menu.position = new CCPoint(0, 0);

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

            m_item1.position = new CCPoint(s.width / 2 - 150, s.height / 2);
            m_item2.position = new CCPoint(s.width / 2 - 200, s.height / 2);
            m_item3.position = new CCPoint(s.width / 2, s.height / 2 - 100);
            CCJumpBy         jump  = CCJumpBy.actionWithDuration(3, new CCPoint(400, 0), 50, 4);
            CCActionInterval spin1 = CCRotateBy.actionWithDuration(3, 360);
            CCActionInterval spin2 = (CCActionInterval)(spin1.copy());
            CCActionInterval spin3 = (CCActionInterval)(spin1.copy());

            m_item1.runAction(CCRepeatForever.actionWithAction(spin1));
            m_item2.runAction(CCRepeatForever.actionWithAction(
                                  (CCActionInterval)(CCSequence.actions(jump, jump.reverse()))
                                  )
                              );
            m_item2.runAction(CCRepeatForever.actionWithAction(spin2)); // Augments the jump
            m_item3.runAction(CCRepeatForever.actionWithAction(spin3));
        }
Ejemplo n.º 6
0
        public override void onEnter()
        {
            base.onEnter();

            CCNode bg      = getChildByTag(EffectAdvanceScene.kTagBackground);
            CCNode target1 = bg.getChildByTag(EffectAdvanceScene.kTagSprite1);
            CCNode target2 = bg.getChildByTag(EffectAdvanceScene.kTagSprite2);

            CCActionInterval waves = CCWaves.actionWithWaves(5, 20, true, false, new ccGridSize(15, 10), 5);
            CCActionInterval shaky = CCShaky3D.actionWithRange(4, false, new ccGridSize(15, 10), 5);

            target1.runAction(CCRepeatForever.actionWithAction(waves));
            target2.runAction(CCRepeatForever.actionWithAction(shaky));

            //// moving background. Testing issue #244
            //CCActionInterval move = CCMoveBy.actionWithDuration(3, new CCPoint(200, 0));
            //bg.runAction(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(move))));
        }
Ejemplo n.º 7
0
        public SpriteZVertex()
        {
            //
            // This test tests z-order
            // If you are going to use it is better to use a 3D projection
            //
            // WARNING:
            // The developer is resposible for ordering it's sprites according to it's Z if the sprite has
            // transparent parts.
            //

            m_dir  = 1;
            m_time = 0;

            CCSize s    = CCDirector.sharedDirector().getWinSize();
            float  step = s.width / 12;

            CCNode node = CCNode.node();

            // camera uses the center of the image as the pivoting point
            node.contentSize = (new CCSize(s.width, s.height));
            node.anchorPoint = (new CCPoint(0.5f, 0.5f));
            node.position    = (new CCPoint(s.width / 2, s.height / 2));

            addChild(node, 0);

            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));
                sprite.vertexZ  = (10 + i * 40);
                node.addChild(sprite, 0);
            }

            for (int i = 5; i < 11; 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));
                sprite.vertexZ  = 10 + (10 - i) * 40;
                node.addChild(sprite, 0);
            }

            node.runAction(CCOrbitCamera.actionWithDuration(10, 1, 0, 0, 360, 0, 0));
        }
Ejemplo n.º 8
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()));
        }
Ejemplo n.º 9
0
        public override void onEnter()
        {
            base.onEnter();

            //CCDirector::sharedDirector()->setProjection(CCDirectorProjection2D);

            CCActionInterval effect = CCLiquid.actionWithWaves(1, 20, new ccGridSize(32, 24), 2);

            CCActionInterval stopEffect = (CCActionInterval)(CCSequence.actions(
                                                                 effect,
                                                                 CCDelayTime.actionWithDuration(2),
                                                                 CCStopGrid.action()
                                                                 //					 [DelayTime::actionWithDuration:2],
                                                                 //					 [[effect copy] autorelease],
                                                                 ));

            CCNode bg = getChildByTag(EffectAdvanceScene.kTagBackground);

            bg.runAction(stopEffect);
        }
Ejemplo n.º 10
0
 public void bugMe(CCNode node)
 {
     node.stopAllActions(); //After this stop next action not working, if remove this stop everything is working
     node.runAction(CCScaleTo.actionWithDuration(2, 2));
 }
Ejemplo n.º 11
0
        public void repeatForever(CCNode pSender)
        {
            CCRepeatForever repeat = CCRepeatForever.actionWithAction(CCRotateBy.actionWithDuration(1.0f, 360));

            pSender.runAction(repeat);
        }
Ejemplo n.º 12
0
        public TextLayer()
        {
            initWithColor(ccTypes.ccc4(32, 32, 32, 255));

            float x, y;

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

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

            CCNode           node   = CCNode.node();
            CCActionInterval effect = getAction();

            node.runAction(effect);
            addChild(node, 0, EffectTestScene.kTagBackground);

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

            node.addChild(bg, 0);
            bg.anchorPoint = new CCPoint(0.5f, 0.5f);
            bg.position    = new CCPoint(size.width / 2, size.height / 2);

            CCSprite grossini = CCSprite.spriteWithFile(TestResource.s_pPathSister2);

            node.addChild(grossini, 1);
            grossini.position = new CCPoint(x / 3, y / 2);
            CCActionInterval   sc      = CCScaleBy.actionWithDuration(2, 5);
            CCFiniteTimeAction sc_back = sc.reverse();

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

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

            node.addChild(tamara, 1);
            tamara.position = new CCPoint(2 * x / 3, y / 2);
            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(EffectTestScene.effectsList[EffectTestScene.actionIdx], "Arial", 32);

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

            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  = 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);

            schedule(checkAnim);
        }