예제 #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
        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:)];
        }
예제 #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
        /**
         * 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);
        }
예제 #5
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);
        }
예제 #6
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);
        }
예제 #7
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 = CCSequence.FromActions(actions.ToArray());
                    node.RunAction(seq);
                }
                else
                {
                    node.RunAction(actions[0]);
                }
            }
        }
예제 #8
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 = CCSequence.FromActions
                  (
                new CCDelayTime(m_fDuration / 2),
                new CCShow(),
                new CCOrbitCamera(m_fDuration / 2, 1, 0, inAngleZ, inDeltaZ, 90, 0),
                new CCCallFunc(Finish)
                  );
            outA = CCSequence.FromActions
                   (
                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);
        }
예제 #9
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);
        }
        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))
                )
            );
        }
예제 #11
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);
        }