Esempio n. 1
0
        public override CCObject copyWithZone(CCZone zone)
        {
            CCZone   cCZone   = zone;
            CCRepeat cCRepeat = null;

            if (cCZone == null || cCZone.m_pCopyObject == null)
            {
                cCRepeat = new CCRepeat();
                cCZone   = new CCZone(cCRepeat);
            }
            else
            {
                cCRepeat = cCZone.m_pCopyObject as CCRepeat;
                if (cCRepeat == null)
                {
                    return(null);
                }
            }
            base.copyWithZone(cCZone);
            CCFiniteTimeAction cCFiniteTimeAction = this.m_pInnerAction.copy() as CCFiniteTimeAction;

            if (cCFiniteTimeAction == null)
            {
                return(null);
            }
            cCRepeat.initWithAction(cCFiniteTimeAction, this.m_uTimes);
            return(cCRepeat);
        }
Esempio n. 2
0
        public static CCRepeat actionWithAction(CCFiniteTimeAction action, uint times)
        {
            CCRepeat cCRepeat = new CCRepeat();

            cCRepeat.initWithAction(action, times);
            return(cCRepeat);
        }
Esempio n. 3
0
        public override void update(float dt)
        {
            float single = dt * (float)((float)this.m_uTimes);

            if (single <= (float)((float)(this.m_uTotal + 1)))
            {
                float single1 = single % 1f;
                if (dt == 1f)
                {
                    single1 = 1f;
                    CCRepeat mUTotal = this;
                    mUTotal.m_uTotal = mUTotal.m_uTotal + 1;
                }
                this.m_pInnerAction.update((single1 > 1f ? 1f : single1));
                return;
            }
            this.m_pInnerAction.update(1f);
            CCRepeat cCRepeat = this;

            cCRepeat.m_uTotal = cCRepeat.m_uTotal + 1;
            this.m_pInnerAction.stop();
            this.m_pInnerAction.startWithTarget(this.m_pTarget);
            if (this.m_uTotal == this.m_uTimes)
            {
                this.m_pInnerAction.update(0f);
                return;
            }
            this.m_pInnerAction.update(single - (float)((float)this.m_uTotal));
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        /// <summary>
        /// ��һ���ڳ��������һ����̬��bird����
        /// �ڶ�����bird�����ж���
        /// ����������box-2d����������bird�������������
        /// </summary>
        private void AddBird()
        {
            CCSprite bird = CCSprite.spriteWithFile("imgs/bird/bird_01");
            bird.rotation = -15;

            // bird���ж���֡����
            List<CCSpriteFrame> frames = new List<CCSpriteFrame>();

            for (int i = 1; i < 3; i++)
            {
                // ֡��ͼ
                CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage("imgs/bird/bird_0" + i);

                // �������һ�������bug����������õĻ����ͻᲥ�Ų���������
                texture.Name = (uint)i;
                var frame = CCSpriteFrame.frameWithTexture(texture, new CCRect(0, 0, texture.ContentSizeInPixels.width, texture.ContentSizeInPixels.height));
                frames.Add(frame);
            }

            // �����
            CCAnimation marmotShowanimation = CCAnimation.animationWithFrames(frames, 0.1f);
            CCAnimate flyAction = CCAnimate.actionWithAnimation(marmotShowanimation, false);
            flyRepeatAction = CCRepeat.actionWithAction(flyAction, 2);
            flyRepeatAction.tag = 0;
            bird.runAction(flyRepeatAction);

            // �����������ж���һ��body��������λ�ã�����bird��֮��Ӧ
            b2BodyDef ballBodyDef = new b2BodyDef();
            ballBodyDef.type = b2BodyType.b2_dynamicBody;
            ballBodyDef.position = new b2Vec2(AppDelegate.screenSize.width / PTM_RATIO / 2, (float)(AppDelegate.screenSize.height / PTM_RATIO));
            ballBodyDef.userData = bird;
            birdBody = world.CreateBody(ballBodyDef);

            // Ϊbody������״��������һЩ��������
            b2PolygonShape shape = new b2PolygonShape();
            shape.SetAsBox(bird.contentSize.width / 2 / PTM_RATIO, bird.contentSize.height / 2 / PTM_RATIO);
            b2FixtureDef fixtureDef = new b2FixtureDef();
            fixtureDef.shape = shape;
            fixtureDef.density = 500.0f;
            fixtureDef.friction = 0.5f;
            birdBody.CreateFixture(fixtureDef);

            this.addChild(bird);
        }
Esempio n. 6
0
        /// <summary>
        /// 加载图片
        /// </summary>
        private void LoadPicture()
        {
            String picpath = String.Empty;
            if (IsTruePeople)
            {
                picpath = TruePicturePath;
            }
            else
            {
                picpath = FailPicturePath;
            }
            Picture = Media.PictureManager.GetCCTexture2DWithFile(picpath);
            List<CCSpriteFrame> frames = new List<CCSpriteFrame>();

            for (int i = 0; i < FrameNumber; i++)
            {
                CCSpriteFrame frame = CCSpriteFrame.frameWithTexture(Picture, new CCRect(i * PicWidth, 0, PicWidth, PicHeight));
                frames.Add(frame);
            }
            CCAnimation ani = CCAnimation.animationWithFrames(frames);
            this.initWithSpriteFrame(frames[0]);
            CCAnimate anima = CCAnimate.actionWithDuration(1f, ani, true);
            action = CCRepeat.actionWithAction(anima.reverse(), 3);
        }
Esempio n. 7
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(2);

            var act1 = new CCRotateTo (1, 90);
            var act2 = new CCRotateTo (1, 0);
            var seq = (CCSequence.FromActions(act1, act2));
            var rep1 = new CCRepeatForever ((CCActionInterval)seq);
            var rep2 = new CCRepeat ((CCFiniteTimeAction)(seq.Copy()), 10);

            m_tamara.RunAction(rep1);
            m_kathia.RunAction(rep2);
        }
Esempio n. 8
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(2);

            var seq = CCSequence.FromActions(
                new CCRotateTo (0.5f, -20),
                new CCRotateTo (0.5f, 20));

            var rep1 = new CCRepeat (seq, 10);
            var rep2 = new CCRepeatForever ((CCActionInterval)(seq.Copy()));

            m_tamara.RunAction(rep1);
            m_kathia.RunAction(rep2);
        }
Esempio n. 9
0
        public override void OnEnter()
        {
            base.OnEnter();

            alignSpritesLeft(2);

            // Test:
            //   Sequence should work both with IntervalAction and InstantActions
            var move1 = new CCMoveBy (1, new CCPoint(250, 0));
            var move2 = new CCMoveBy (1, new CCPoint(0, 50));
            var tog1 = new CCToggleVisibility();
            var tog2 = new CCToggleVisibility();
            var seq = CCSequence.FromActions(move1, tog1, move2, tog2, move1.Reverse());
            var action = new CCRepeat ((CCSequence.FromActions(seq, seq.Reverse())), 3);

            // Test:
            //   Also test that the reverse of Hide is Show, and vice-versa
            m_kathia.RunAction(action);

            var move_tamara = new CCMoveBy (1, new CCPoint(100, 0));
            var move_tamara2 = new CCMoveBy (1, new CCPoint(50, 0));
            var hide = new CCHide();
            var seq_tamara = CCSequence.FromActions(move_tamara, hide, move_tamara2);
            var seq_back = seq_tamara.Reverse();
            m_tamara.RunAction(CCSequence.FromActions(seq_tamara, seq_back));
        }
Esempio n. 10
0
        public override void OnEnter()
        {
            base.OnEnter();

            alignSpritesLeft(2);

            var a1 = new CCMoveBy (1, new CCPoint(150, 0));
            var action1 = new CCRepeat (
                CCSequence.FromActions(new CCPlace(new CCPoint(60, 60)), a1),
                3);
            var action2 = new CCRepeatForever (
                (CCSequence.FromActions((CCActionInterval) (a1.Copy()), a1.Reverse()))
                );

            m_kathia.RunAction(action1);
            m_tamara.RunAction(action2);
        }
Esempio n. 11
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(0);

            var spr = new CCSprite("Images/grossini");
            spr.Position = new CCPoint(100, 100);
            AddChild(spr);

            var act1 = new CCMoveBy (0.5f, new CCPoint(100, 0));
            var act2 = (CCMoveBy) act1.Reverse();
            var act3 = CCSequence.FromActions(act1, act2);
            var act4 = new CCRepeat (act3, 2);

            spr.RunAction(act4);
        }
Esempio n. 12
0
 public override CCFiniteTimeAction reverse()
 {
     return(CCRepeat.actionWithAction(this.m_pInnerAction.reverse(), this.m_uTimes));
 }