예제 #1
0
        /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
        public static CCRepeat actionWithAction(CCFiniteTimeAction action, uint times)
        {
            CCRepeat ret = new CCRepeat();
            ret.initWithAction(action, times);

            return ret;
        }
예제 #2
0
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            float aspect = Scene.Viewport.AspectRatio;
            var   x      = (int)(12 * aspect);
            int   y      = 12;

            action = CreateAction(new CCGridSize(x, y));
        }
예제 #3
0
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            float aspect = Scene.Viewport.AspectRatio;
            var x = (int) (12 * aspect);
            int y = 12;

            action = CreateAction(new CCGridSize(x, y));
        }
예제 #4
0
 protected bool InitWithTarget(CCNode target, CCFiniteTimeAction pAction)
 {
     if (base.InitWithDuration(pAction.Duration))
     {
         m_pForcedTarget = target;
         m_pAction = pAction;
         return true;
     }
     return false;
 }
예제 #5
0
        public void disableMenuCallback(object pSender)
        {
            m_pMenu1.Enabled = false;
            CCDelayTime wait   = new CCDelayTime(5);
            CCCallFunc  enable = new CCCallFunc(enableMenuCallback);

            CCFiniteTimeAction seq = CCSequence.FromActions(wait, enable);

            m_pMenu1.RunAction(seq);
        }
예제 #6
0
 protected bool InitWithTarget(CCNode target, CCFiniteTimeAction pAction)
 {
     if (base.InitWithDuration(pAction.Duration))
     {
         m_pForcedTarget = target;
         m_pAction       = pAction;
         return(true);
     }
     return(false);
 }
예제 #7
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);
        }
예제 #8
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);
        }
예제 #9
0
        public override void onEnter()
        {
            base.onEnter();

            alignSpritesLeft(1);

            CCActionInterval   move   = CCMoveBy.actionWithDuration(1, new CCPoint(150, 0));
            CCFiniteTimeAction action = CCSequence.actions(move, CCDelayTime.actionWithDuration(2), move);

            m_grossini.runAction(action);
        }
예제 #10
0
        public override void onEnter()
        {
            base.onEnter();

            alignSpritesLeft(1);

            CCActionInterval   jump   = CCJumpBy.actionWithDuration(2, new CCPoint(300, 0), 50, 4);
            CCFiniteTimeAction action = CCSequence.actions(jump, jump.reverse());

            m_grossini.runAction(action);
        }
예제 #11
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(1);

            CCFiniteTimeAction action = CCSequence.actions(CCMoveBy.actionWithDuration(2.0f, new CCPoint(200, 0)));

            //CCCallFuncND::actionWithTarget(m_grossini, callfuncND_selector(ActionCallFuncND::removeFromParentAndCleanup), (void*)true),

            m_grossini.runAction(action);
        }
예제 #12
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);
        }
예제 #13
0
        public SpriteBatchNodeOffsetAnchorFlip()
        {
            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;

            cache.AddSpriteFrames("animations/grossini.plist");
            cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray");

            // Create animations and actions

            var    animFrames = new List <CCSpriteFrame>();
            string tmp        = "";

            for (int j = 0; j < 14; j++)
            {
                string temp = "";
                if (j + 1 < 10)
                {
                    temp = "0" + (j + 1);
                }
                else
                {
                    temp = (j + 1).ToString();
                }

                tmp = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = cache[tmp];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.3f);


            CCFlipY     flip      = new CCFlipY(true);
            CCFlipY     flip_back = new CCFlipY(false);
            CCDelayTime delay     = new CCDelayTime(1);

            seq = new CCSequence(delay, flip, delay, flip_back);

            sprites      = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

            for (int i = 0; i < numOfSprites; i++)
            {
                // Animation using Sprite batch
                sprites[i]      = new CCSprite("grossini_dance_01.png");
                pointSprites[i] = new CCSprite("Images/r1");

                CCSpriteBatchNode spritebatch = new CCSpriteBatchNode("animations/grossini");
                AddChild(spritebatch);
                AddChild(pointSprites[i], 200);
                spritebatch.AddChild(sprites[i], i);
            }
        }
예제 #14
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(1);

            CCFiniteTimeAction action = CCSequence.actions(
                CCDelayTime.actionWithDuration(1),
                CCCallFuncN.actionWithTarget(this, new SEL_CallFuncN(repeatForever)));

            m_grossini.runAction(action);
        }
예제 #15
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(2);

            CCActionInterval   action1     = CCTintTo.actionWithDuration(2, 255, 0, 255);
            CCActionInterval   action2     = CCTintBy.actionWithDuration(2, -127, -255, -127);
            CCFiniteTimeAction action2Back = action2.reverse();

            m_tamara.runAction(action1);
            m_kathia.runAction(CCSequence.actions(action2, action2Back));
        }
예제 #16
0
        public CCRepeat(CCFiniteTimeAction action, uint times) : base(action.Duration * times)
        {
            Times       = times;
            InnerAction = action;

            ActionInstant = action is CCActionInstant;
            //an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action
            if (ActionInstant)
            {
                Times -= 1;
            }
            Total = 0;
        }
예제 #17
0
        public override void onEnter()
        {
            base.onEnter();

            alignSpritesLeft(1);

            CCActionInterval   move1  = CCMoveBy.actionWithDuration(1, new CCPoint(250, 0));
            CCActionInterval   move2  = CCMoveBy.actionWithDuration(1, new CCPoint(0, 50));
            CCFiniteTimeAction seq    = CCSequence.actions(move1, move2, move1.reverse());
            CCFiniteTimeAction action = CCSequence.actions(seq, seq.reverse());

            m_grossini.runAction(action);
        }
예제 #18
0
        void LoadStartLabels()
        {
            var bounds = mainLayer.VisibleBoundsWorldspace;
            var center = bounds.Center;

            var scaleAction = new CCScaleBy(0.5f, 1.0f, 1.5f);
            var fadeAction  = new CCFadeIn(0.5f);

            scaleLabelAction = new CCSequence(new CCSpawn(scaleAction, fadeAction),
                                              new CCEaseElasticInOut(scaleAction.Reverse(), 1.0f));

            tintLabelAction = new CCSequence(new CCTintTo(1.0f, 100, 152, 219),
                                             new CCTintTo(1.0f, 255, 255, 255));
        }
예제 #19
0
        public CCRepeat (CCFiniteTimeAction action, uint times) : base (action.Duration * times)
        {

            Times = times;
            InnerAction = action;

            ActionInstant = action is CCActionInstant;
            //an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action
            if (ActionInstant)
            {
                Times -= 1;
            }
            Total = 0;
        }
예제 #20
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(3);

            CCActionInterval   actionTo     = CCJumpTo.actionWithDuration(2, new CCPoint(300, 300), 50, 4);
            CCActionInterval   actionBy     = CCJumpBy.actionWithDuration(2, new CCPoint(300, 0), 50, 4);
            CCActionInterval   actionUp     = CCJumpBy.actionWithDuration(2, new CCPoint(0, 0), 80, 4);
            CCFiniteTimeAction actionByBack = actionBy.reverse();

            m_tamara.runAction(actionTo);
            m_grossini.runAction(CCSequence.actions(actionBy, actionByBack));
            m_kathia.runAction(CCRepeatForever.actionWithAction(actionUp));
        }
예제 #21
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(3);

            CCActionInterval   actionTo     = CCScaleTo.actionWithDuration(2, 0.5f);
            CCActionInterval   actionBy     = CCScaleBy.actionWithDuration(2, 2);
            CCActionInterval   actionBy2    = CCScaleBy.actionWithDuration(2, 0.25f, 4.5f);
            CCFiniteTimeAction actionByBack = actionBy.reverse();

            m_tamara.runAction(actionTo);
            m_grossini.runAction(CCSequence.actions(actionBy, actionByBack));
            m_kathia.runAction(CCSequence.actions(actionBy2, actionBy2.reverse()));
        }
예제 #22
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSprite bg = new CCSprite("Images/background3");

            AddChild(bg, 0, EffectAdvanceScene.kTagBackground);
            bg.Position = CCVisibleRect.Center;

            grossini = new CCSprite("Images/grossinis_sister2");
            bg.AddChild(grossini, 1, EffectAdvanceScene.kTagSprite1);
            grossini.Position = new CCPoint(CCVisibleRect.Left.X + CCVisibleRect.VisibleRect.Size.Width / 3,
                                            CCVisibleRect.Center.Y);
            CCActionInterval   sc      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc_back = sc.Reverse();

            grossini.RunAction(new CCRepeatForever((CCActionInterval)(new CCSequence(sc, sc_back))));

            tamara = new CCSprite("Images/grossinis_sister1");
            bg.AddChild(tamara, 1, EffectAdvanceScene.kTagSprite2);
            tamara.Position = new CCPoint(CCVisibleRect.Left.X + 2 * CCVisibleRect.VisibleRect.Size.Width / 3,
                                          CCVisibleRect.Center.Y);
            CCActionInterval   sc2      = new CCScaleBy(2, 5);
            CCFiniteTimeAction sc2_back = sc2.Reverse();

            tamara.RunAction(new CCRepeatForever((CCActionInterval)(new CCSequence(sc2, sc2_back))));

            CCLabelTTF label = new CCLabelTTF(title(), "arial", 28);

            label.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Top.Y - 80);
            AddChild(label);
            label.Tag = EffectAdvanceScene.kTagLabel;

            CCMenuItemImage item1 = new CCMenuItemImage("Images/b1", "Images/b2", backCallback);
            CCMenuItemImage item2 = new CCMenuItemImage("Images/r1", "Images/r2", restartCallback);
            CCMenuItemImage item3 = new CCMenuItemImage("Images/f1", "Images/f2", nextCallback);

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

            menu.Position  = CCPoint.Zero;
            item1.Position = new CCPoint(CCVisibleRect.Center.X - item2.ContentSize.Width * 2,
                                         CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
            item2.Position = new CCPoint(CCVisibleRect.Center.X, CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);
            item3.Position = new CCPoint(CCVisibleRect.Center.X + item2.ContentSize.Width * 2,
                                         CCVisibleRect.Bottom.Y + item2.ContentSize.Height / 2);

            AddChild(menu, 1);
        }
예제 #23
0
        public Atlas3()
        {
            m_time = 0;

            CCLayerColor col = CCLayerColor.layerWithColor(new ccColor4B(128, 128, 128, 255));

            addChild(col, -10);

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

            // testing anchors
            label1.anchorPoint = new CCPoint(0, 0);
            addChild(label1, 0, (int)TagSprite.kTagBitmapAtlas1);
            CCActionInterval   fade    = CCFadeOut.actionWithDuration(1.0f);
            CCFiniteTimeAction fade_in = fade.reverse();
            CCFiniteTimeAction seq     = CCSequence.actions(fade, fade_in);
            CCAction           repeat  = CCRepeatForever.actionWithAction((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 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2");

            // 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 = CCLabelBMFont.labelWithString("Test", "fonts/fnt/bitmapFontTest2");

            // testing anchors
            label3.anchorPoint = new CCPoint(1, 1);
            addChild(label3, 0, (int)TagSprite.kTagBitmapAtlas3);


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

            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:)];
        }
예제 #24
0
        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:)];
        }
        public SpriteBatchNodeColorOpacity()
        {
            // 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);

            sprite1 = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
            sprite2 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
            sprite3 = new CCSprite(batch.Texture, new CCRect(85 * 2, 121 * 1, 85, 121));
            sprite4 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 1, 85, 121));

            sprite5 = new CCSprite(batch.Texture, new CCRect(85 * 0, 121 * 1, 85, 121));
            sprite6 = new CCSprite(batch.Texture, new CCRect(85 * 1, 121 * 1, 85, 121));
            sprite7 = new CCSprite(batch.Texture, new CCRect(85 * 2, 121 * 1, 85, 121));
            sprite8 = new CCSprite(batch.Texture, new CCRect(85 * 3, 121 * 1, 85, 121));


            CCFiniteTimeAction action      = new CCFadeIn(2);
            CCFiniteTimeAction action_back = (CCFiniteTimeAction)action.Reverse();

            fade = new CCRepeatForever((CCFiniteTimeAction)(new CCSequence(action, action_back)));

            CCFiniteTimeAction tintred      = new CCTintBy(2, 0, -255, -255);
            CCFiniteTimeAction tintred_back = (CCFiniteTimeAction)tintred.Reverse();

            red = new CCRepeatForever((CCFiniteTimeAction)(new CCSequence(tintred, tintred_back)));

            CCFiniteTimeAction tintgreen      = new CCTintBy(2, -255, 0, -255);
            CCFiniteTimeAction tintgreen_back = (CCFiniteTimeAction)tintgreen.Reverse();

            green = new CCRepeatForever((CCFiniteTimeAction)(new CCSequence(tintgreen, tintgreen_back)));

            CCFiniteTimeAction tintblue      = new CCTintBy(2, -255, -255, 0);
            CCFiniteTimeAction tintblue_back = (CCFiniteTimeAction)tintblue.Reverse();

            blue = new CCRepeatForever((CCFiniteTimeAction)(new CCSequence(tintblue, tintblue_back)));

            batch.AddChild(sprite1, 0, (int)kTagSprite.kTagSprite1);
            batch.AddChild(sprite2, 0, (int)kTagSprite.kTagSprite2);
            batch.AddChild(sprite3, 0, (int)kTagSprite.kTagSprite3);
            batch.AddChild(sprite4, 0, (int)kTagSprite.kTagSprite4);
            batch.AddChild(sprite5, 0, (int)kTagSprite.kTagSprite5);
            batch.AddChild(sprite6, 0, (int)kTagSprite.kTagSprite6);
            batch.AddChild(sprite7, 0, (int)kTagSprite.kTagSprite7);
            batch.AddChild(sprite8, 0, (int)kTagSprite.kTagSprite8);
        }
        public SpriteOffsetAnchorSkewScale()
        {
            sprites      = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

            // Create actions

            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;

            cache.AddSpriteFrames("animations/grossini.plist");
            cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray");
            var    animFrames = new List <CCSpriteFrame>();
            string tmp        = "";

            for (int j = 0; j < 14; j++)
            {
                tmp = string.Format("grossini_dance_{0:00}.png", j + 1);
                CCSpriteFrame frame = cache[tmp];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.3f);

            // Skew
            CCSkewBy           skewX      = new CCSkewBy(2, 45, 0);
            CCFiniteTimeAction skewX_back = (CCFiniteTimeAction)skewX.Reverse();
            CCSkewBy           skewY      = new CCSkewBy(2, 0, 45);
            CCFiniteTimeAction skewY_back = (CCFiniteTimeAction)skewY.Reverse();

            seq_skew = new CCSequence(skewX, skewX_back, skewY, skewY_back);

            // Scale
            CCScaleBy          scale      = new CCScaleBy(2, 2);
            CCFiniteTimeAction scale_back = (CCFiniteTimeAction)scale.Reverse();

            seq_scale = new CCSequence(scale, scale_back);


            for (int i = 0; i < numOfSprites; i++)
            {
                // Animation using Sprite batch
                sprites[i] = new CCSprite("grossini_dance_01.png");
                AddChild(sprites[i], 0);

                pointSprites[i] = new CCSprite("Images/r1");
                AddChild(pointSprites[i], 1);
            }
        }
예제 #27
0
        /** initializes a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
        public bool initWithAction(CCFiniteTimeAction action, uint times)
        {
            float d = action.Duration * times;

            if (base.initWithDuration(d))
            {
                m_uTimes = times;
                m_pInnerAction = action;

                m_uTotal = 0;

                return true;
            }

            return false;
        }
예제 #28
0
 /* Play a list of animations */
 public void PlayAnims(string[] animList)
 {
     CCFiniteTimeAction[] actions = new CCFiniteTimeAction[animList.Length];
     for (int i = 0; i < animList.Length; i++)
     {
         if (anims.ContainsKey(animList[i]))
         {
             actions[i] = (CCFiniteTimeAction)anims[animList[i]];
         }
         else
         {
             return;
         }
     }
     sprite.RunActions(actions);
 }
예제 #29
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(2);

            CCFiniteTimeAction seq = CCSequence.actions(
                CCRotateTo.actionWithDuration(0.5f, -20),
                CCRotateTo.actionWithDuration(0.5f, 20));

            CCActionInterval rep1 = CCRepeat.actionWithAction(seq, 10);
            CCAction         rep2 = CCRepeatForever.actionWithAction((CCActionInterval)(seq.copy()));

            m_tamara.runAction(rep1);
            m_kathia.runAction(rep2);
        }
예제 #30
0
        /** initializes a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */
        public bool initWithAction(CCFiniteTimeAction action, uint times)
        {
            float d = action.duration * times;

            if (base.initWithDuration(d))
            {
                m_uTimes       = times;
                m_pInnerAction = action;

                m_uTotal = 0;

                return(true);
            }

            return(false);
        }
예제 #31
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(2);

            m_tamara.Opacity = 0;
            CCActionInterval   action1     = CCFadeIn.actionWithDuration(1.0f);
            CCFiniteTimeAction action1Back = action1.reverse();

            CCActionInterval   action2     = CCFadeOut.actionWithDuration(1.0f);
            CCFiniteTimeAction action2Back = action2.reverse();

            m_tamara.runAction(CCSequence.actions(action1, action1Back));
            m_kathia.runAction(CCSequence.actions(action2, action2Back));
        }
예제 #32
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));
        }
예제 #33
0
        public SpriteOffsetAnchorScale()
        {
            CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;

            cache.AddSpriteFrames("animations/grossini.plist");
            cache.AddSpriteFrames("animations/grossini_gray.plist", "animations/grossini_gray");

            sprites      = new CCSprite[numOfSprites];
            pointSprites = new CCSprite[numOfSprites];

            var    animFrames = new List <CCSpriteFrame>(14);
            string str        = "";

            for (int j = 0; j < 14; j++)
            {
                string temp = "";
                if (j + 1 < 10)
                {
                    temp = "0" + (j + 1);
                }
                else
                {
                    temp = (j + 1).ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = cache[str];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.3f);

            for (int i = 0; i < numOfSprites; i++)
            {
                // Animation using Sprite BatchNode
                sprites[i] = new CCSprite("grossini_dance_01.png");
                AddChild(sprites[i], 0);

                pointSprites[i] = new CCSprite("Images/r1");
                AddChild(pointSprites[i], 1);


                CCFiniteTimeAction scale      = new CCScaleBy(2, 2);
                CCFiniteTimeAction scale_back = (CCFiniteTimeAction)scale.Reverse();
                seq_scale = (CCFiniteTimeAction)(new CCSequence(scale, scale_back));
            }
        }
예제 #34
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(3);

            CCActionInterval   actionTo     = CCSkewTo.actionWithDuration(2, 37.2f, -37.2f);
            CCActionInterval   actionToBack = CCSkewTo.actionWithDuration(2, 0, 0);
            CCActionInterval   actionBy     = CCSkewBy.actionWithDuration(2, 0.0f, -90.0f);
            CCActionInterval   actionBy2    = CCSkewBy.actionWithDuration(2, 45.0f, 45.0f);
            CCFiniteTimeAction actionByBack = actionBy.reverse();

            m_tamara.runAction(CCSequence.actions(actionTo, actionToBack));
            m_grossini.runAction(CCSequence.actions(actionBy, actionByBack));

            m_kathia.runAction(CCSequence.actions(actionBy2, actionBy2.reverse()));
        }
예제 #35
0
        public override void onEnter()
        {
            base.onEnter();

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

            m_grossini.position = new CCPoint(-200, s.height / 2);
            CCActionInterval   move      = CCMoveBy.actionWithDuration(2, new CCPoint(s.width * 3, 0));
            CCFiniteTimeAction move_back = move.reverse();
            CCFiniteTimeAction seq       = CCSequence.actions(move, move_back);
            CCAction           rep       = CCRepeatForever.actionWithAction((CCActionInterval)seq);

            m_grossini.runAction(rep);

            this.runAction(CCFollow.actionWithTarget(m_grossini, new CCRect(0, 0, s.width * 2 - 100, s.height)));
        }
예제 #36
0
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();
            var bounds = Layer.VisibleBoundsWorldspace;

            InSceneNodeContainer.Scale = 0.5f;
            InSceneNodeContainer.Position = new CCPoint(bounds.Origin.X + bounds.Size.Width, bounds.Origin.Y);
            InSceneNodeContainer.AnchorPoint = new CCPoint(0.5f, 0.5f);
            OutSceneNodeContainer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            InSceneNodeContainer.IgnoreAnchorPointForPosition = true;
            OutSceneNodeContainer.IgnoreAnchorPointForPosition = true;

            CCJumpBy jump = new CCJumpBy (Duration / 4, new CCPoint(-bounds.Size.Width, 0), bounds.Size.Width / 4, 2);
            CCFiniteTimeAction scaleIn = new CCScaleTo(Duration / 4, 1.0f);
            CCFiniteTimeAction scaleOut = new CCScaleTo(Duration / 4, 0.5f);

            jumpZoomOut = (new CCSequence(scaleOut, jump));
            jumpZoomIn = (new CCSequence(jump, scaleIn));

            delay = new CCDelayTime (Duration / 2);
        }
예제 #37
0
        public bool InitWithAction(CCFiniteTimeAction action, uint times)
        {
            float d = action.Duration * times;

            if (base.InitWithDuration(d))
            {
                m_uTimes = times;
                m_pInnerAction = action;

                m_bActionInstant = action is CCActionInstant;
                //an instant action needs to be executed one time less in the update method since it uses startWithTarget to execute the action
                if (m_bActionInstant)
                {
                    m_uTimes -= 1;
                }
                m_uTotal = 0;

                return true;
            }

            return false;
        }
예제 #38
0
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            InSceneNodeContainer.Scale = 0.001f;
            OutSceneNodeContainer.Scale = 1.0f;

            var bounds = Layer.VisibleBoundsWorldspace;

            InSceneNodeContainer.AnchorPoint = new CCPoint(0.5f, 0.5f);
            OutSceneNodeContainer.AnchorPoint = new CCPoint(0.5f, 0.5f);

            InSceneNodeContainer.Position = bounds.Center;
            OutSceneNodeContainer.Position = bounds.Center;

            rotozoom = new CCSequence(
                new CCSpawn(
                    new CCScaleBy(Duration / 2, 0.001f),
                    new CCRotateBy(Duration / 2, 360 * 2)
                ),
                new CCDelayTime(Duration / 2)
            );

        }
예제 #39
0
 protected CCFiniteTimeAction(CCFiniteTimeAction finiteTimeAction)
     : base(finiteTimeAction)
 {
 }
예제 #40
0
        protected override void InitialiseScenes()
        {
            base.InitialiseScenes();

            var bounds = Layer.VisibleBoundsWorldspace;
            int x, y;

            if (bounds.Size.Width > bounds.Size.Height)
            {
                x = 16;
                y = 12;
            }
            else
            {
                x = 12;
                y = 16;
            }

            action = ActionWithSize(new CCGridSize(x, y));

            if (Back)
            {
                // to prevent initial flicker
                InSceneNodeContainer.Visible = false;

            }
        }
예제 #41
0
 public CCTargetedAction(CCNode target, CCFiniteTimeAction pAction)
 {
     InitWithTarget(target, pAction);
 }
예제 #42
0
 public CCActionEase(CCFiniteTimeAction action) : base (action.Duration)
 {
     InnerAction = action;
 }
예제 #43
0
 public CCEaseBackInOut(CCFiniteTimeAction action) : base (action)
 {
 }
예제 #44
0
 public CCEaseElastic (CCFiniteTimeAction action, float period) : base (action)
 {
     Period = period;
 }
예제 #45
0
 public CCTargetedAction (CCNode target, CCFiniteTimeAction action) : base (action.Duration)
 {
     ForcedTarget = target;
     TargetedAction = action;
 }
예제 #46
0
 public virtual CCFiniteTimeAction EaseAction(CCFiniteTimeAction action)
 {
     return new CCEaseOut(action, 2.0f);
 }
예제 #47
0
 public CCRepeat (CCFiniteTimeAction action, uint times)
 {
     InitWithAction(action, times);
 }
예제 #48
0
 public CCEaseElastic (CCFiniteTimeAction action) : this (action, 0.3f)
 {
 }
예제 #49
0
 protected virtual CCFiniteTimeAction EaseAction(CCFiniteTimeAction action)
 {
     return action;
 }
예제 #50
0
 public CCEaseRateAction (CCFiniteTimeAction action, float rate) : base (action)
 {
     Rate = rate;
 }
예제 #51
0
 public virtual CCFiniteTimeAction EaseAction(CCFiniteTimeAction action)
 {
     return action;
 }
예제 #52
0
 public CCEaseBounceInOut (CCFiniteTimeAction action) : base (action)
 {
 }
예제 #53
0
 protected CCFiniteTimeAction(CCFiniteTimeAction finiteTimeAction) : base(finiteTimeAction)
 {
     m_fDuration = finiteTimeAction.m_fDuration;
 }