Пример #1
0
        public static CCMoveTo actionWithDuration(float duration, CCPoint position)
        {
            CCMoveTo cCMoveTo = new CCMoveTo();

            cCMoveTo.initWithDuration(duration, position);
            return(cCMoveTo);
        }
Пример #2
0
        /** creates the action */
        public static CCMoveTo actionWithDuration(float duration, CCPoint position)
        {
            CCMoveTo moveTo = new CCMoveTo();
            moveTo.initWithDuration(duration, position);

            return moveTo;
        }
Пример #3
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 = CCLabelTTF.labelWithString(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().getWinSize().height - inputTextSize.height * 2);

            float duration = 0.5f;

            label.position = beginPos;
            label.scale    = 8;

            CCAction seq = CCSequence.actions(
                CCSpawn.actions(
                    CCMoveTo.actionWithDuration(duration, endPos),
                    CCScaleTo.actionWithDuration(duration, 1),
                    CCFadeOut.actionWithDuration(duration)),
                CCCallFuncN.actionWithTarget(this, callbackRemoveNodeWhenDidAction));

            label.runAction(seq);
            return(false);
        }
Пример #4
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone   cCZone   = zone;
            CCMoveTo cCMoveTo = null;

            if (cCZone == null || cCZone.m_pCopyObject == null)
            {
                cCMoveTo = new CCMoveTo();
                cCZone   = new CCZone(cCMoveTo);
            }
            else
            {
                cCMoveTo = (CCMoveTo)cCZone.m_pCopyObject;
            }
            base.copyWithZone(cCZone);
            cCMoveTo.initWithDuration(this.m_fDuration, this.m_endPosition);
            return(cCMoveTo);
        }
Пример #5
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone tmpZone = zone;
            CCMoveTo ret = null;

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

            base.copyWithZone(tmpZone);
            ret.initWithDuration(Duration, m_endPosition);

            return ret;
        }
Пример #6
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone   tmpZone = zone;
            CCMoveTo ret     = null;

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

            base.copyWithZone(tmpZone);
            ret.initWithDuration(Duration, m_endPosition);

            return(ret);
        }
Пример #7
0
        public virtual bool onTextFieldDeleteBackward(CCTextFieldTTF pSender, string delText, int nLen)
        {
            // create a delete text sprite and do some action
            CCLabelTTF label = CCLabelTTF.labelWithString(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;
            Random rand     = new Random();

            CCSize  winSize        = CCDirector.sharedDirector().getWinSize();
            CCPoint endPos         = new CCPoint(-winSize.width / 4.0f, winSize.height * (0.5f + (float)rand.Next() / (2.0f * RAND_MAX)));
            float   duration       = 1;
            float   rotateDuration = 0.2f;
            int     repeatTime     = 5;

            label.position = beginPos;

            CCAction seq = CCSequence.actions(
                CCSpawn.actions(
                    CCMoveTo.actionWithDuration(duration, endPos),
                    CCRepeat.actionWithAction(
                        CCRotateBy.actionWithDuration(rotateDuration, (rand.Next() % 2 > 0) ? 360 : -360),
                        (uint)repeatTime),
                    CCFadeOut.actionWithDuration(duration)),
                CCCallFuncN.actionWithTarget(this, callbackRemoveNodeWhenDidAction));

            label.runAction(seq);
            return(false);
        }
Пример #8
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);
 }
Пример #9
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            var s = CCDirector.SharedDirector.WinSize;

            var actionTo = new CCMoveTo (2, new CCPoint(s.Width - 40, s.Height - 40));
            var actionBy = new CCMoveBy (2, new CCPoint(80, 80));
            var actionByBack = actionBy.Reverse();

            m_tamara.RunAction(actionTo);
            m_grossini.RunAction(CCSequence.FromActions(actionBy, actionByBack));
            m_kathia.RunAction(new CCMoveTo (1, new CCPoint(40, 40)));
        }
Пример #10
0
        void ShowPointsWithImagesForValue(int pointValue, CCPoint positionToShowScore)
        {
            CCSprite scoreLabel;

            if (pointValue == 100) {

                scoreLabel = new CCSprite ("100points.png");
            }
            else if (pointValue == 500) {

                scoreLabel = new CCSprite ("500points.png");
            }
            else if (pointValue == 1000) {

                scoreLabel = new CCSprite ("1000points.png");
            }
            else if (pointValue == 5000) {

                scoreLabel = new CCSprite ("5000points.png");
            }
            else if (pointValue == 10000) {

                scoreLabel = new CCSprite ("10000points.png");
            }
            else { //default

                scoreLabel = new CCSprite ("100points.png");

            }

            AddChild(scoreLabel, Constants.DepthPointScore);
            scoreLabel.Position = positionToShowScore;

            CCMoveTo moveAction = new CCMoveTo(1.0f, new CCPoint ( scoreLabel.Position.X  , scoreLabel.Position.Y + 25 ));

            scoreLabel.RunAction(moveAction);

            CCSequence seq = CCSequence.FromActions(
                               new CCFadeTo(1.5f, 20),
                               new CCCallFuncN(RemoveThisChild));

            scoreLabel.RunAction(seq);
        }
Пример #11
0
        void ShowPointsWithFontLabelForValue(int pointValue, CCPoint positionToShowScore)
        {
            CCLabelTTF scoreLabel = new CCLabelTTF(string.Format("{0}", pointValue), "MarkerFelt", 22);
            AddChild(scoreLabel, Constants.DepthPointScore);
            scoreLabel.Color = new CCColor3B(255,255,255);
            scoreLabel.Position = positionToShowScore;

            CCMoveTo moveAction = new CCMoveTo(1.0f, new CCPoint ( scoreLabel.Position.X  , scoreLabel.Position.Y + 25 ));

            scoreLabel.RunAction(moveAction);

            CCSequence seq = CCSequence.FromActions(
                new CCFadeTo(1.5f, 20),
                new CCCallFuncN(RemoveThisLabel));

            scoreLabel.RunAction(seq);
        }
Пример #12
0
 public virtual CCActionInterval action()
 {
     return(CCMoveTo.actionWithDuration(this.m_fDuration, new CCPoint(0f, 0f)));
 }