コード例 #1
0
        // CCLayer
        public override void OnEnter()
        {
            base.OnEnter();

            m_nCharLimit = 12;

            m_pTextFieldAction = new CCRepeatForever(
                (CCActionInterval)CCSequence.FromActions(
                    new CCFadeOut(0.25f),
                    new CCFadeIn(0.25f)));
            //m_pTextFieldAction->retain();
            m_bAction = false;

            // add CCTextFieldTTF
            CCSize s = CCDirector.SharedDirector.WinSize;

            m_pTextField = CCTextFieldTTF.TextFieldWithPlaceHolder("<click here for input>",
                                                                   TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);
            AddChild(m_pTextField);

            //m_pTextField.setDelegate(this);


            //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
            //    // on android, CCTextFieldTTF cannot auto adjust its position when soft-keyboard pop up
            //    // so we had to set a higher position
            //    m_pTextField->setPosition(new CCPoint(s.width / 2, s.height/2 + 50));
            //#else
            //    m_pTextField->setPosition(ccp(s.width / 2, s.height / 2));
            //#endif

            m_pTrackNode = m_pTextField;
        }
コード例 #2
0
        protected CCSequence(CCSequence sequence) : base(sequence)
        {
            var param1 = sequence.m_pActions[0].Copy() as CCFiniteTimeAction;
            var param2 = sequence.m_pActions[1].Copy() as CCFiniteTimeAction;

            InitOneTwo(param1, param2);
        }
コード例 #3
0
        /** switches to a certain layer indexed by n.
         * The current (old) layer will be removed from it's parent with 'cleanup:YES'.
         */

        /// <summary>
        /// Swtich to the given index layer and use the given action after the layer is
        /// added to the scene.
        /// </summary>
        /// <param name="n"></param>
        public void SwitchTo(int n)
        {
            Debug.Assert(n < m_pLayers.Count, "Invalid index in MultiplexLayer switchTo message");

            CCLayer outLayer = m_pLayers[m_nEnabledLayer];

            if (m_OutAction != null)
            {
                outLayer.RunAction(
                    CCSequence.FromActions(
                        (CCFiniteTimeAction)m_OutAction.Copy(),
                        new CCCallFunc(() => RemoveChild(outLayer, true))
                        )
                    );
            }
            else
            {
                RemoveChild(outLayer, true);
            }

            m_nEnabledLayer = n;

            AddChild(m_pLayers[n]);

            if (m_InAction != null)
            {
                m_pLayers[n].RunAction(m_InAction.Copy());
            }
        }
コード例 #4
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' ');

            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity  = 200;

            CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' ');

            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            //label2.setColor( ccRED );
            label2.Color = ccRED;

            CCActionInterval fade = new CCFadeOut(1.0f);
            //CCActionInterval fade_in = fade.reverse();
            CCActionInterval   fade_in = null;
            CCFiniteTimeAction seq     = CCSequence.FromActions(fade, fade_in, null);
            CCAction           repeat  = new CCRepeatForever((CCActionInterval)seq);

            label2.RunAction(repeat);

            m_time = 0;

            //schedule( schedule_selector(LabelAtlasColorTest.step) ); //:@selector(step:)];
        }
コード例 #5
0
ファイル: NodeToWorld.cs プロジェクト: Ratel13/cocos2d-xna
        public NodeToWorld()
        {
            //
            // This code tests that nodeToParent works OK:
            //  - It tests different anchor Points
            //  - It tests different children anchor points

            CCSprite back = new CCSprite(TestResource.s_back3);
            AddChild(back, -10);
            back.AnchorPoint = (new CCPoint(0, 0));
            CCSize backSize = back.ContentSize;

            CCMenuItem item = new CCMenuItemImage(TestResource.s_PlayNormal, TestResource.s_PlaySelect);
            CCMenu menu = new CCMenu(item);
            menu.AlignItemsVertically();
            menu.Position = (new CCPoint(backSize.Width / 2, backSize.Height / 2));
            back.AddChild(menu);

            CCActionInterval rot = new CCRotateBy (5, 360);
            CCAction fe = new CCRepeatForever (rot);
            item.RunAction(fe);

            CCActionInterval move = new CCMoveBy (3, new CCPoint(200, 0));
            var move_back = (CCActionInterval) move.Reverse();
            CCFiniteTimeAction seq = new CCSequence(move, move_back);
            CCAction fe2 = new CCRepeatForever ((CCActionInterval) seq);
            back.RunAction(fe2);
        }
コード例 #6
0
        /// <summary>
        /// Constructs the parallel sequence from the given array of actions.
        /// </summary>
        /// <param name="actions"></param>
        public CCParallel(params CCFiniteTimeAction[] actions)
        {
            m_pActions = actions;
            float duration = 0f;

            for (int i = 0; i < m_pActions.Length; i++)
            {
                var actionDuration = m_pActions[i].Duration;
                if (duration < actionDuration)
                {
                    duration = actionDuration;
                }
            }

            for (int i = 0; i < m_pActions.Length; i++)
            {
                var actionDuration = m_pActions[i].Duration;
                if (actionDuration < duration)
                {
                    m_pActions[i] = new CCSequence(m_pActions[i], new CCDelayTime(duration - actionDuration));
                }
            }

            base.InitWithDuration(duration);
        }
コード例 #7
0
ファイル: StressTest2.cs プロジェクト: Karunp/cocos2d-xna
        public StressTest2()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayer sublayer = new CCLayer();

            CCSprite sp1 = new CCSprite(TestResource.s_pPathSister1);
            sp1.Position = (new CCPoint(80, s.Height / 2));

            CCActionInterval move = new CCMoveBy (3, new CCPoint(350, 0));
            CCActionInterval move_ease_inout3 = new CCEaseInOut((CCActionInterval) (move.Copy()), 2.0f);
            var move_ease_inout_back3 = (CCActionInterval) move_ease_inout3.Reverse();
            CCFiniteTimeAction seq3 = new CCSequence(move_ease_inout3, move_ease_inout_back3);
            sp1.RunAction(new CCRepeatForever ((CCActionInterval) seq3));
            sublayer.AddChild(sp1, 1);

            CCParticleFire fire = new CCParticleFire();
            fire.Texture = (CCTextureCache.SharedTextureCache.AddImage("Images/fire"));
            fire.Position = (new CCPoint(80, s.Height / 2 - 50));

            var copy_seq3 = (CCActionInterval) (seq3.Copy());

            fire.RunAction(new CCRepeatForever (copy_seq3));
            sublayer.AddChild(fire, 2);

            Schedule((shouldNotLeak), 6.0f);

            AddChild(sublayer, 0, CocosNodeTestStaticLibrary.kTagSprite1);
        }
コード例 #8
0
ファイル: CCSequence.cs プロジェクト: Ratel13/cocos2d-xna
        protected CCSequence(CCSequence sequence) : base(sequence)
        {
            var param1 = sequence.m_pActions[0].Copy() as CCFiniteTimeAction;
            var param2 = sequence.m_pActions[1].Copy() as CCFiniteTimeAction;

            InitOneTwo(param1, param2);
        }
コード例 #9
0
ファイル: BodyNode.cs プロジェクト: johnkg/AngryNinjas
 public void FadeThenRemove(float delta)
 {
     var seq = new CCSequence(
                        new CCFadeTo (1.0f,0),
                        new CCCallFunc(RemoveSpriteAndBody));
     sprite.RunAction(seq);
 }
コード例 #10
0
ファイル: LayerTest2.cs プロジェクト: Karunp/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;
            var layer1 = new CCLayerColor(new CCColor4B(255, 255, 0, 80), 100, s.Height - 50);
            layer1.Position = (new CCPoint(s.Width / 3, s.Height / 2));
            layer1.IgnoreAnchorPointForPosition = false;
            AddChild(layer1, 1);

            var layer2 = new CCLayerColor(new CCColor4B(0, 0, 255, 255), 100, s.Height - 50);
            layer2.Position = (new CCPoint((s.Width / 3) * 2, s.Height / 2));
            layer2.IgnoreAnchorPointForPosition = false;
            AddChild(layer2, 1);

            var actionTint = new CCTintBy (2, -255, -127, 0);
            var actionTintBack = actionTint.Reverse();
            var seq1 = new CCSequence(actionTint, actionTintBack);
            layer1.RunAction(seq1);

            var actionFade = new CCFadeOut(2.0f);
            var actionFadeBack = actionFade.Reverse();
            var seq2 = new CCSequence(actionFade, actionFadeBack);
            layer2.RunAction(seq2);
        }
コード例 #11
0
        /**
         * Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
         * You can override the animation duration with this method.
         *
         * @param offset new offset
         * @param animation duration
         */

        public void SetContentOffsetInDuration(CCPoint offset, float dt)
        {
            CCMoveTo    scroll = new CCMoveTo(dt, offset);
            CCCallFuncN expire = new CCCallFuncN(StoppedAnimatedScroll);

            m_pContainer.RunAction(CCSequence.FromActions(scroll, expire));
            Schedule(PerformedAnimatedScroll);
        }
コード例 #12
0
ファイル: Parallax1.cs プロジェクト: rtabbara/cocos2d-xna
        public Parallax1()
        {
            // Top Layer, a simple image
            CCSprite cocosImage = new CCSprite(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.Create(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.SetAntiAliasTexParameters();


            // background layer: another image
            CCSprite background = new CCSprite(TestResource.s_back);
            // scale the image (optional)
            background.Scale = 1.5f;
            // change the transform anchor point (optional)
            background.AnchorPoint = new CCPoint(0, 0);


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

            // 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, new CCPoint(0.4f, 0.5f), new CCPoint(0, 0));

            // tiles are moved at a ratio of 2.2x, 1.0y
            voidNode.AddChild(tilemap, 1, new CCPoint(2.2f, 1.0f), new CCPoint(0, -200));

            // top image is moved at a ratio of 3.0x, 2.5y
            voidNode.AddChild(cocosImage, 2, new CCPoint(3.0f, 2.5f), new CCPoint(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
            CCMoveBy goUp = new CCMoveBy (4, new CCPoint(0, -500));
            CCFiniteTimeAction goDown = goUp.Reverse();
            CCMoveBy go = new CCMoveBy (8, new CCPoint(-1000, 0));
            CCFiniteTimeAction goBack = go.Reverse();
            CCFiniteTimeAction seq = new CCSequence(goUp, go, goDown, goBack);

            voidNode.RunAction(new CCRepeatForever ((CCActionInterval) seq));

            AddChild(voidNode, -1, kTagTileMap);
        }
コード例 #13
0
        public void disableMenuCallback(object pSender)
        {
            m_pMenu1.Enabled = false;
            CCDelayTime wait = new CCDelayTime (5);
            CCCallFunc enable = new CCCallFunc(enableMenuCallback);

            CCFiniteTimeAction seq = new CCSequence(wait, enable);
            m_pMenu1.RunAction(seq);
        }
コード例 #14
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(1);
            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);
            //CCActionInterval scale_back = scale.reverse();
            CCActionInterval   scale_back  = null;
            CCFiniteTimeAction scale_seq   = CCSequence.FromActions(scale, scale_back, null);
            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        = CCSequence.FromActions(fade_out, fade_in, null);
            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);
        }
コード例 #15
0
        /// <summary>
        /// Creates a sequence of actions that causes a sprite to move using all the actions on the screen.
        /// </summary>
        /// <param name="repeatForever">A boolean value that determines if the action should be repeated indefinitely.</param>
        /// <returns></returns>
        internal static CCAction AllShapesAction(bool repeatForever)
        {
            // Create a new action sequence that will move the sprite using all the other actions
            CCActionInterval allAction = new CCSequence(RotateAction(false), ScaleAction(false), JumpAction(false), BoxAction(false), TriangleAction(false));

            // See if we're repeating the action indefinitely
            if (repeatForever) allAction = new CCRepeatForever(allAction);

            return allAction;
        }
コード例 #16
0
        public static CCSequence FromActions(params CCFiniteTimeAction[] actions)
        {
            CCFiniteTimeAction prev = actions[0];

            for (int i = 1; i < actions.Length; i++)
            {
                prev = new CCSequence(prev, actions[i]);
            }

            return((CCSequence)prev);
        }
コード例 #17
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize s = CCDirector.SharedDirector.WinSize;

            CCProgressTo to = new CCProgressTo(6, 100);
            CCAction tint = new CCSequence(new CCTintTo (1, 255, 0, 0),
                                              new CCTintTo (1, 0, 255, 0),
                                              new CCTintTo (1, 0, 0, 255));
            CCAction fade = new CCSequence(new CCFadeTo (1.0f, 0),
                                              new CCFadeTo (1.0f, 255));

            CCProgressTimer left = new CCProgressTimer(new CCSprite(s_pPathSister1));
            left.Type = CCProgressTimerType.Bar;

            //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
            left.Midpoint = new CCPoint(0.5f, 0.5f);
            //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
            left.BarChangeRate = new CCPoint(1, 0);
            AddChild(left);
            left.Position = new CCPoint(100, s.Height / 2);
            left.RunAction(new CCRepeatForever ((CCActionInterval) to.Copy()));
            left.RunAction(new CCRepeatForever ((CCActionInterval) tint.Copy()));

            left.AddChild(new CCLabelTTF("Tint", "arial", 20.0f));

            CCProgressTimer middle = new CCProgressTimer(new CCSprite(s_pPathSister2));
            middle.Type = CCProgressTimerType.Bar;
            //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
            middle.Midpoint = new CCPoint(0.5f, 0.5f);
            //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
            middle.BarChangeRate = new CCPoint(1, 1);
            AddChild(middle);
            middle.Position = new CCPoint(s.Width / 2, s.Height / 2);
            middle.RunAction(new CCRepeatForever ((CCActionInterval) to.Copy()));
            middle.RunAction(new CCRepeatForever ((CCActionInterval) fade.Copy()));

            middle.AddChild(new CCLabelTTF("Fade", "arial", 20.0f));

            CCProgressTimer right = new CCProgressTimer(new CCSprite(s_pPathSister2));
            right.Type = CCProgressTimerType.Bar;
            //    Setup for a bar starting from the bottom since the midpoint is 0 for the y
            right.Midpoint = new CCPoint(0.5f, 0.5f);
            //    Setup for a vertical bar since the bar change rate is 0 for x meaning no horizontal change
            right.BarChangeRate = new CCPoint(0, 1);
            AddChild(right);
            right.Position = new CCPoint(s.Width - 100, s.Height / 2);
            right.RunAction(new CCRepeatForever ((CCActionInterval) to.Copy()));
            right.RunAction(new CCRepeatForever ((CCActionInterval) tint.Copy()));
            right.RunAction(new CCRepeatForever ((CCActionInterval) fade.Copy()));

            right.AddChild(new CCLabelTTF("Tint and Fade", "arial", 20.0f));
        }
コード例 #18
0
ファイル: Atlas4.cs プロジェクト: Ratel13/cocos2d-xna
        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);
        }
コード例 #19
0
ファイル: MenuTestScene.cs プロジェクト: Ratel13/cocos2d-xna
        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);
        }
コード例 #20
0
        /// <summary>
        /// Creates a sequence of actions that causes a sprite to move in a box shape on the screen.
        /// </summary>
        /// <param name="repeatForever">A boolean value that determines if the action should be repeated indefinitely.</param>
        /// <returns></returns>
        internal static CCFiniteTimeAction BoxAction(bool repeatForever)
        {
            // Create a new action sequence that will move the sprite in a box shape at fixed positions on the screen
            CCActionInterval boxAction = new CCSequence(
                new CCMoveTo(1, new CCPoint(100, 100)),
                new CCMoveTo(1, new CCPoint(100, 500)),
                new CCMoveTo(1, new CCPoint(500, 500)),
                new CCMoveTo(1, new CCPoint(500, 100)));

            // See if we're repeating the action indefinitely
            if (repeatForever) boxAction = new CCRepeatForever(boxAction);

            return boxAction;
        }
コード例 #21
0
        public virtual bool onTextFieldInsertText(CCTextFieldTTF pSender, string text, int nLen)
        {
            // if insert enter, treat as default to detach with ime
            if ("\n" == text)
            {
                return(false);
            }

            // if the textfield's char count more than m_nCharLimit, doesn't insert text anymore.
            if (pSender.CharCount >= m_nCharLimit)
            {
                return(true);
            }

            // create a insert text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(text, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.AddChild(label);
            CCColor3B color = new CCColor3B {
                R = 226, G = 121, B = 7
            };

            label.Color = color;

            // move the sprite from top to position
            CCPoint endPos = pSender.Position;

            if (pSender.CharCount > 0)
            {
                endPos.X += pSender.ContentSize.Width / 2;
            }
            CCSize  inputTextSize = label.ContentSize;
            CCPoint beginPos      = new CCPoint(endPos.X, CCDirector.SharedDirector.WinSize.Height - inputTextSize.Height * 2);

            float duration = 0.5f;

            label.Position = beginPos;
            label.Scale    = 8;

            CCAction seq = CCSequence.FromActions(
                CCSpawn.FromActions(
                    new CCMoveTo(duration, endPos),
                    new CCScaleTo(duration, 1),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
コード例 #22
0
ファイル: CCSequence.cs プロジェクト: Ratel13/cocos2d-xna
        public CCSequence(params CCFiniteTimeAction[] actions)
        {
            CCFiniteTimeAction prev = actions[0];

            if (actions.Length == 1)
            {
                InitOneTwo(prev, new CCExtraAction());
            }
            else
            {
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new CCSequence(prev, actions[i]);
                }

                InitOneTwo(prev, actions[actions.Length - 1]);
            }
        }
コード例 #23
0
        public CCSpawn(params CCFiniteTimeAction[] actions)
        {
            CCFiniteTimeAction prev = actions[0];

            if (actions.Length == 1)
            {
                InitOneTwo(prev, new CCExtraAction());
            }
            else
            {
                for (int i = 1; i < actions.Length - 1; i++)
                {
                    prev = new CCSequence(prev, actions[i]);
                }

                InitOneTwo(prev, actions[actions.Length - 1]);
            }
        }
コード例 #24
0
        private void RunAction(CCNode node, CCBSequenceProperty pSeqProp, float fTweenDuration)
        {
            List <CCBKeyframe> keyframes = pSeqProp.Keyframes;
            int numKeyframes             = keyframes.Count;

            if (numKeyframes > 1)
            {
                // Make an animation!
                var actions = new List <CCFiniteTimeAction>();

                CCBKeyframe keyframeFirst = keyframes[0];
                float       timeFirst     = keyframeFirst.Time + fTweenDuration;

                if (timeFirst > 0)
                {
                    actions.Add(new CCDelayTime(timeFirst));
                }

                for (int i = 0; i < numKeyframes - 1; ++i)
                {
                    CCBKeyframe kf0 = keyframes[i];
                    CCBKeyframe kf1 = keyframes[i + 1];

                    CCActionInterval action = GetAction(kf0, kf1, pSeqProp.Name, node);
                    if (action != null)
                    {
                        // Apply easing
                        action = GetEaseAction(action, kf0.EasingType, kf0.EasingOpt);

                        actions.Add(action);
                    }
                }

                if (actions.Count > 1)
                {
                    CCFiniteTimeAction seq = new CCSequence(actions.ToArray());
                    node.RunAction(seq);
                }
                else
                {
                    node.RunAction(actions[0]);
                }
            }
        }
コード例 #25
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCActionInterval inA, outA;

            m_pInScene.Visible = false;

            float inDeltaZ, inAngleZ;
            float outDeltaZ, outAngleZ;

            if (m_eOrientation == CCTransitionOrientation.RightOver)
            {
                inDeltaZ  = 90;
                inAngleZ  = 270;
                outDeltaZ = 90;
                outAngleZ = 0;
            }
            else
            {
                inDeltaZ  = -90;
                inAngleZ  = 90;
                outDeltaZ = -90;
                outAngleZ = 0;
            }

            inA = new CCSequence
                  (
                new CCDelayTime(m_fDuration / 2),
                new CCShow(),
                new CCOrbitCamera(m_fDuration / 2, 1, 0, inAngleZ, inDeltaZ, -45, 0),
                new CCCallFunc(Finish)
                  );
            outA = new CCSequence
                   (
                new CCOrbitCamera(m_fDuration / 2, 1, 0, outAngleZ, outDeltaZ, 45, 0),
                new CCHide(),
                new CCDelayTime(m_fDuration / 2)
                   );

            m_pInScene.RunAction(inA);
            m_pOutScene.RunAction(outA);
        }
コード例 #26
0
ファイル: Atlas3.cs プロジェクト: Ratel13/cocos2d-xna
        public Atlas3()
        {
            m_time = 0;

            CCLayerColor col = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(col, -10);

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

            // testing anchors
            label1.AnchorPoint = new CCPoint(0, 0);
            AddChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            CCActionInterval fade = new CCFadeOut  (1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq = new CCSequence(fade, fade_in);
            CCAction repeat = new CCRepeatForever ((CCActionInterval)seq);
            label1.RunAction(repeat);


            // VERY IMPORTANT
            // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image)
            // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images
            // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected
            CCLabelBMFont label2 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");
            // testing anchors
            label2.AnchorPoint = new CCPoint(0.5f, 0.5f);
            label2.Color = ccRED;
            AddChild(label2, 0, (int)TagSprite.kTagBitmapAtlas2);
            label2.RunAction((CCAction)(repeat.Copy()));

            CCLabelBMFont label3 = new CCLabelBMFont("Test", "fonts/bitmapFontTest2.fnt");
            // testing anchors
            label3.AnchorPoint = new CCPoint(1, 1);
            AddChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);


            CCSize s = CCDirector.SharedDirector.WinSize;
            label1.Position = new CCPoint();
            label2.Position = new CCPoint(s.Width / 2, s.Height / 2);
            label3.Position = new CCPoint(s.Width, s.Height);

            base.Schedule(step);//:@selector(step:)];
        }
コード例 #27
0
ファイル: LabelTTFA8Test.cs プロジェクト: Ratel13/cocos2d-xna
        public LabelTTFA8Test()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCLayerColor layer = new CCLayerColor(new CCColor4B(128, 128, 128, 255));
            AddChild(layer, -10);

            // CCLabelBMFont
            CCLabelTTF label1 = new CCLabelTTF("Testing A8 Format", "Marker Felt", 38);
            AddChild(label1);
            label1.Color = CCTypes.CCRed;
            label1.Position = new CCPoint(s.Width / 2, s.Height / 2);

            CCFadeOut fadeOut = new CCFadeOut  (2);
            CCFadeIn fadeIn = new CCFadeIn  (2);
            CCFiniteTimeAction seq = new CCSequence(fadeOut, fadeIn);
            CCRepeatForever forever = new CCRepeatForever ((CCActionInterval) seq);
            label1.RunAction(forever);
        }
コード例 #28
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCActionInterval inA, outA;
            m_pInScene.Visible = false;

            float inDeltaZ, inAngleZ;
            float outDeltaZ, outAngleZ;

            if (m_eOrientation == CCTransitionOrientation.UpOver)
            {
                inDeltaZ = 90;
                inAngleZ = 270;
                outDeltaZ = 90;
                outAngleZ = 0;
            }
            else
            {
                inDeltaZ = -90;
                inAngleZ = 90;
                outDeltaZ = -90;
                outAngleZ = 0;
            }

            inA = new CCSequence
                (
                    new CCDelayTime (m_fDuration / 2),
                    new CCShow(),
                    new CCOrbitCamera(m_fDuration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
                    new CCCallFunc(Finish)
                );
            outA = new CCSequence
                (
                    new CCOrbitCamera(m_fDuration / 2, 1, 0, outAngleZ, outDeltaZ, 90, 0),
                    new CCHide(),
                    new CCDelayTime (m_fDuration / 2)
                );

            m_pInScene.RunAction(inA);
            m_pOutScene.RunAction(outA);
        }
コード例 #29
0
ファイル: LayerScaleTest.cs プロジェクト: Ratel13/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            this.TouchEnabled = true;

            CCSize s = CCDirector.SharedDirector.WinSize;
            CCLayerColor layer = new CCLayerColor(new CCColor4B(0xFF, 0x00, 0x00, 0x80), s.Width * 0.75f, s.Height * 0.75f);

            layer.IgnoreAnchorPointForPosition = false;
            layer.Position = (new CCPoint(s.Width / 2, s.Height / 2));
            AddChild(layer, 1, kTagLayer);
            //
            // Add two labels using BM label class
            // CCLabelBMFont
            CCLabelBMFont label1 = new CCLabelBMFont("LABEL1", "fonts/konqa32.fnt");
            layer.AddChild(label1);
            label1.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.75f);
            CCLabelBMFont label2 = new CCLabelBMFont("LABEL2", "fonts/konqa32.fnt");
            layer.AddChild(label2);
            label2.Position = new CCPoint(layer.ContentSize.Width / 2, layer.ContentSize.Height * 0.25f);
            //
            // Do the sequence of actions in the bug report
            float waitTime = 3f;
            float runTime = 12f;
            layer.Visible = false;
            CCHide hide = new CCHide();
            CCScaleTo scaleTo1 = new CCScaleTo(0.0f, 0.0f);
            CCShow show = new CCShow();
            CCDelayTime delay = new CCDelayTime (waitTime);
            CCScaleTo scaleTo2 = new CCScaleTo(runTime * 0.25f, 1.2f);
            CCScaleTo scaleTo3 = new CCScaleTo(runTime * 0.25f, 0.95f);
            CCScaleTo scaleTo4 = new CCScaleTo(runTime * 0.25f, 1.1f);
            CCScaleTo scaleTo5 = new CCScaleTo(runTime * 0.25f, 1.0f);

            CCFiniteTimeAction seq = new CCSequence(hide, scaleTo1, show, delay, scaleTo2, scaleTo3, scaleTo4, scaleTo5);

            layer.RunAction(seq);


        }
コード例 #30
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCLayerColor l = new CCLayerColor(m_tColor);

            m_pInScene.Visible = false;

            AddChild(l, 2, kSceneFade);
            CCNode f = GetChildByTag(kSceneFade);

            var a = (CCActionInterval)CCSequence.FromActions
                    (
                new CCFadeIn(m_fDuration / 2),
                new CCCallFunc((HideOutShowIn)),
                new CCFadeOut(m_fDuration / 2),
                new CCCallFunc((Finish))
                    );

            f.RunAction(a);
        }
コード例 #31
0
ファイル: Effect4.cs プロジェクト: Karunp/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            CCLens3D lens = new CCLens3D(10, new CCGridSize(32, 24), new CCPoint(100, 180), 150);
            CCJumpBy move = new CCJumpBy (5, new CCPoint(380, 0), 100, 4);
            var move_back = (CCActionInterval) move.Reverse();
            CCSequence seq = new CCSequence(move, move_back);

            /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'CCLens3D' as its target.
                While in cocos2d-x, the target of action only supports CCNode or its subclass,
                so we make an encapsulation for CCLens3D to achieve that.
            */

            CCDirector director = CCDirector.SharedDirector;
            CCNode target = Lens3DTarget.Create(lens);
            // Please make sure the target been added to its parent.
            AddChild(target);

            director.ActionManager.AddAction(seq, target, false);
            RunAction(lens);
        }
コード例 #32
0
        public LabelAtlasColorTest()
        {
            CCLabelAtlas label1 = new CCLabelAtlas("123 Test", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label1, 0, (int)TagSprite.kTagSprite1);
            label1.Position = new CCPoint(10, 100);
            label1.Opacity = 200;

            CCLabelAtlas label2 = new CCLabelAtlas("0123456789", "fonts/tuffy_bold_italic-charmap", 48, 64, ' ');
            AddChild(label2, 0, (int)TagSprite.kTagSprite2);
            label2.Position = new CCPoint(10, 200);
            label2.Color = ccRED;

            CCActionInterval fade = new CCFadeOut  (1.0f);
            CCFiniteTimeAction fade_in = fade.Reverse();
            CCFiniteTimeAction seq = new CCSequence(fade, fade_in);
            CCAction repeat = new CCRepeatForever ((CCActionInterval)seq);
            label2.RunAction(repeat);

            m_time = 0;

            Schedule(step); //:@selector(step:)];
        }
コード例 #33
0
        public override void OnEnter()
        {
            base.OnEnter();

            m_pInScene.Scale  = 0.001f;
            m_pOutScene.Scale = (1.0f);

            m_pInScene.AnchorPoint  = new CCPoint(2 / 3.0f, 0.5f);
            m_pOutScene.AnchorPoint = new CCPoint(1 / 3.0f, 0.5f);

            CCActionInterval scaleOut = new CCScaleTo(m_fDuration, 0.01f);
            CCActionInterval scaleIn  = new CCScaleTo(m_fDuration, 1.0f);

            m_pInScene.RunAction(EaseAction(scaleIn));
            m_pOutScene.RunAction
            (
                CCSequence.FromActions
                (
                    EaseAction(scaleOut),
                    new CCCallFunc((Finish))
                )
            );
        }
コード例 #34
0
        public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen)
        {
            // create a delete text sprite and do some action
            CCLabelTTF label = new CCLabelTTF(delText, TextInputTestScene.FONT_NAME, TextInputTestScene.FONT_SIZE);

            this.AddChild(label);

            // move the sprite to fly out
            CCPoint beginPos      = pSender.Position;
            CCSize  textfieldSize = pSender.ContentSize;
            CCSize  labelSize     = label.ContentSize;

            beginPos.X += (textfieldSize.Width - labelSize.Width) / 2.0f;

            int      RAND_MAX = 32767;
            CCRandom rand     = new CCRandom();

            CCSize  winSize        = CCDirector.SharedDirector.WinSize;
            CCPoint endPos         = new CCPoint(-winSize.Width / 4.0f, winSize.Height * (0.5f + (float)CCRandom.Next() / (2.0f * RAND_MAX)));
            float   duration       = 1;
            float   rotateDuration = 0.2f;
            int     repeatTime     = 5;

            label.Position = beginPos;

            CCAction seq = CCSequence.FromActions(
                CCSpawn.FromActions(
                    new CCMoveTo(duration, endPos),
                    new CCRepeat(
                        new CCRotateBy(rotateDuration, (CCRandom.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    new CCFadeOut(duration)),
                new CCCallFuncN(callbackRemoveNodeWhenDidAction));

            label.RunAction(seq);
            return(false);
        }
コード例 #35
0
ファイル: CCParallel.cs プロジェクト: rtabbara/cocos2d-xna
        /// <summary>
        /// Constructs the parallel sequence from the given array of actions.
        /// </summary>
        /// <param name="actions"></param>
        public CCParallel(params CCFiniteTimeAction[] actions)
        {
            m_pActions = actions;
            float duration = 0f;
            for (int i = 0; i < m_pActions.Length; i++)
            {
                var actionDuration = m_pActions[i].Duration;
                if (duration < actionDuration)
                {
                    duration = actionDuration;
                }
            }

            for (int i = 0; i < m_pActions.Length; i++)
            {
                var actionDuration = m_pActions[i].Duration;
                if (actionDuration < duration)
                {
                    m_pActions[i] = new CCSequence(m_pActions[i], new CCDelayTime(duration - actionDuration));
                }
            }

            base.InitWithDuration(duration);
        }
コード例 #36
0
ファイル: TileMapTest.cs プロジェクト: rtabbara/cocos2d-xna
        public TileMapTest()
        {
            CCTileMapAtlas map = CCTileMapAtlas.Create(s_TilesPng, s_LevelMapTga, 16, 16);
            // Convert it to "alias" (GL_LINEAR filtering)
            map.Texture.SetAntiAliasTexParameters();

            CCSize s = map.ContentSize;
            CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height);

            // If you are not going to use the Map, you can free it now
            // NEW since v0.7
            map.ReleaseMap();

            AddChild(map, 0, kTagTileMap);

            map.AnchorPoint = (new CCPoint(0, 0.5f));

            CCScaleBy scale = new CCScaleBy(4, 0.8f);
            CCFiniteTimeAction scaleBack = scale.Reverse();

            var seq = new CCSequence(scale, scaleBack);

            map.RunAction(new CCRepeatForever ((CCActionInterval)seq));
        }
コード例 #37
0
ファイル: TileMapTest.cs プロジェクト: rtabbara/cocos2d-xna
        public TMXIsoVertexZ()
        {
            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/iso-test-vertexz");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;
            map.Position = new CCPoint(-s.Width / 2, 0);

            // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
            // can use any CCSprite and it will work OK.
            CCTMXLayer layer = map.LayerNamed("Trees");
            m_tamara = layer.TileAt(new CCPoint(29, 29));

            CCMoveBy move = new CCMoveBy (10, new CCPoint(300, 250) * (1f / CCMacros.CCContentScaleFactor()));
            CCFiniteTimeAction back = move.Reverse();
            CCSequence seq = new CCSequence(move, back);
            m_tamara.RunAction(new CCRepeatForever (seq));

            m_tamara.Position = new CCPoint(m_tamara.Position.X + 100, m_tamara.Position.Y + 100);

            Schedule(repositionSprite);
        }
コード例 #38
0
ファイル: TileMapTest.cs プロジェクト: rtabbara/cocos2d-xna
        public TMXOrthoZorder()
        {
            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test-zorder");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            m_tamara = new CCSprite(s_pPathSister1);
            map.AddChild(m_tamara, map.Children.Count);
            m_tamara.AnchorPoint = (new CCPoint(0.5f, 0));


            CCMoveBy move = new CCMoveBy (10, new CCPoint(400, 450));
            CCFiniteTimeAction back = move.Reverse();
            CCSequence seq = new CCSequence(move, back);
            m_tamara.RunAction(new CCRepeatForever (seq));

            Schedule(repositionSprite);
        }
コード例 #39
0
ファイル: TileMapTest.cs プロジェクト: rtabbara/cocos2d-xna
        public TMXIsoZorder()
        {
            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/iso-test-zorder");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;
            CCLog.Log("ContentSize: {0}, {1}", s.Width, s.Height);
            map.Position = new CCPoint(-s.Width / 2, 0);

            m_tamara = new CCSprite(s_pPathSister1);
            map.AddChild(m_tamara, map.Children.Count);
            float mapWidth = map.MapSize.Width * map.TileSize.Width;
            m_tamara.Position = CCMacros.CCPointPixelsToPoints(new CCPoint(mapWidth / 2, 0));
            m_tamara.AnchorPoint = (new CCPoint(0.5f, 0));


            CCMoveBy move = new CCMoveBy (10, new CCPoint(300, 250));
            CCFiniteTimeAction back = move.Reverse();
            CCSequence seq = new CCSequence(move, back);
            m_tamara.RunAction(new CCRepeatForever (seq));

            Schedule(repositionSprite);
        }
コード例 #40
0
ファイル: TileMapTest.cs プロジェクト: rtabbara/cocos2d-xna
        public TMXReadWriteTest()
        {
            m_gid = 0;

            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test2");
            AddChild(map, 0, kTagTileMap);

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

            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 seq0 = new CCSequence(move, rotate, scale, opacity, fadein, scaleback, finish);
            var seq1 = (CCActionInterval) (seq0.Copy());
            var seq2 = (CCActionInterval) (seq0.Copy());
            var seq3 = (CCActionInterval) (seq0.Copy());

            tile0.RunAction(seq0);
            tile1.RunAction(seq1);
            tile2.RunAction(seq2);
            tile3.RunAction(seq3);


            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;
        }
コード例 #41
0
ファイル: TileMapTest.cs プロジェクト: rtabbara/cocos2d-xna
        public TMXOrthoVertexZ()
        {
            CCTMXTiledMap map = CCTMXTiledMap.Create("TileMaps/orthogonal-test-vertexz");
            AddChild(map, 0, kTagTileMap);

            CCSize s = map.ContentSize;

            // because I'm lazy, I'm reusing a tile as an sprite, but since this method uses vertexZ, you
            // can use any CCSprite and it will work OK.
            CCTMXLayer layer = map.LayerNamed("trees");
            m_tamara = layer.TileAt(new CCPoint(0, 11));
            CCLog.Log("tamara vertexZ: {0}", m_tamara.VertexZ);

            CCMoveBy move = new CCMoveBy (10, new CCPoint(400, 450) * (1f / CCMacros.CCContentScaleFactor()));
            CCFiniteTimeAction back = move.Reverse();
            CCSequence seq = new CCSequence(move, back);
            m_tamara.RunAction(new CCRepeatForever (seq));

            Schedule(repositionSprite);
        }
コード例 #42
0
ファイル: EaseActionsTest.cs プロジェクト: Karunp/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            var size = CCDirector.SharedDirector.WinSize;

            var move = new CCMoveBy (3, new CCPoint(size.Width - 130, 0));
            var move_back = (CCActionInterval) move.Reverse();

            var move_ease_in = new CCEaseIn((CCActionInterval) move.Copy(), 2.5f);
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out = new CCEaseOut((CCActionInterval) move.Copy(), 2.5f);
            var move_ease_out_back = move_ease_out.Reverse();

            var delay = new CCDelayTime (0.25f);

            var seq1 = new CCSequence(move, delay, move_back, (CCFiniteTimeAction) delay.Copy());
            var seq2 = new CCSequence(move_ease_in, (CCFiniteTimeAction) delay.Copy(), move_ease_in_back, (CCFiniteTimeAction) delay.Copy());
            var seq3 = new CCSequence(move_ease_out, (CCFiniteTimeAction) delay.Copy(), move_ease_out_back,
                                                (CCFiniteTimeAction) delay.Copy());

            var a2 = m_grossini.RunAction(new CCRepeatForever ((CCActionInterval)seq1));
            a2.Tag = 1;

            var a1 = m_tamara.RunAction(new CCRepeatForever ((CCActionInterval)seq2));
            a1.Tag = 1;

            var a = m_kathia.RunAction(new CCRepeatForever ((CCActionInterval)seq3));
            a.Tag = 1;

            Schedule(testStopAction, 6.25f);
        }
コード例 #43
0
ファイル: EaseActionsTest.cs プロジェクト: Karunp/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            // rotate and jump
            var jump1 = new CCJumpBy (4, new CCPoint(-s.Width + 80, 0), 100, 4);
            var jump2 = jump1.Reverse();
            var rot1 = new CCRotateBy (4, 360 * 2);
            var rot2 = rot1.Reverse();

            var seq3_1 = new CCSequence(jump2, jump1);
            var seq3_2 = new CCSequence(rot1, rot2);
            var spawn = new CCSpawn(seq3_1, seq3_2);
            var action = new CCSpeed (new CCRepeatForever (spawn), 1.0f);
            action.Tag = EaseTest.kTagAction1;

            var action2 = (CCAction) (action.Copy());
            var action3 = (CCAction) (action.Copy());

            action2.Tag = EaseTest.kTagAction1;
            action3.Tag = EaseTest.kTagAction1;

            m_grossini.RunAction(action2);
            m_tamara.RunAction(action3);
            m_kathia.RunAction(action);

            Schedule(altertime, 1.0f);
        }
コード例 #44
0
ファイル: EaseActionsTest.cs プロジェクト: Karunp/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            var move = new CCMoveBy (3, new CCPoint(s.Width - 130, 0));
            var move_back = move.Reverse();

            var move_ease = new CCEaseBackInOut((CCActionInterval) (move.Copy()));
            var move_ease_back = move_ease.Reverse() as CCActionInterval;

            var delay = new CCDelayTime (0.25f);

            var seq1 = new CCSequence(move, delay, move_back, (CCFiniteTimeAction) delay.Copy());
            var seq2 = new CCSequence(move_ease, (CCFiniteTimeAction) delay.Copy(), move_ease_back, (CCFiniteTimeAction) delay.Copy());

            positionForTwo();

            m_grossini.RunAction(new CCRepeatForever (seq1));
            m_tamara.RunAction(new CCRepeatForever (seq2));
        }
コード例 #45
0
ファイル: EaseActionsTest.cs プロジェクト: Karunp/cocos2d-xna
        public override void OnEnter()
        {
            base.OnEnter();

            var s = CCDirector.SharedDirector.WinSize;

            var move = new CCMoveBy (3, new CCPoint(s.Width - 130, 0));
            var move_back = move.Reverse();

            var move_ease_in = new CCEaseBounceIn((CCActionInterval) (move.Copy()));
            var move_ease_in_back = move_ease_in.Reverse();

            var move_ease_out = new CCEaseBounceOut((CCActionInterval) (move.Copy()));
            var move_ease_out_back = move_ease_out.Reverse();

            var delay = new CCDelayTime (0.25f);

            var seq1 = new CCSequence(move, delay, move_back, (CCFiniteTimeAction) delay.Copy());
            var seq2 = new CCSequence(move_ease_in, (CCFiniteTimeAction) delay.Copy(), move_ease_in_back, (CCFiniteTimeAction) delay.Copy());
            var seq3 = new CCSequence(move_ease_out, (CCFiniteTimeAction) delay.Copy(), move_ease_out_back,
                                                (CCFiniteTimeAction) delay.Copy());

            m_grossini.RunAction(new CCRepeatForever (seq1));
            m_tamara.RunAction(new CCRepeatForever (seq2));
            m_kathia.RunAction(new CCRepeatForever (seq3));
        }
コード例 #46
0
        public void RunAnimations(int nSeqId, float fTweenDuration)
        {
            Debug.Assert(nSeqId != -1, "Sequence id couldn't be found");

            mRootNode.StopAllActions();

            foreach (var pElement in mNodeSequences)
            {
                CCNode node = pElement.Key;
                node.StopAllActions();

                // Refer to CCBReader::readKeyframe() for the real type of value
                Dictionary <int, Dictionary <string, CCBSequenceProperty> > seqs = pElement.Value;

                var seqNodePropNames = new List <string>();

                Dictionary <string, CCBSequenceProperty> seqNodeProps;
                if (seqs.TryGetValue(nSeqId, out seqNodeProps))
                {
                    // Reset nodes that have sequence node properties, and run actions on them
                    foreach (var pElement1 in seqNodeProps)
                    {
                        string propName             = pElement1.Key;
                        CCBSequenceProperty seqProp = pElement1.Value;
                        seqNodePropNames.Add(propName);

                        SetFirstFrame(node, seqProp, fTweenDuration);
                        RunAction(node, seqProp, fTweenDuration);
                    }
                }

                // Reset the nodes that may have been changed by other timelines
                Dictionary <string, object> nodeBaseValues;
                if (mBaseValues.TryGetValue(node, out nodeBaseValues))
                {
                    foreach (var pElement2 in nodeBaseValues)
                    {
                        if (!seqNodePropNames.Contains(pElement2.Key))
                        {
                            object value = pElement2.Value;

                            if (value != null)
                            {
                                SetAnimatedProperty(pElement2.Key, node, value, fTweenDuration);
                            }
                        }
                    }
                }
            }

            // Make callback at end of sequence
            CCBSequence seq            = GetSequence(nSeqId);
            CCAction    completeAction = new CCSequence(
                new CCDelayTime(seq.Duration + fTweenDuration),
                new CCCallFunc(SequenceCompleted)
                );

            mRootNode.RunAction(completeAction);

            // Set the running scene
            mRunningSequence = GetSequence(nSeqId);
        }