public static CCRotateBy actionWithDuration(float duration, float fDeltaAngle)
        {
            CCRotateBy ret = new CCRotateBy();
            ret.initWithDuration(duration, fDeltaAngle);

            return ret;
        }
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone tmpZone = zone;
            CCRotateBy ret = null;

            if (tmpZone != null && tmpZone.m_pCopyObject != null)
            {
                ret = tmpZone.m_pCopyObject as CCRotateBy;
                if (ret == null)
                {
                    return null;
                }
            }
            else
            {
                ret = new CCRotateBy();
                tmpZone = new CCZone(ret);
            }

            base.copyWithZone(tmpZone);

            ret.initWithDuration(m_fDuration, m_fAngle);

            return ret;
        }
Beispiel #3
0
        public Layer3()
            : base(new ccColor4B (0,0,255,255))
        {
            CGSize s = CCDirector.SharedDirector ().WinSize ();
            CCMenuItemFont item0 = new CCMenuItemFont("Touch to pushScene (self)", delegate {
                CCScene newScene = new CCScene();
                newScene.AddChild (new Layer3 ());
                CCDirector.SharedDirector ().PushScene (new CCTransitionFade (0.5f, newScene, new ccColor3B (0, 255, 255)));
            });

            CCMenuItemFont item1 = new CCMenuItemFont("Touch to popScene", delegate {
                CCDirector.SharedDirector ().PopScene ();
            });

            CCMenuItemFont item2 = new CCMenuItemFont("Touch to popToRootScene", delegate {
                CCDirector.SharedDirector ().PopToRootScene ();
            });

            CCMenu menu = new CCMenu(item0, item1, item2);
            this.AddChild (menu);
            menu.AlignItemsVertically ();

            CCSprite sprite = new CCSprite("grossini.png", true);
            this.AddChild (sprite);
            sprite.Position = new CCPoint(s.Width / 2, 40);
            var rotate = new CCRotateBy (2, 360);
            var repeat = new CCRepeatForever (rotate);
            sprite.RunAction (repeat);
        }
Beispiel #4
0
        public CCRotateByState (CCRotateBy action, CCNode target)
            : base (action, target)
        { 
            AngleX = action.AngleX;
            AngleY = action.AngleY;
            StartAngleX = target.RotationX;
            StartAngleY = target.RotationY;

        }
Beispiel #5
0
        public override void OnEnter()
        {
            base.OnEnter();

            m_pInnerLayer.ChildClippingMode = CCClipMode.BoundsWithRenderTarget;

            var rotateBy = new CCRotateBy(3, 90);

            m_pInnerLayer.RunAction(new CCRepeatForever(rotateBy));
        }
Beispiel #6
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");

            AddChild(label);

            CCSize s = CCDirector.SharedDirector.WinSize;

            label.Position    = new CCPoint(s.Width / 2, s.Height / 2);
            label.AnchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.GetChildByTag(0);
            CCSprite FChar = (CCSprite)label.GetChildByTag(7);
            CCSprite AChar = (CCSprite)label.GetChildByTag(12);


            CCActionInterval rotate    = new CCRotateBy(2, 360);
            CCAction         rot_4ever = new CCRepeatForever(rotate);

            CCActionInterval   scale       = new CCScaleBy(2, 1.5f);
            CCFiniteTimeAction scale_back  = scale.Reverse();
            CCFiniteTimeAction scale_seq   = new CCSequence(scale, scale_back);
            CCAction           scale_4ever = new CCRepeatForever((CCActionInterval)scale_seq);

            CCActionInterval jump       = new CCJumpBy(0.5f, new CCPoint(), 60, 1);
            CCAction         jump_4ever = new CCRepeatForever(jump);

            CCActionInterval   fade_out   = new CCFadeOut(1);
            CCActionInterval   fade_in    = new CCFadeIn(1);
            CCFiniteTimeAction seq        = new CCSequence(fade_out, fade_in);
            CCAction           fade_4ever = new CCRepeatForever((CCActionInterval)seq);

            BChar.RunAction(rot_4ever);
            BChar.RunAction(scale_4ever);
            FChar.RunAction(jump_4ever);
            AChar.RunAction(fade_4ever);


            // Bottom Label
            CCLabelBMFont label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");

            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.Position = new CCPoint(s.Width / 2.0f, 80);

            CCSprite lastChar = (CCSprite)label2.GetChildByTag(3);

            lastChar.RunAction((CCAction)(rot_4ever.Copy()));

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
        public SpriteBatchNodeChildrenChildren()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/ghosts.plist");

            var rot = new CCRotateBy(10, 360);

            seq = new CCRepeatForever(rot);

            var rot_back = rot.Reverse();

            rot_back_fe = new CCRepeatForever(rot_back);

            // SpriteBatchNode: 3 levels of children

            aParent = new CCSpriteBatchNode("animations/ghosts");
            AddChild(aParent);

            // parent
            l1 = new CCSprite("father.gif");
            aParent.AddChild(l1);


            // child left
            l2a = new CCSprite("sister1.gif");

            l1.AddChild(l2a);

            // child right
            l2b = new CCSprite("sister2.gif");

            l1.AddChild(l2b);


            // child left bottom
            l3a1       = new CCSprite("child1.gif");
            l3a1.Scale = 0.45f;
            l2a.AddChild(l3a1);

            // child left top
            l3a2       = new CCSprite("child1.gif");
            l3a2.Scale = 0.45f;
            l2a.AddChild(l3a2);

            // child right bottom
            l3b1       = new CCSprite("child1.gif");
            l3b1.Scale = 0.45f;
            l3b1.FlipY = true;
            l2b.AddChild(l3b1);

            // child right top
            l3b2       = new CCSprite("child1.gif");
            l3b2.Scale = 0.45f;
            l3b2.FlipY = true;
            l2b.AddChild(l3b2);
        }
        public SpriteHybrid()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // parents
            CCNode            parent1 = CCNode.node();
            CCSpriteBatchNode parent2 = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini", 50);

            addChild(parent1, 0, (int)kTags.kTagNode);
            addChild(parent2, 0, (int)kTags.kTagSpriteBatchNode);


            // IMPORTANT:
            // The sprite frames will be cached AND RETAINED, and they won't be released unless you call
            //     CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames);
            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini");


            // create 250 sprites
            // only show 80% of them
            for (int i = 0; i < 250; i++)
            {
                int    spriteIdx = (int)(rand.NextDouble() * 14);
                string str       = "";
                string temp      = "";
                if (spriteIdx + 1 < 10)
                {
                    temp = "0" + (spriteIdx + 1);
                }
                else
                {
                    temp = (spriteIdx + 1).ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame  = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str);
                CCSprite      sprite = CCSprite.spriteWithSpriteFrame(frame);
                parent1.addChild(sprite, i, i);

                float x = -1000;
                float y = -1000;
                if (rand.NextDouble() < 0.2f)
                {
                    x = (float)(rand.NextDouble() * s.width);
                    y = (float)(rand.NextDouble() * s.height);
                }
                sprite.position = (new CCPoint(x, y));

                CCActionInterval action = CCRotateBy.actionWithDuration(4, 360);
                sprite.runAction(CCRepeatForever.actionWithAction(action));
            }

            m_usingSpriteBatchNode = false;

            schedule(reparentSprite, 2);
        }
Beispiel #9
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(2f, 3f, 32f, new ccColor3B(0, 255, 0), s_streak);
            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);
            CCActionInterval colorAction = CCRepeatForever.actionWithAction((CCActionInterval)CCSequence.actions(
                                                                                CCTintTo.actionWithDuration(0.2f, 255, 0, 0),
                                                                                CCTintTo.actionWithDuration(0.2f, 0, 255, 0),
                                                                                CCTintTo.actionWithDuration(0.2f, 0, 0, 255),
                                                                                CCTintTo.actionWithDuration(0.2f, 0, 255, 255),
                                                                                CCTintTo.actionWithDuration(0.2f, 255, 255, 0),
                                                                                CCTintTo.actionWithDuration(0.2f, 255, 0, 255),
                                                                                CCTintTo.actionWithDuration(0.2f, 255, 255, 255)
                                                                                ));

            m_streak.runAction(colorAction);

            /*
             * CCActionInterval *colorAction = CCRepeatForever::create((CCActionInterval *)CCSequence::create(
             * CCTintTo::create(0.2f, 255, 0, 0),
             * CCTintTo::create(0.2f, 0, 255, 0),
             * CCTintTo::create(0.2f, 0, 0, 255),
             * CCTintTo::create(0.2f, 0, 255, 255),
             * CCTintTo::create(0.2f, 255, 255, 0),
             * CCTintTo::create(0.2f, 255, 0, 255),
             * CCTintTo::create(0.2f, 255, 255, 255),
             * NULL));
             *
             * streak->runAction(colorAction);
             */
        }
Beispiel #10
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            CCLabelBMFont label = CCLabelBMFont.labelWithString("Bitmap Font Atlas", "fonts/fnt/bitmapFontTest");

            addChild(label);

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

            label.position    = new CCPoint(s.width / 2, s.height / 2);
            label.anchorPoint = new CCPoint(0.5f, 0.5f);


            CCSprite BChar = (CCSprite)label.getChildByTag(0);
            CCSprite FChar = (CCSprite)label.getChildByTag(7);
            CCSprite AChar = (CCSprite)label.getChildByTag(12);


            CCActionInterval rotate    = CCRotateBy.actionWithDuration(2, 360);
            CCAction         rot_4ever = CCRepeatForever.actionWithAction(rotate);

            CCActionInterval   scale       = CCScaleBy.actionWithDuration(2, 1.5f);
            CCFiniteTimeAction scale_back  = scale.reverse();
            CCFiniteTimeAction scale_seq   = CCSequence.actions(scale, scale_back);
            CCAction           scale_4ever = CCRepeatForever.actionWithAction((CCActionInterval)scale_seq);

            CCActionInterval jump       = CCJumpBy.actionWithDuration(0.5f, new CCPoint(), 60, 1);
            CCAction         jump_4ever = CCRepeatForever.actionWithAction(jump);

            CCActionInterval   fade_out   = CCFadeOut.actionWithDuration(1);
            CCActionInterval   fade_in    = CCFadeIn.actionWithDuration(1);
            CCFiniteTimeAction seq        = CCSequence.actions(fade_out, fade_in);
            CCAction           fade_4ever = CCRepeatForever.actionWithAction((CCActionInterval)seq);

            BChar.runAction(rot_4ever);
            BChar.runAction(scale_4ever);
            FChar.runAction(jump_4ever);
            AChar.runAction(fade_4ever);


            // Bottom Label
            CCLabelBMFont label2 = CCLabelBMFont.labelWithString("00.0", "fonts/fnt/bitmapFontTest");

            addChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.position = new CCPoint(s.width / 2.0f, 80);

            CCSprite lastChar = (CCSprite)label2.getChildByTag(3);

            lastChar.runAction((CCAction)(rot_4ever.copy()));

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.schedule(step, 0.1f);
        }
Beispiel #11
0
        public override void onEnter()
        {
            base.onEnter();

            alignSpritesLeft(1);

            CCFiniteTimeAction action = CCSequence.actions(
                CCMoveBy.actionWithDuration(2, new CCPoint(240, 0)),
                CCRotateBy.actionWithDuration(2, 540));

            m_grossini.runAction(action);
        }
Beispiel #12
0
        public override void onEnter()
        {
            base.onEnter();

            alignSpritesLeft(1);

            CCAction action = CCSpawn.actions(
                CCJumpBy.actionWithDuration(2, new CCPoint(300, 0), 50, 4),
                CCRotateBy.actionWithDuration(2, 720));

            m_grossini.runAction(action);
        }
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var winSize = VisibleBoundsWorldspace.Size;

            var moveTo   = new CCMoveBy(1.0f, new CCPoint(30, 0));
            var moveBack = moveTo.Reverse();
            var rotateBy = new CCRotateBy(1.0f, 180);
            var scaleBy  = new CCScaleTo(1.0f, -2.0f);
            var action   = new CCSequence(moveTo, moveBack, rotateBy, scaleBy);

            var buttonNormal = new CCSprite("Images/animationbuttonnormal.png");
            var button1      = new Button(buttonNormal,
                                          new CCLabel("Click", "fonts/arial", 20, CCLabelFormat.SpriteFont));

            button1.Position   = winSize.Center;
            button1.PositionX -= 100;
            button1.PositionY += 100;

            AddChild(button1);
            button1.RunAction(action);

            var button2 = new Button(buttonNormal,
                                     new CCLabel("Me", "fonts/arial", 20, CCLabelFormat.SpriteFont));

            button2.Position   = winSize.Center;
            button2.PositionX += 100;
            button2.PositionY += 100;

            AddChild(button2);
            button2.RunAction(action);

            var button3 = new Button(buttonNormal,
                                     new CCLabel("Ple", "fonts/arial", 20, CCLabelFormat.SpriteFont));

            button3.Position   = winSize.Center;
            button3.PositionX -= 100;
            button3.PositionY -= 100;

            AddChild(button3);
            button3.RunAction(action);

            var button4 = new Button(buttonNormal,
                                     new CCLabel("ase", "fonts/arial", 20, CCLabelFormat.SpriteFont));

            button4.Position   = winSize.Center;
            button4.PositionX += 100;
            button4.PositionY -= 100;

            AddChild(button4);
            button4.RunAction(action);
        }
Beispiel #14
0
        public static void AddJiggle(CCNode targetSprite)
        {
            var swingTime = CCRandom.Next(10, 31) / 100f;

            var rotateLeftAction  = new CCRotateBy(swingTime, 1);
            var rotateRightAction = new CCRotateBy(swingTime * 2, -2);
            var rotateBackAction  = new CCRotateBy(swingTime, 1);

            var rotateSequence = new CCSequence(rotateLeftAction, rotateRightAction, rotateBackAction);
            var repeatAction   = new CCRepeatForever(rotateSequence);

            targetSprite.RunAction(repeatAction);
        }
Beispiel #15
0
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = new CCTMXTiledMap("TileMaps/orthogonal-test2");

            AddChild(map, 0, kTagTileMap);

            CCTMXLayer layer = map.LayerNamed("Layer 0");

            layer.IsAntialiased = true;

            map.Scale = (1);

            CCSprite tile0 = layer.TileAt(new CCPoint(1, 63));
            CCSprite tile1 = layer.TileAt(new CCPoint(2, 63));
            CCSprite tile2 = layer.TileAt(new CCPoint(3, 62)); //new CCPoint(1,62));
            CCSprite tile3 = layer.TileAt(new CCPoint(2, 62));

            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy    move      = new CCMoveBy(0.5f, new CCPoint(0, 160));
            CCRotateBy  rotate    = new CCRotateBy(2, 360);
            CCScaleBy   scale     = new CCScaleBy(2, 5);
            CCFadeOut   opacity   = new CCFadeOut(2);
            CCFadeIn    fadein    = new CCFadeIn(2);
            CCScaleTo   scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish    = new CCCallFuncN(removeSprite);
            CCSequence  sequence  = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

            tile0.RunAction(sequence);
            tile1.RunAction(sequence);
            tile2.RunAction(sequence);
            tile3.RunAction(sequence);


            m_gid = layer.TileGIDAt(new CCPoint(0, 63));
            ////----UXLOG("Tile GID at:(0,63) is: %d", m_gid);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);

            ////----UXLOG("++++atlas quantity: %d", layer.textureAtlas().getTotalQuads());
            ////----UXLOG("++++children: %d", layer.getChildren().count() );

            m_gid2 = 0;
        }
        public SpriteBatchNodeChildrenScale()
        {
            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("animations/grossini_family.plist");

            var rot = new CCRotateBy(10, 360);

            seq = new CCRepeatForever(rot);

            // Children + Scale using Sprite
            // Test 1
            aParent = new CCNode();
            sprite1 = new CCSprite("grossinis_sister1.png");
            sprite2 = new CCSprite("grossinis_sister2.png");

            AddChild(aParent);
            aParent.AddChild(sprite1);
            sprite1.AddChild(sprite2);

            // Children + Scale using SpriteBatchNode
            // Test 2
            aParent2         = new CCSpriteBatchNode("animations/grossini_family");
            sprite3          = new CCSprite("grossinis_sister1.png");
            sprite4          = new CCSprite("grossinis_sister2.png");
            sprite4.Position = (new CCPoint(50, 0));

            AddChild(aParent2);
            aParent2.AddChild(sprite3);
            sprite3.AddChild(sprite4);

            // Children + Scale using Sprite
            // Test 3
            aParent3 = new CCNode();
            sprite5  = new CCSprite("grossinis_sister1.png");
            sprite6  = new CCSprite("grossinis_sister2.png");

            AddChild(aParent3);
            aParent3.AddChild(sprite5);
            sprite5.AddChild(sprite6);

            // Children + Scale using Sprite
            // Test 4
            aParent4 = new CCSpriteBatchNode("animations/grossini_family");
            sprite7  = new CCSprite("grossinis_sister1.png");
            sprite8  = new CCSprite("grossinis_sister2.png");

            AddChild(aParent4);
            aParent4.AddChild(sprite7);
            sprite7.AddChild(sprite8);
        }
Beispiel #17
0
        public Atlas4()
        {
            m_time = 0;

            // Upper Label
            label = new CCLabelBMFont("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt");
            AddChild(label);

            label.AnchorPoint = CCPoint.AnchorMiddle;


            var BChar = (CCSprite)label[0];
            var FChar = (CCSprite)label[7];
            var AChar = (CCSprite)label[12];


            var rotate    = new CCRotateBy(2, 360);
            var rot_4ever = new CCRepeatForever(rotate);

            var scale       = new CCScaleBy(2, 1.5f);
            var scale_back  = scale.Reverse();
            var scale_seq   = new CCSequence(scale, scale_back);
            var scale_4ever = new CCRepeatForever(scale_seq);

            var jump       = new CCJumpBy(0.5f, new CCPoint(), 60, 1);
            var jump_4ever = new CCRepeatForever(jump);

            var fade_out   = new CCFadeOut(1);
            var fade_in    = new CCFadeIn(1);
            var seq        = new CCSequence(fade_out, fade_in);
            var fade_4ever = new CCRepeatForever(seq);

            BChar.RunAction(rot_4ever);
            BChar.RunAction(scale_4ever);
            FChar.RunAction(jump_4ever);
            AChar.RunAction(fade_4ever);


            // Bottom Label
            label2 = new CCLabelBMFont("00.0", "fonts/bitmapFontTest.fnt");
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);

            var lastChar = (CCSprite)label2[3];

            lastChar.RunAction(rot_4ever);

            //schedule( schedule_selector(Atlas4::step), 0.1f);
            base.Schedule(step, 0.1f);
        }
Beispiel #18
0
        void AddNewSprite()
        {
            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            CCPoint p = new CCPoint((float)(CCRandom.NextDouble() * s.Width), (float)(CCRandom.NextDouble() * s.Height));

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x   = (idx % 5) * 85;
            int y   = (idx / 5) * 121;


            CCNode   node   = GetChildByTag((int)kTags.kTagSpriteBatchNode);
            CCSprite sprite = new CCSprite(texture1, new CCRect(x, y, 85, 121));

            node.AddChild(sprite);

            sprite.Position = (new CCPoint(p.X, p.Y));

            CCFiniteTimeAction action;
            float random = (float)CCRandom.NextDouble();

            if (random < 0.20)
            {
                action = new CCScaleBy(3, 2);
            }
            else if (random < 0.40)
            {
                action = new CCRotateBy(3, 360);
            }
            else if (random < 0.60)
            {
                action = new CCBlink(1, 3);
            }
            else if (random < 0.8)
            {
                action = new CCTintBy(2, 0, -255, -255);
            }
            else
            {
                action = new CCFadeOut(2);
            }

            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();
            CCFiniteTimeAction seq         = (CCFiniteTimeAction)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever(seq));
        }
Beispiel #19
0
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var label = new CCLabelBMFont("Enable AtlasItem", "fonts/bitmapFontTest3.fnt");
            var item1 = new CCMenuItemLabelBMFont(label, this.menuCallback2);

            CCMenuItemFont.FontSize = 28;
            CCMenuItemFont.FontName = "arial";

            var item2 = new CCMenuItemFont("--- Go Back ---", this.menuCallback);

            // We do not have an HD version of the menuitemsprite so internally CocosSharp tries to convert our
            // rectangle coordinates passed to work with HD images so the coordinates are off.  We will just
            // modify this here to make sure we have the correct sizes when they are passed.
            var spriteNormal   = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            var spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            var spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


            var item3 = new CCMenuItemImage(spriteNormal, spriteSelected, spriteDisabled, this.menuCallback3);

            m_disabledItem         = item3;
            m_disabledItem.Enabled = false;

            var menu = new CCMenu(item1, item2, item3);

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

            var s = Layer.VisibleBoundsWorldspace.Size;

            item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2);
            item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2);
            item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100);

            var jump = new CCJumpBy(3, new CCPoint(400, 0), 50, 4);

            item2.RepeatForever(jump, jump.Reverse());

            var spin1 = new CCRotateBy(3, 360);

            item1.RepeatForever(spin1);
            item2.RepeatForever(spin1);
            item3.RepeatForever(spin1);

            AddChild(menu);
        }
        public void addNewSprite()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCPoint p = new CCPoint((float)(CCRandom.NextDouble() * s.Width), (float)(CCRandom.NextDouble() * s.Height));

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x   = (idx % 5) * 85;
            int y   = (idx / 5) * 121;


            CCNode   node   = GetChildByTag((int)kTags.kTagSpriteBatchNode);
            CCSprite sprite = new CCSprite(m_texture1, new CCRect(x, y, 85, 121));

            node.AddChild(sprite);

            sprite.Position = (new CCPoint(p.X, p.Y));

            CCActionInterval action;
            float            random = (float)CCRandom.NextDouble();

            if (random < 0.20)
            {
                action = new CCScaleBy(3, 2);
            }
            else if (random < 0.40)
            {
                action = new CCRotateBy(3, 360);
            }
            else if (random < 0.60)
            {
                action = new CCBlink(1, 3);
            }
            else if (random < 0.8)
            {
                action = new CCTintBy(2, 0, -255, -255);
            }
            else
            {
                action = new CCFadeOut(2);
            }

            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval seq         = (CCActionInterval)(CCSequence.FromActions(action, action_back));

            sprite.RunAction(new CCRepeatForever(seq));
        }
Beispiel #21
0
        public void addNewSprite()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCPoint p = new CCPoint((float)(rand.NextDouble() * s.width), (float)(rand.NextDouble() * s.height));

            int idx = (int)(rand.NextDouble() * 1400 / 100);
            int x   = (idx % 5) * 85;
            int y   = (idx / 5) * 121;


            CCNode   node   = getChildByTag((int)kTags.kTagSpriteBatchNode);
            CCSprite sprite = CCSprite.spriteWithTexture(m_texture1, new CCRect(x, y, 85, 121));

            node.addChild(sprite);

            sprite.position = (new CCPoint(p.x, p.y));

            CCActionInterval action;
            float            random = (float)rand.NextDouble();

            if (random < 0.20)
            {
                action = CCScaleBy.actionWithDuration(3, 2);
            }
            else if (random < 0.40)
            {
                action = CCRotateBy.actionWithDuration(3, 360);
            }
            else if (random < 0.60)
            {
                action = CCBlink.actionWithDuration(1, 3);
            }
            else if (random < 0.8)
            {
                action = CCTintBy.actionWithDuration(2, 0, -255, -255);
            }
            else
            {
                action = CCFadeOut.actionWithDuration(2);
            }

            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCActionInterval seq         = (CCActionInterval)(CCSequence.actions(action, action_back));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
        }
        protected override void AddedToScene()
        {
            base.AddedToScene();

            var listener = new CCEventListenerTouchAllAtOnce();

            listener.OnTouchesEnded = onTouchesEnded;

            AddEventListener(listener);

            CCSize s = Layer.VisibleBoundsWorldspace.Size;

            var rotate = new CCRotateBy(10, 360);

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini");
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

                CCSprite point = new CCSprite("Images/r1");
                point.Scale    = 0.25f;
                point.Position = sprite.Position;
                AddChild(point, 10, 100 + i);

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = CCPoint.AnchorLowerLeft;
                    break;

                case 1:
                    sprite.AnchorPoint = CCPoint.AnchorMiddle;
                    break;

                case 2:
                    sprite.AnchorPoint = CCPoint.AnchorUpperRight;
                    break;
                }

                point.Position = sprite.Position;

                sprite.RepeatForever(rotate);

                AddChild(sprite, i);
            }
        }
        public SpriteBatchNodeAnchorPoint()
        {
            // small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("Images/grossini_dance_atlas", 1);

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

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


            CCActionInterval rotate = CCRotateBy.actionWithDuration(10, 360);
            CCAction         action = CCRepeatForever.actionWithAction(rotate);

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = CCSprite.spriteWithTexture(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2));

                CCSprite point = CCSprite.spriteWithFile("Images/r1");
                point.scale    = 0.25f;
                point.position = sprite.position;
                addChild(point, 1);

                switch (i)
                {
                case 0:
                    sprite.anchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.anchorPoint = (new CCPoint(0.5f, 0.5f));
                    break;

                case 2:
                    sprite.anchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.position = sprite.position;

                CCAction copy = (CCAction)(action.copy());
                sprite.runAction(copy);
                batch.addChild(sprite, i);
            }
        }
        public SpriteBatchNodeAnchorPoint()
        {
            // small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);

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

            CCSize s = CCDirector.SharedDirector.WinSize;


            CCActionInterval rotate = new CCRotateBy(10, 360);
            CCAction         action = new CCRepeatForever(rotate);

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

                CCSprite point = new CCSprite("Images/r1");
                point.Scale    = 0.25f;
                point.Position = sprite.Position;
                AddChild(point, 1);

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.AnchorPoint = (new CCPoint(0.5f, 0.5f));
                    break;

                case 2:
                    sprite.AnchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.Position = sprite.Position;

                CCAction copy = (CCAction)(action.Copy());
                sprite.RunAction(copy);
                batch.AddChild(sprite, i);
            }
        }
Beispiel #25
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));
        }
Beispiel #26
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            // the root object just rotates around
            m_root = new CCSprite(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 = new CCSprite(s_pPathR1);
            m_root.AddChild(m_target);
            m_target.Position = new CCPoint(s.Width / 4, 0);

            // create the streak object and add it to the scene
            streak          = CCMotionStreak.Create(2, 3, 32, CCTypes.CCGreen, s_streak);
            streak.FastMode = true;
            AddChild(streak);
            // schedule an update on each frame so we can syncronize the streak with the target
            Schedule(onUpdate);

            var a1 = new CCRotateBy(2, 360);

            var action1 = new CCRepeatForever(a1);
            var motion  = new CCMoveBy(2, new CCPoint(100, 0));

            m_root.RunAction(new CCRepeatForever((CCActionInterval) new CCSequence(motion, motion.Reverse())));
            m_root.RunAction(action1);

            var colorAction = new CCRepeatForever((CCActionInterval)
                                                  new CCSequence(
                                                      new CCTintTo(0.2f, 255, 0, 0),
                                                      new CCTintTo(0.2f, 0, 255, 0),
                                                      new CCTintTo(0.2f, 0, 0, 255),
                                                      new CCTintTo(0.2f, 0, 255, 255),
                                                      new CCTintTo(0.2f, 255, 255, 0),
                                                      new CCTintTo(0.2f, 255, 0, 255),
                                                      new CCTintTo(0.2f, 255, 255, 255)
                                                      )
                                                  );

            streak.RunAction(colorAction);
        }
Beispiel #27
0
        public Sprite6()
        {
            // SpriteBatchNode actions
            rotate = new CCRotateBy(5, 360);
            action = new CCRepeatForever(rotate);

            // SpriteBatchNode actions
            rotate_back = rotate.Reverse();

            scale      = new CCScaleBy(5, 1.5f);
            scale_back = scale.Reverse();

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite("Images/grossini_dance_atlas", new CCRect(85 * i, 121 * 1, 85, 121));
                AddChild(sprite, i);
            }
        }
Beispiel #28
0
        public SpriteBatchNodeAnchorPoint()
        {
            sprites      = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

            CCRotateBy rotate = new CCRotateBy(10, 360);

            action = new CCRepeatForever(rotate);

            // Small capacity. Testing resizing.
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);

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

            for (int i = 0; i < numOfSprites; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85, 121 * 1, 85, 121));
                batch.AddChild(sprite, i);

                CCSprite point = new CCSprite("Images/r1");
                AddChild(point, 10);

                switch (i)
                {
                case 0:
                    sprite.AnchorPoint = (new CCPoint(0, 0));
                    break;

                case 1:
                    sprite.AnchorPoint = (new CCPoint(0.5f, 0.5f));
                    break;

                case 2:
                    sprite.AnchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.Position = sprite.Position;

                sprites[i]      = sprite;
                pointSprites[i] = point;
            }
        }
Beispiel #29
0
        public TMXReadWriteTest() : base("TileMaps/orthogonal-test2")
        {
            m_gid = CCTileGidAndFlags.EmptyTile;

            CCTileMapLayer layer = tileMap.LayerNamed("Layer 0");

            layer.Antialiased = true;

            tileMap.Scale = (1);

            CCSprite tile0 = layer.ExtractTile(1, 63);
            CCSprite tile1 = layer.ExtractTile(2, 63);
            CCSprite tile2 = layer.ExtractTile(3, 62); //new CCPoint(1,62));
            CCSprite tile3 = layer.ExtractTile(2, 62);

            tile0.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile1.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile2.AnchorPoint = (new CCPoint(0.5f, 0.5f));
            tile3.AnchorPoint = (new CCPoint(0.5f, 0.5f));

            CCMoveBy    move      = new CCMoveBy(0.5f, new CCPoint(0, 160));
            CCRotateBy  rotate    = new CCRotateBy(2, 360);
            CCScaleBy   scale     = new CCScaleBy(2, 5);
            CCFadeOut   opacity   = new CCFadeOut(2);
            CCFadeIn    fadein    = new CCFadeIn(2);
            CCScaleTo   scaleback = new CCScaleTo(1, 1);
            CCCallFuncN finish    = new CCCallFuncN(removeSprite);
            CCSequence  sequence  = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);

            tile0.RunAction(sequence);
            tile1.RunAction(sequence);
            tile2.RunAction(sequence);
            tile3.RunAction(sequence);


            m_gid = layer.TileGIDAndFlags(0, 63);

            Schedule(updateCol, 2.0f);
            Schedule(repaintWithGID, 2.0f);
            Schedule(removeTiles, 1.0f);


            m_gid2 = CCTileGidAndFlags.EmptyTile;
        }
Beispiel #30
0
        public MenuLayer3()
        {
            CCMenuItemFont.FontName = "arial";
            CCMenuItemFont.FontSize = 28;

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

            CCSprite spriteNormal   = new CCSprite(s_MenuItem, new CCRect(0, 23 * 2, 115, 23));
            CCSprite spriteSelected = new CCSprite(s_MenuItem, new CCRect(0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = new CCSprite(s_MenuItem, new CCRect(0, 23 * 0, 115, 23));


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

            m_disabledItem         = item3;
            m_disabledItem.Enabled = false;

            CCMenu menu = new CCMenu(item1, item2, item3);

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

            CCSize s = CCDirector.SharedDirector.WinSize;

            item1.Position = new CCPoint(s.Width / 2 - 150, s.Height / 2);
            item2.Position = new CCPoint(s.Width / 2 - 200, s.Height / 2);
            item3.Position = new CCPoint(s.Width / 2, s.Height / 2 - 100);
            CCJumpBy jump = new CCJumpBy(3, new CCPoint(400, 0), 50, 4);

            item2.RunAction(new CCRepeatForever(
                                (CCActionInterval)(new CCSequence(jump, jump.Reverse()))
                                )
                            );
            CCActionInterval spin1 = new CCRotateBy(3, 360);
            CCActionInterval spin2 = (CCActionInterval)(spin1.Copy());
            CCActionInterval spin3 = (CCActionInterval)(spin1.Copy());

            item1.RunAction(new CCRepeatForever(spin1));
            item2.RunAction(new CCRepeatForever(spin2));
            item3.RunAction(new CCRepeatForever(spin3));

            AddChild(menu);
        }
        public void addNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)GetChildByTag((int)kTags.kTagSpriteBatchNode);

            int idx = (int)(CCRandom.NextDouble() * 1400 / 100);
            int x   = (idx % 5) * 85;
            int y   = (idx / 5) * 121;


            CCSprite sprite = new CCSprite(BatchNode.Texture, new CCRect(x, y, 85, 121));

            BatchNode.AddChild(sprite);

            sprite.Position = (new CCPoint(p.X, p.Y));

            CCActionInterval action = null;
            float            random = (float)CCRandom.NextDouble();

            if (random < 0.20)
            {
                action = new CCScaleBy(3, 2);
            }
            else if (random < 0.40)
            {
                action = new CCRotateBy(3, 360);
            }
            else if (random < 0.60)
            {
                action = new CCBlink(1, 3);
            }
            else if (random < 0.8)
            {
                action = new CCTintBy(2, 0, -255, -255);
            }
            else
            {
                action = new CCFadeOut(2);
            }

            CCActionInterval action_back = (CCActionInterval)action.Reverse();
            CCActionInterval seq         = (CCActionInterval)(new CCSequence(action, action_back));

            sprite.RunAction(new CCRepeatForever(seq));
        }
        public void addNewSpriteWithCoords(CCPoint p)
        {
            CCSpriteBatchNode BatchNode = (CCSpriteBatchNode)getChildByTag((int)kTags.kTagSpriteBatchNode);

            int idx = (int)(rand.NextDouble() * 1400 / 100);
            int x   = (idx % 5) * 85;
            int y   = (idx / 5) * 121;


            CCSprite sprite = CCSprite.spriteWithTexture(BatchNode.Texture, new CCRect(x, y, 85, 121));

            BatchNode.addChild(sprite);

            sprite.position = (new CCPoint(p.x, p.y));

            CCActionInterval action = null;
            float            random = (float)rand.NextDouble();

            if (random < 0.20)
            {
                action = CCScaleBy.actionWithDuration(3, 2);
            }
            else if (random < 0.40)
            {
                action = CCRotateBy.actionWithDuration(3, 360);
            }
            else if (random < 0.60)
            {
                action = CCBlink.actionWithDuration(1, 3);
            }
            else if (random < 0.8)
            {
                action = CCTintBy.actionWithDuration(2, 0, -255, -255);
            }
            else
            {
                action = CCFadeOut.actionWithDuration(2);
            }

            CCActionInterval action_back = (CCActionInterval)action.reverse();
            CCActionInterval seq         = (CCActionInterval)(CCSequence.actions(action, action_back));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
        }
Beispiel #33
0
        private void performanceActions(CCSprite pSprite)
        {
            CCSize size = Layer.VisibleBoundsWorldspace.Size;

            pSprite.Position = new CCPoint((CCRandom.Next() % (int)size.Width), (CCRandom.Next() % (int)size.Height));

            float      period            = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCRotateBy rot               = new CCRotateBy(period, 360.0f * CCRandom.Float_0_1());
            var        rot_back          = rot.Reverse();
            CCAction   permanentRotation = new CCRepeatForever(new CCSequence(rot, rot_back));

            pSprite.RunAction(permanentRotation);

            float growDuration      = 0.5f + (CCRandom.Next() % 1000) / 500.0f;
            CCFiniteTimeAction grow = new CCScaleBy(growDuration, 0.5f, 0.5f);
            CCAction           permanentScaleLoop = new CCRepeatForever(new CCSequence(grow, grow.Reverse()));

            pSprite.RunAction(permanentScaleLoop);
        }
Beispiel #34
0
        public Sprite6()
        {
            // small capacity. Testing resizing
            // Don't use capacity=1 in your real game. It is expensive to resize the capacity
            CCSpriteBatchNode batch = new CCSpriteBatchNode("Images/grossini_dance_atlas", 1);

            AddChild(batch, 0, kTagSpriteBatchNode);
            batch.IgnoreAnchorPointForPosition = true;

            CCSize s = CCDirector.SharedDirector.WinSize;

            batch.AnchorPoint = new CCPoint(0.5f, 0.5f);
            batch.ContentSize = (new CCSize(s.Width, s.Height));


            // SpriteBatchNode actions
            CCActionInterval rotate = new CCRotateBy(5, 360);
            CCAction         action = new CCRepeatForever(rotate);

            // SpriteBatchNode actions
            CCActionInterval rotate_back    = (CCActionInterval)rotate.Reverse();
            CCActionInterval rotate_seq     = (CCActionInterval)(CCSequence.FromActions(rotate, rotate_back));
            CCAction         rotate_forever = new CCRepeatForever(rotate_seq);

            CCActionInterval scale         = new CCScaleBy(5, 1.5f);
            CCActionInterval scale_back    = (CCActionInterval)scale.Reverse();
            CCActionInterval scale_seq     = (CCActionInterval)(CCSequence.FromActions(scale, scale_back));
            CCAction         scale_forever = new CCRepeatForever(scale_seq);

            float step = s.Width / 4;

            for (int i = 0; i < 3; i++)
            {
                CCSprite sprite = new CCSprite(batch.Texture, new CCRect(85 * i, 121 * 1, 85, 121));
                sprite.Position = (new CCPoint((i + 1) * step, s.Height / 2));

                sprite.RunAction((CCAction)(action.Copy()));
                batch.AddChild(sprite, i);
            }

            batch.RunAction(scale_forever);
            batch.RunAction(rotate_forever);
        }
Beispiel #35
0
        public Layer1()
            : base(new ccColor4B (0, 255, 0, 255))
        {
            CCMenuItemFont item1 = new CCMenuItemFont("Test pushScene", OnPushScene);
            CCMenuItemFont item2 = new CCMenuItemFont("Test pushScene w/transition", OnPushSceneTran);
            CCMenuItemFont item3 = new CCMenuItemFont("Quit", OnQuit);

            CCMenu menu = new CCMenu(item1, item2, item3);
            menu.AlignItemsVertically ();
            this.AddChild (menu);

            CGSize s = CCDirector.SharedDirector ().WinSize ();
            CCSprite sprite = new CCSprite("grossini.png", true);
            this.AddChild (sprite);
            sprite.Position = new CCPoint(s.Width-40, s.Height/2);
            var rotate = new CCRotateBy (2, 360);
            var repeat = new CCRepeatForever (rotate);
            sprite.RunAction (repeat);

            this.Schedule (new MonoMac.ObjCRuntime.Selector ("testDealloc:"));
        }
Beispiel #36
0
        public Layer3()
        {
            CCMenuItemFont.DefaultFontName = "Marker Felt";
            CCMenuItemFont.DefaultFontSize = 28;

            CCLabelBMFont label = new CCLabelBMFont("Enable AtlasItem", "bitmapFontTest3.fnt");
            CCMenuItemLabel item1 = new CCMenuItemLabel(label, this, new MonoMac.ObjCRuntime.Selector("menuCallback2:"));
            CCMenuItemFont item2 = new CCMenuItemFont("--- Go Back ---", this, new MonoMac.ObjCRuntime.Selector("menuCallback:"));

            CCSprite spriteNormal = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 2, 115, 23));
            CCSprite spriteSelected = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 1, 115, 23));
            CCSprite spriteDisabled = new CCSprite ("menuitemsprite.png", new RectangleF (0, 23 * 0, 115, 23));

            CCMenuItemSprite item3 = new CCMenuItemSprite (spriteNormal, spriteSelected, spriteDisabled, this, new MonoMac.ObjCRuntime.Selector("menuCallback3:"));
            disabledItem = item3;
            disabledItem.Enabled = false;

            NSArray arrayOfItems = NSArray.FromObjects(item1, item2, item3);
            CCMenu menu = new CCMenu(arrayOfItems);

            CGSize s = CCDirector.SharedDirector().WinSize ();

            item1.Position = new CCPoint(s.Width/2 - 150, s.Height/2);
            item2.Position = new CCPoint(s.Width/2 - 200, s.Height/2);
            item3.Position = new CCPoint(s.Width/2, s.Height/2 - 100);

            var jump = new CCJumpBy(3, new CCPoint(400,0), 50, 4);
            item2.RunAction (new CCRepeatForever ((CCActionInterval)CCSequence.Actions (jump, jump.Reverse ())));
            var spin1 = new CCRotateBy (3, 360);
            var spin2 = (CCRotateBy)spin1.Copy ();
            var spin3 = (CCRotateBy)spin1.Copy ();

            item1.RunAction (new CCRepeatForever (spin1));
            item2.RunAction (new CCRepeatForever (spin2));
            item3.RunAction (new CCRepeatForever (spin3));

            this.AddChild (menu);
            menu.Position = new CCPoint(0, 0);
        }
Beispiel #37
0
 protected CCRotateBy(CCRotateBy rotateTo)
     : base(rotateTo)
 {
     InitWithDuration(rotateTo.m_fDuration, rotateTo.m_fAngle);
 }