Esempio n. 1
0
        public override void onEnter()
        {
            base.onEnter();

            centerSprites(1);

            CCAnimation animation = CCAnimation.animation();
            string      frameName;

            for (int i = 1; i < 15; i++)
            {
                if (i < 10)
                {
                    frameName = string.Format("Images/grossini_dance_0{0}", i);
                }
                else
                {
                    frameName = string.Format("Images/grossini_dance_{0}", i);
                }
                animation.addFrameWithFileName(frameName);
            }

            CCActionInterval   action      = CCAnimate.actionWithDuration(3.0f, animation, false);
            CCFiniteTimeAction action_back = action.reverse();

            m_grossini.runAction(CCSequence.actions(action, action_back));
        }
Esempio n. 2
0
        public override void OnEnter()
        {
            base.OnEnter();

            CCSize windowSize = Layer.VisibleBoundsWorldspace.Size;

            var characterSpriteFactory = new CharacterSpriteFactory();

            swingAnimate    = characterSpriteFactory.CreateAnimateAction(Director);
            thrustAnimate   = characterSpriteFactory.CreateAnimateAction(Director);
            dodgeAnimate    = characterSpriteFactory.CreateAnimateAction(Director);
            collapseAnimate = characterSpriteFactory.CreateAnimateAction(Director);

            swingAnimate2    = characterSpriteFactory.CreateAnimateAction(Director);
            thrustAnimate2   = characterSpriteFactory.CreateAnimateAction(Director);
            dodgeAnimate2    = characterSpriteFactory.CreateAnimateAction(Director);
            collapseAnimate2 = characterSpriteFactory.CreateAnimateAction(Director);

            testSprite.Position  = new CCPoint(windowSize.Width / 2 - 200, windowSize.Height / 2 + 100);
            testSprite2.Position = new CCPoint(windowSize.Width / 2 + 200, windowSize.Height / 2 + 100);
            testSprite2.FlipX    = true;

            AnimationLoop();
            AnimationLoop2();
        }
Esempio n. 3
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);
        }
        public RenderTextureCompositeTest()
        {
            var winSize = CCDirector.SharedDirector.WinSize;
            var characterSpriteFactory = new CharacterSpriteFactory();

            _testSprite  = new CCSprite(@"Images\grossini_dance_01");
            _testSprite2 = new CCSprite(@"Images\grossini_dance_02");

            _swingAnimate    = characterSpriteFactory.CreateAnimateAction();
            _thrustAnimate   = characterSpriteFactory.CreateAnimateAction();
            _dodgeAnimate    = characterSpriteFactory.CreateAnimateAction();
            _collapseAnimate = characterSpriteFactory.CreateAnimateAction();

            _swingAnimate2    = characterSpriteFactory.CreateAnimateAction();
            _thrustAnimate2   = characterSpriteFactory.CreateAnimateAction();
            _dodgeAnimate2    = characterSpriteFactory.CreateAnimateAction();
            _collapseAnimate2 = characterSpriteFactory.CreateAnimateAction();

            _testSprite.Position = new CCPoint(winSize.Width / 2 - 200, winSize.Height / 2 + 100);
            AddChild(_testSprite);

            _testSprite2.Position = new CCPoint(winSize.Width / 2 + 200, winSize.Height / 2 + 100);
            _testSprite2.FlipX    = true;
            AddChild(_testSprite2);

            AnimationLoop();
            AnimationLoop2();
        }
Esempio n. 5
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            //
            // Manual animation
            //
            var animation = new CCAnimation();

            for (var i = 1; i < 15; i++)
            {
                var szName = String.Format("Images/grossini_dance_{0:00}", i);
                animation.AddSpriteFrameWithFileName(szName);
            }

            // should last 2.8 seconds. And there are 14 frames.
            animation.DelayPerUnit         = 2.8f / 14.0f;
            animation.RestoreOriginalFrame = true;

            var action = new CCAnimate(animation);

            m_grossini.RunAction(CCSequence.FromActions(action, action.Reverse()));

            //
            // File animation
            //
            // With 2 loops and reverse
            var cache = CCAnimationCache.SharedAnimationCache;

            cache.AddAnimationsWithFile("animations/animations-2.plist");
            var animation2 = cache.AnimationByName("dance_1");

            var action2 = new CCAnimate(animation2);

            m_tamara.RunAction(CCSequence.FromActions(action2, action2.Reverse()));

            // TODO:
            //     observer_ = [[NSNotificationCenter defaultCenter] addObserverForName:CCAnimationFrameDisplayedNotification object:nil queue:nil usingBlock:^(NSNotification* notification) {
            //
            //         NSDictionary *userInfo = [notification userInfo];
            //         NSLog(@"object %@ with data %@", [notification object], userInfo );
            //     }];


            //
            // File animation
            //
            // with 4 loops
            var animation3 = (CCAnimation)animation2.Copy();

            animation3.Loops = 4;


            var action3 = new CCAnimate(animation3);

            m_kathia.RunAction(action3);
        }
Esempio n. 6
0
        public ActorBase(ActorData data)
        {
            ActorData = data;
            //创建攻击动画
            List <CCSpriteFrame> _attackFrames      = new List <CCSpriteFrame>();
            List <CCSpriteFrame> _attackFrames_flip = new List <CCSpriteFrame>();

            for (int i = 0; i < 4; i++)
            {
                _attackFrames.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "_" + i + ".png"));
                _attackFrames_flip.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "f_" + i + ".png"));
            }
            _action_attack      = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_attackFrames, 0.1f));
            _action_attack_flip = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_attackFrames_flip, 0.1f));
            //创建行走动画
            List <CCSpriteFrame> _runFrames      = new List <CCSpriteFrame>();
            List <CCSpriteFrame> _runFrames_flip = new List <CCSpriteFrame>();

            for (int i = 4; i < 6; i++)
            {
                _runFrames.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "_" + i + ".png"));
                _runFrames_flip.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "f_" + i + ".png"));
            }
            _action_run      = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_runFrames, 0.1f));
            _action_run_flip = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_runFrames_flip, 0.1f));
            //创建站立动画
            List <CCSpriteFrame> _standFrames      = new List <CCSpriteFrame>();
            List <CCSpriteFrame> _standFrames_flip = new List <CCSpriteFrame>();

            for (int i = 6; i < 7; i++)
            {
                _standFrames.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "_" + i + ".png"));
                _standFrames_flip.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "f_" + i + ".png"));
            }
            _action_stand      = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_standFrames, 0.2f));
            _action_stand_flip = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_standFrames_flip, 0.2f));
            //创建死亡动画
            List <CCSpriteFrame> _deadFrames      = new List <CCSpriteFrame>();
            List <CCSpriteFrame> _deadFrames_flip = new List <CCSpriteFrame>();

            for (int i = 7; i < 9; i++)
            {
                _deadFrames.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "_" + i + ".png"));
                _deadFrames_flip.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(data.ActorID + "f_" + i + ".png"));
            }
            _action_dead      = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_deadFrames, 0.3f));
            _action_dead_flip = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_deadFrames_flip, 0.3f));
            //初始化默认帧
            base.initWithSpriteFrame(_standFrames[0]);
        }
Esempio n. 7
0
        private void LoadPicture()
        {
            CCTexture2D          speakerpic = Media.PictureManager.GetCCTexture2DWithFile(PictuerName);
            List <CCSpriteFrame> frames     = new List <CCSpriteFrame>();

            for (int i = 0; i < FrameNumber; i++)
            {
                CCSpriteFrame frame = CCSpriteFrame.frameWithTexture(speakerpic, new CCRect(i * PictuerWidth, 0, PictuerWidth, PictuerHeight));
                frames.Add(frame);
            }
            CCAnimation ani = CCAnimation.animationWithFrames(frames);

            this.initWithSpriteFrame(frames[0]);
            action = CCAnimate.actionWithDuration(1f, ani, true);
        }
        public CCAnimate CreateAnimateAction(CCDirector director)
        {
            var frameList = new List <CCSpriteFrame>();

            for (var i = 0; i < 7; i++)
            {
                var texture = CreateCharacterTexture(director);

                var sprite = new CCSpriteFrame(texture, new CCRect(0, 0, texture.ContentSizeInPixels.Width, texture.ContentSizeInPixels.Height));
                frameList.Add(sprite);
            }
            var animation = new CCAnimation(frameList, 0.1f);
            var animate   = new CCAnimate(animation);

            return(animate);
        }
Esempio n. 9
0
        protected Animation GetAnimation(string filename, bool repeating = true)
        {
            Animation            animation       = new Animation();
            CCSpriteSheet        spritesheet     = new CCSpriteSheet("animations/" + filename + ".plist");
            List <CCSpriteFrame> animationFrames = spritesheet.Frames;

            animation.Frames = animationFrames;
            CCAnimate action = new CCAnimate(new CCAnimation(animationFrames, 0.1f));

            if (repeating)
            {
                animation.Action = new CCRepeatForever(action);
            }
            else
            {
                animation.Action = action;
            }
            return(animation);
        }
        public SpriteAnimationSplit()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            CCTexture2D texture = CCTextureCache.sharedTextureCache().addImage("animations/images/dragon_animation");

            // manually add frames to the frame cache
            CCSpriteFrame frame0 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 0, 132 * 0, 132, 132));
            CCSpriteFrame frame1 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 1, 132 * 0, 132, 132));
            CCSpriteFrame frame2 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 2, 132 * 0, 132, 132));
            CCSpriteFrame frame3 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 3, 132 * 0, 132, 132));
            CCSpriteFrame frame4 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 0, 132 * 1, 132, 132));
            CCSpriteFrame frame5 = CCSpriteFrame.frameWithTexture(texture, new CCRect(132 * 1, 132 * 1, 132, 132));

            //
            // Animation using Sprite BatchNode
            //
            CCSprite sprite = CCSprite.spriteWithSpriteFrame(frame0);

            sprite.position = (new CCPoint(s.width / 2 - 80, s.height / 2));
            addChild(sprite);

            List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>(6);

            animFrames.Add(frame0);
            animFrames.Add(frame1);
            animFrames.Add(frame2);
            animFrames.Add(frame3);
            animFrames.Add(frame4);
            animFrames.Add(frame5);

            CCAnimation      animation = CCAnimation.animationWithFrames(animFrames, 0.2f);
            CCAnimate        animate   = CCAnimate.actionWithAnimation(animation, false);
            CCActionInterval seq       = (CCActionInterval)(CCSequence.actions(animate,
                                                                               CCFlipX.actionWithFlipX(true),
                                                                               (CCFiniteTimeAction)animate.copy(),
                                                                               CCFlipX.actionWithFlipX(false)
                                                                               ));

            sprite.runAction(CCRepeatForever.actionWithAction(seq));
            //animFrames->release();    // win32 : memory leak    2010-0415
        }
        public SpriteAnimationSplit()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            CCTexture2D texture = CCTextureCache.SharedTextureCache.AddImage("animations/dragon_animation");

            // manually add frames to the frame cache
            CCSpriteFrame frame0 = new CCSpriteFrame(texture, new CCRect(132 * 0, 132 * 0, 132, 132));
            CCSpriteFrame frame1 = new CCSpriteFrame(texture, new CCRect(132 * 1, 132 * 0, 132, 132));
            CCSpriteFrame frame2 = new CCSpriteFrame(texture, new CCRect(132 * 2, 132 * 0, 132, 132));
            CCSpriteFrame frame3 = new CCSpriteFrame(texture, new CCRect(132 * 3, 132 * 0, 132, 132));
            CCSpriteFrame frame4 = new CCSpriteFrame(texture, new CCRect(132 * 0, 132 * 1, 132, 132));
            CCSpriteFrame frame5 = new CCSpriteFrame(texture, new CCRect(132 * 1, 132 * 1, 132, 132));

            //
            // Animation using Sprite BatchNode
            //
            CCSprite sprite = new CCSprite(frame0);

            sprite.Position = (new CCPoint(s.Width / 2 - 80, s.Height / 2));
            AddChild(sprite);

            var animFrames = new List <CCSpriteFrame>(6);

            animFrames.Add(frame0);
            animFrames.Add(frame1);
            animFrames.Add(frame2);
            animFrames.Add(frame3);
            animFrames.Add(frame4);
            animFrames.Add(frame5);

            CCAnimation      animation = new CCAnimation(animFrames, 0.2f);
            CCAnimate        animate   = new CCAnimate(animation);
            CCActionInterval seq       = (CCActionInterval)(new CCSequence(animate,
                                                                           new CCFlipX(true),
                                                                           (CCFiniteTimeAction)animate.Copy(),
                                                                           new CCFlipX(false)
                                                                           ));

            sprite.RunAction(new CCRepeatForever(seq));
            //animFrames->release();    // win32 : memory leak    2010-0415
        }
Esempio n. 12
0
        void CreatePlayer()
        {
            player.Name     = "player";
            player.Position = new CCPoint(VisibleBoundsWorldspace.MinX + player.ContentSize.Width * 1.5f, ContentSize.Height * 0.75f);
            AddChild(player);
            this.ReorderChild(player, 10);

            CCAnimation playerAnimation = new CCAnimation();

            for (int i = 1; i <= 3; i++)
            {
                playerAnimation.AddSpriteFrame(new CCSprite(string.Format("player-{0}", i)));
            }
            playerAnimation.AddSpriteFrame(playerAnimation.Frames[1].SpriteFrame);
            playerAnimation.DelayPerUnit = 0.01f;

            var animate         = new CCAnimate(playerAnimation);
            var animationAction = new CCRepeatForever(animate);

            player.RunAction(animationAction);
        }
Esempio n. 13
0
        public Uncle_sprite()
        {
            //uncledata = data;

            // 创建走的动画
            List <CCSpriteFrame> _runFream = new List <CCSpriteFrame>();

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile(@"plist/zhengyu");
            CCSpriteBatchNode sheet = CCSpriteBatchNode.batchNodeWithFile(@"plist/Images/zhengyu");

            this.addChild(sheet);
            for (int i = 1; i <= 4; i++)
            {
                _runFream.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(String.Format("MM0{0}.png", i)));
            }
            _run = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_runFream, 0.12f));

            List <CCSpriteFrame> _actackFream = new List <CCSpriteFrame>();

            // 创建攻击时候动作
            for (int i = 1; i <= 5; i++)
            {
                _actackFream.Add(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(String.Format("Mthrow0{0}.png", i)));
            }
            _actack = CCAnimate.actionWithAnimation(CCAnimation.animationWithFrames(_actackFream, 0.3f));

            position = new CCPoint(100, 100);
            // 初始化开始帧
            base.initWithSpriteFrame(_runFream[0]);


            // 如果手机倾斜
            if (Accelerometer.IsSupported)
            {
                gSensor = new Accelerometer();
                gSensor.CurrentValueChanged += new EventHandler <SensorReadingEventArgs <AccelerometerReading> >(gSensor_CurrentValueChanged);
                gSensor.Start();
            }
        }
Esempio n. 14
0
        public SpriteAnimationSplit()
        {
            var    texture             = CCTextureCache.SharedTextureCache.AddImage("animations/dragon_animation");
            CCSize contentSizeInPixels = texture.ContentSizeInPixels;
            float  height       = contentSizeInPixels.Height / 4.0f;
            float  heightOffset = height / 2.0f;
            float  width        = contentSizeInPixels.Width / 5.0f;

            // Manually add frames to the frame cache
            // The rects in pixels of each frame are determined from the textureatlas
            var frame0 = new CCSpriteFrame(texture, new CCRect(width * 0, heightOffset + height * 0, width, height));
            var frame1 = new CCSpriteFrame(texture, new CCRect(width * 1, heightOffset + height * 0, width, height));
            var frame2 = new CCSpriteFrame(texture, new CCRect(width * 2, heightOffset + height * 0, width, height));
            var frame3 = new CCSpriteFrame(texture, new CCRect(width * 3, heightOffset + height * 0, width, height));

            // Note: The height positioning below is a bit of voodoo because the sprite atlas isn't currently packed tightly
            // See the dragon_animation.png file
            var frame4 = new CCSpriteFrame(texture, new CCRect(width * 0, heightOffset * 1.6f + height * 1, width, height));
            var frame5 = new CCSpriteFrame(texture, new CCRect(width * 1, heightOffset * 1.6f + height * 1, width, height));

            // Animation using Sprite BatchNode
            sprite = new CCSprite(frame0);
            AddChild(sprite);

            var animFrames = new List <CCSpriteFrame>(6);

            animFrames.Add(frame0);
            animFrames.Add(frame1);
            animFrames.Add(frame2);
            animFrames.Add(frame3);
            animFrames.Add(frame4);
            animFrames.Add(frame5);

            CCAnimation animation = new CCAnimation(animFrames, 0.2f);
            CCAnimate   animate   = new CCAnimate(animation);

            seq = new CCSequence(animate, new CCFlipX(true), animate, new CCFlipX(false));
        }
        public SpriteBatchNodeChildren()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // parents
            CCSpriteBatchNode batch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini", 50);

            addChild(batch, 0, (int)kTags.kTagSpriteBatchNode);

            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini");

            CCSprite sprite1 = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");

            sprite1.position = (new CCPoint(s.width / 3, s.height / 2));

            CCSprite sprite2 = CCSprite.spriteWithSpriteFrameName("grossini_dance_02.png");

            sprite2.position = (new CCPoint(50, 50));

            CCSprite sprite3 = CCSprite.spriteWithSpriteFrameName("grossini_dance_03.png");

            sprite3.position = (new CCPoint(-50, -50));

            batch.addChild(sprite1);
            sprite1.addChild(sprite2);
            sprite1.addChild(sprite3);

            // BEGIN NEW CODE
            List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>();
            string str = "";

            for (int i = 1; i < 15; i++)
            {
                string temp = "";
                if (i < 10)
                {
                    temp = "0" + i;
                }
                else
                {
                    temp = i.ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str);
                animFrames.Add(frame);
            }

            CCAnimation animation = CCAnimation.animationWithFrames(animFrames, 0.2f);

            sprite1.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithAnimation(animation, false)));
            // END NEW CODE

            CCActionInterval action        = CCMoveBy.actionWithDuration(2, new CCPoint(200, 0));
            CCActionInterval action_back   = (CCActionInterval)action.reverse();
            CCActionInterval action_rot    = CCRotateBy.actionWithDuration(2, 360);
            CCActionInterval action_s      = CCScaleBy.actionWithDuration(2, 2);
            CCActionInterval action_s_back = (CCActionInterval)action_s.reverse();

            CCActionInterval seq2 = (CCActionInterval)action_rot.reverse();

            sprite2.runAction(CCRepeatForever.actionWithAction(seq2));

            sprite1.runAction((CCAction)(CCRepeatForever.actionWithAction(action_rot)));
            sprite1.runAction((CCAction)(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action, action_back)))));
            sprite1.runAction((CCAction)(CCRepeatForever.actionWithAction((CCActionInterval)(CCSequence.actions(action_s, action_s_back)))));
        }
Esempio n. 16
0
        void CreatePipesAndCoins()
        {
            var pipeNode = new CCNode();

            pipeNode.AnchorPoint = CCPoint.Zero;
            pipeNode.Name        = "pipe";

            var bottomPipe = new CCSprite("pipe");

            bottomPipe.AnchorPoint = CCPoint.Zero;
            bottomPipe.ScaleX      = 0.5f;
            bottomPipe.FlipY       = true;
            bottomPipe.Name        = "bottomPipe";
            bottomPipe.Position    = new CCPoint(0, 0);

            var pipeGap = new CCDrawNode();

            pipeGap.AnchorPoint = CCPoint.Zero;
            pipeGap.DrawRect(new CCRect(0, 0, 1, (player.ContentSize.Height * 2.8f) - pipeGapShrink), CCColor4B.Red);
            pipeGap.Name     = "sensorScore";
            pipeGap.Position = new CCPoint(bottomPipe.ScaledContentSize.Width, bottomPipe.ContentSize.Height);
            pipeGap.Visible  = false;

            var topPipe = new CCSprite("pipe");

            topPipe.AnchorPoint = CCPoint.Zero;
            topPipe.ScaleX      = 0.5f;
            topPipe.Name        = "topPipe";
            topPipe.Position    = new CCPoint(0, bottomPipe.ContentSize.Height + pipeGap.ContentSize.Height);

            pipeNode.AddChild(bottomPipe);
            pipeNode.AddChild(pipeGap);
            pipeNode.AddChild(topPipe);


            AddChild(pipeNode);
            this.ReorderChild(pipeNode, -20);

            float xPosition = ContentSize.Width;
            float yPosition = CCRandom.Next(-530, 5);

            pipeNode.Position = new CCPoint(xPosition, yPosition);

            //Create coin
            var coin = new CCSprite("gold_1");

            coin.Name  = "coin";
            coin.Scale = 0.75f;

            int coinPos = CCRandom.Next(0, 3);

            if (coinPos == 0)
            {
                coin.Tag       = 0;
                coin.PositionX = topPipe.PositionX + 190;
                coin.PositionY = topPipe.PositionY + 120;
            }
            else if (coinPos == 1)
            {
                coin.Tag       = 1;
                coin.PositionX = topPipe.PositionX + coin.ContentSize.Width / 3;
                coin.PositionY = topPipe.PositionY - pipeGap.ContentSize.Height / 2;
            }
            else
            {
                coin.Tag       = 2;
                coin.PositionX = topPipe.PositionX + 190;
                coin.PositionY = topPipe.PositionY - pipeGap.ContentSize.Height - 120;
            }


            pipeNode.AddChild(coin);
            this.ReorderChild(coin, 10);

            CCAnimation coinAnimation = new CCAnimation();

            for (int i = 1; i <= 4; i++)
            {
                coinAnimation.AddSpriteFrame(new CCSprite(string.Format("gold_{0}", i)));
            }
            coinAnimation.DelayPerUnit = 0.1f;

            var animate         = new CCAnimate(coinAnimation);
            var animationAction = new CCRepeatForever(animate);

            coin.RunAction(animationAction);



            float endPosition  = ContentSize.Width + (pipeNode.ContentSize.Width * 2) + 190;
            var   moveAction   = new CCMoveBy(6.2f, new CCPoint(-endPosition, 0));
            var   remove       = new CCRemoveSelf();
            var   moveSequence = new CCSequence(moveAction, remove);

            pipeNode.RunAction(moveSequence);
        }
Esempio n. 17
0
        public override void onEnter()
        {
            base.onEnter();
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // IMPORTANT:
            // The sprite frames will be cached AND RETAINED, and they won't be released unless you call
            //     [[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
            //
            // CCSpriteFrameCache is a cache of CCSpriteFrames
            // CCSpriteFrames each contain a texture id and a rect (frame).

            CCSpriteFrameCache cache = CCSpriteFrameCache.sharedSpriteFrameCache();

            cache.addSpriteFramesWithFile("animations/grossini-aliases", "animations/images/grossini-aliases");

            //
            // Animation using Sprite batch
            //
            // A CCSpriteBatchNode can reference one and only one texture (one .png file)
            // Sprites that are contained in that texture can be instantiatied as CCSprites and then added to the CCSpriteBatchNode
            // All CCSprites added to a CCSpriteBatchNode are drawn in one OpenGL ES draw call
            // If the CCSprites are not added to a CCSpriteBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient
            //
            // When you animate a sprite, CCAnimation changes the frame of the sprite using setDisplayFrame: (this is why the animation must be in the same texture)
            // When setDisplayFrame: is used in the CCAnimation it changes the frame to one specified by the CCSpriteFrames that were added to the animation,
            // but texture id is still the same and so the sprite is still a child of the CCSpriteBatchNode,
            // and therefore all the animation sprites are also drawn as part of the CCSpriteBatchNode
            //

            CCSprite sprite = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");

            sprite.position = (new CCPoint(s.width * 0.5f, s.height * 0.5f));

            CCSpriteBatchNode spriteBatch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini-aliases");

            spriteBatch.addChild(sprite);
            addChild(spriteBatch);

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

            for (int i = 1; i < 15; i++)
            {
                string temp = "";
                if (i < 10)
                {
                    temp = "0" + i;
                }
                else
                {
                    temp = i.ToString();
                }
                // Obtain frames by alias name
                str = string.Format("dance_{0}", temp);
                CCSpriteFrame frame = cache.spriteFrameByName(str);
                animFrames.Add(frame);
            }

            CCAnimation animation = CCAnimation.animationWithFrames(animFrames);

            // 14 frames * 1sec = 14 seconds
            sprite.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithDuration(14.0f, animation, false)));
        }
Esempio n. 18
0
        public AnimationCache()
        {
            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini");
            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini_gray");
            CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFramesWithFile("animations/grossini_blue");

            //
            // create animation "dance"
            //
            List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>(15);
            string str = "";

            for (int i = 1; i < 15; i++)
            {
                string temp = "";
                if (i < 10)
                {
                    temp = "0" + i;
                }
                else
                {
                    temp = i.ToString();
                }
                str = string.Format("grossini_dance_{0}.png", temp);
                CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str);
                animFrames.Add(frame);
            }

            CCAnimation animation = CCAnimation.animationWithFrames(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.sharedAnimationCache().addAnimation(animation, "dance");

            //
            // create animation "dance gray"
            //
            animFrames.Clear();

            for (int i = 1; i < 15; i++)
            {
                string temp = "";
                if (i < 10)
                {
                    temp = "0" + i;
                }
                else
                {
                    temp = i.ToString();
                }
                str = String.Format("grossini_dance_gray_{0}.png", temp);
                CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str);
                animFrames.Add(frame);
            }

            animation = CCAnimation.animationWithFrames(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.sharedAnimationCache().addAnimation(animation, "dance_gray");

            //
            // create animation "dance blue"
            //
            animFrames.Clear();

            for (int i = 1; i < 4; i++)
            {
                str = String.Format("grossini_blue_0{0}.png", i);
                CCSpriteFrame frame = CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName(str);
                animFrames.Add(frame);
            }

            animation = CCAnimation.animationWithFrames(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.sharedAnimationCache().addAnimation(animation, "dance_blue");


            CCAnimationCache animCache = CCAnimationCache.sharedAnimationCache();

            CCAnimation normal     = animCache.animationByName("dance");
            CCAnimation dance_grey = animCache.animationByName("dance_gray");
            CCAnimation dance_blue = animCache.animationByName("dance_blue");

            CCAnimate animN = CCAnimate.actionWithAnimation(normal);
            CCAnimate animG = CCAnimate.actionWithAnimation(dance_grey);
            CCAnimate animB = CCAnimate.actionWithAnimation(dance_blue);

            CCFiniteTimeAction seq = CCSequence.actions(animN, animG, animB);

            // create an sprite without texture
            CCSprite grossini = new CCSprite();

            grossini.init();

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

            grossini.position = (new CCPoint(winSize.width / 2, winSize.height / 2));
            addChild(grossini);

            // run the animation
            grossini.runAction(seq);
        }
Esempio n. 19
0
        public AnimationCache()
        {
            var frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;

            frameCache.AddSpriteFrames("animations/grossini.plist");
            frameCache.AddSpriteFrames("animations/grossini_gray.plist");
            frameCache.AddSpriteFrames("animations/grossini_blue.plist");

            //
            // create animation "dance"
            //
            var    animFrames = new List <CCSpriteFrame>(15);
            string str        = "";

            for (int i = 1; i < 15; i++)
            {
                str = string.Format("grossini_dance_{0:00}.png", i);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache[str];
                animFrames.Add(frame);
            }

            CCAnimation animation = new CCAnimation(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance");

            //
            // create animation "dance gray"
            //
            animFrames.Clear();

            for (int i = 1; i < 15; i++)
            {
                str = String.Format("grossini_dance_gray_{0:00}.png", i);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache[str];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance_gray");

            //
            // create animation "dance blue"
            //
            animFrames.Clear();

            for (int i = 1; i < 4; i++)
            {
                str = String.Format("grossini_blue_{0:00}.png", i);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache[str];
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance_blue");


            CCAnimationCache animCache = CCAnimationCache.SharedAnimationCache;

            CCAnimation normal = animCache["dance"];

            normal.RestoreOriginalFrame = true;
            CCAnimation dance_grey = animCache["dance_gray"];

            dance_grey.RestoreOriginalFrame = true;
            CCAnimation dance_blue = animCache["dance_blue"];

            dance_blue.RestoreOriginalFrame = true;

            CCAnimate animN = new CCAnimate(normal);
            CCAnimate animG = new CCAnimate(dance_grey);
            CCAnimate animB = new CCAnimate(dance_blue);

            seqAnimation = new CCSequence(animN, animG, animB);

            grossini = new CCSprite();
            AddChild(grossini);
        }
Esempio n. 20
0
        public SpriteFrameTest()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            // IMPORTANT:
            // The sprite frames will be cached AND RETAINED, and they won't be released unless you call
            //     CCSpriteFrameCache::sharedSpriteFrameCache()->removeUnusedSpriteFrames);
            CCSpriteFrameCache cache = CCSpriteFrameCache.sharedSpriteFrameCache();

            cache.addSpriteFramesWithFile("animations/grossini");
            cache.addSpriteFramesWithFile("animations/grossini_gray", "animations/images/grossini_gray");
            cache.addSpriteFramesWithFile("animations/grossini_blue", "animations/images/grossini_blue");

            //
            // Animation using Sprite BatchNode
            //
            m_pSprite1          = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");
            m_pSprite1.position = (new CCPoint(s.width / 2 - 80, s.height / 2));

            CCSpriteBatchNode spritebatch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini");

            spritebatch.addChild(m_pSprite1);
            addChild(spritebatch);

            List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>(15);

            string str = "";

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

            CCAnimation animation = CCAnimation.animationWithFrames(animFrames);

            m_pSprite1.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithAnimation(animation, false)));

            // to test issue #732, uncomment the following line
            m_pSprite1.IsFlipX = false;
            m_pSprite1.IsFlipY = false;

            //
            // Animation using standard Sprite
            //
            m_pSprite2          = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");
            m_pSprite2.position = (new CCPoint(s.width / 2 + 80, s.height / 2));
            addChild(m_pSprite2);


            List <CCSpriteFrame> moreFrames = new List <CCSpriteFrame>(20);

            for (int i = 1; i < 15; i++)
            {
                string temp;
                if (i < 10)
                {
                    temp = "0" + i;
                }
                else
                {
                    temp = i.ToString();
                }
                str = string.Format("grossini_dance_gray_{0}.png", temp);
                CCSpriteFrame frame = cache.spriteFrameByName(str);
                moreFrames.Add(frame);
            }


            for (int i = 1; i < 5; i++)
            {
                str = string.Format("grossini_blue_0{0}.png", i);
                CCSpriteFrame frame = cache.spriteFrameByName(str);
                moreFrames.Add(frame);
            }

            // append frames from another batch
            moreFrames.AddRange(animFrames);
            CCAnimation animMixed = CCAnimation.animationWithFrames(moreFrames);


            m_pSprite2.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithAnimation(animMixed, false)));



            // to test issue #732, uncomment the following line
            m_pSprite2.IsFlipX = (false);
            m_pSprite2.IsFlipY = (false);

            schedule(startIn05Secs, 0.5f);
            m_nCounter = 0;
        }
Esempio n. 21
0
        public AnimationCache()
        {
            var frameCache = CCSpriteFrameCache.SharedSpriteFrameCache;

            frameCache.AddSpriteFramesWithFile("animations/grossini.plist");
            frameCache.AddSpriteFramesWithFile("animations/grossini_gray.plist");
            frameCache.AddSpriteFramesWithFile("animations/grossini_blue.plist");

            //
            // create animation "dance"
            //
            var    animFrames = new List <CCSpriteFrame>(15);
            string str        = "";

            for (int i = 1; i < 15; i++)
            {
                str = string.Format("grossini_dance_{0:00}.png", i);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
                animFrames.Add(frame);
            }

            CCAnimation animation = new CCAnimation(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance");

            //
            // create animation "dance gray"
            //
            animFrames.Clear();

            for (int i = 1; i < 15; i++)
            {
                str = String.Format("grossini_dance_gray_{0:00}.png", i);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance_gray");

            //
            // create animation "dance blue"
            //
            animFrames.Clear();

            for (int i = 1; i < 4; i++)
            {
                str = String.Format("grossini_blue_{0:00}.png", i);
                CCSpriteFrame frame = CCSpriteFrameCache.SharedSpriteFrameCache.SpriteFrameByName(str);
                animFrames.Add(frame);
            }

            animation = new CCAnimation(animFrames, 0.2f);

            // Add an animation to the Cache
            CCAnimationCache.SharedAnimationCache.AddAnimation(animation, "dance_blue");


            CCAnimationCache animCache = CCAnimationCache.SharedAnimationCache;

            CCAnimation normal = animCache.AnimationByName("dance");

            normal.RestoreOriginalFrame = true;
            CCAnimation dance_grey = animCache.AnimationByName("dance_gray");

            dance_grey.RestoreOriginalFrame = true;
            CCAnimation dance_blue = animCache.AnimationByName("dance_blue");

            dance_blue.RestoreOriginalFrame = true;

            CCAnimate animN = new CCAnimate(normal);
            CCAnimate animG = new CCAnimate(dance_grey);
            CCAnimate animB = new CCAnimate(dance_blue);

            CCFiniteTimeAction seq = CCSequence.FromActions(animN, animG, animB);

            // create an sprite without texture
            CCSprite grossini = new CCSprite();

            grossini.DisplayFrame = frameCache.SpriteFrameByName("grossini_dance_01.png");

            CCSize winSize = CCDirector.SharedDirector.WinSize;

            grossini.Position = (new CCPoint(winSize.Width / 2, winSize.Height / 2));
            AddChild(grossini);

            // run the animation
            grossini.RunAction(seq);
        }
        public SpriteBatchNodeOffsetAnchorFlip()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            for (int i = 0; i < 3; i++)
            {
                CCSpriteFrameCache cache = CCSpriteFrameCache.sharedSpriteFrameCache();
                cache.addSpriteFramesWithFile("animations/grossini");
                cache.addSpriteFramesWithFile("animations/grossini_gray", "animations/images/grossini_gray");

                //
                // Animation using Sprite batch
                //
                CCSprite sprite = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");
                sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2));

                CCSprite point = CCSprite.spriteWithFile("Images/r1");
                point.scale    = 0.25f;
                point.position = sprite.position;
                addChild(point, 200);

                switch (i)
                {
                case 0:
                    sprite.anchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
                    break;

                case 2:
                    sprite.anchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.position = sprite.position;

                CCSpriteBatchNode spritebatch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini");
                addChild(spritebatch);

                List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>();
                string tmp = "";
                for (int j = 0; j < 14; j++)
                {
                    string temp = "";
                    if (i + 1 < 10)
                    {
                        temp = "0" + (i + 1);
                    }
                    else
                    {
                        temp = (i + 1).ToString();
                    }
                    tmp = string.Format("grossini_dance_{0}.png", temp);
                    CCSpriteFrame frame = cache.spriteFrameByName(tmp);
                    animFrames.Add(frame);
                }

                CCAnimation animation = CCAnimation.animationWithFrames(animFrames);
                sprite.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithDuration(2.8f, animation, false)));

                animFrames = null;

                CCFlipY            flip      = CCFlipY.actionWithFlipY(true);
                CCFlipY            flip_back = CCFlipY.actionWithFlipY(false);
                CCDelayTime        delay     = CCDelayTime.actionWithDuration(1);
                CCFiniteTimeAction seq       = CCSequence.actions((CCFiniteTimeAction)delay, (CCFiniteTimeAction)flip, (CCFiniteTimeAction)delay.copyWithZone(null), (CCFiniteTimeAction)flip_back);
                sprite.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq));

                spritebatch.addChild(sprite, i);
            }
        }
Esempio n. 23
0
 //播放循环动画的统一方法
 private void RunAnimateAction_RepeatForever(CCAnimate action)
 {
     currentAnimateActionStop();
     _currentAnimateAction = runAction(CCRepeatForever.actionWithAction(action));
 }
Esempio n. 24
0
        public SpriteOffsetAnchorSkewScale()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            for (int i = 0; i < 3; i++)
            {
                CCSpriteFrameCache cache = CCSpriteFrameCache.sharedSpriteFrameCache();
                cache.addSpriteFramesWithFile("animations/grossini");
                cache.addSpriteFramesWithFile("animations/grossini_gray", "animations/images/grossini_gray");

                //
                // Animation using Sprite batch
                //
                CCSprite sprite = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");
                sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2));

                CCSprite point = CCSprite.spriteWithFile("Images/r1");
                point.scale    = 0.25f;
                point.position = sprite.position;
                addChild(point, 1);

                switch (i)
                {
                case 0:
                    sprite.anchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.anchorPoint = (new CCPoint(0.5f, 0.5f));
                    break;

                case 2:
                    sprite.anchorPoint = (new CCPoint(1, 1));
                    break;
                }

                point.position = sprite.position;

                List <CCSpriteFrame> 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.spriteFrameByName(tmp);
                    animFrames.Add(frame);
                }

                CCAnimation animation = CCAnimation.animationWithFrames(animFrames);
                sprite.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithDuration(2.8f, animation, false)));

                animFrames = null;

                // Skew
                CCSkewBy         skewX      = CCSkewBy.actionWithDuration(2, 45, 0);
                CCActionInterval skewX_back = (CCActionInterval)skewX.reverse();
                CCSkewBy         skewY      = CCSkewBy.actionWithDuration(2, 0, 45);
                CCActionInterval skewY_back = (CCActionInterval)skewY.reverse();

                CCFiniteTimeAction seq_skew = CCSequence.actions(skewX, skewX_back, skewY, skewY_back);
                sprite.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq_skew));

                // Scale
                CCScaleBy          scale      = CCScaleBy.actionWithDuration(2, 2);
                CCActionInterval   scale_back = (CCActionInterval)scale.reverse();
                CCFiniteTimeAction seq_scale  = CCSequence.actions(scale, scale_back);
                sprite.runAction(CCRepeatForever.actionWithAction((CCActionInterval)seq_scale));

                addChild(sprite, 0);
            }
        }
        public SpriteBatchNodeOffsetAnchorRotation()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            for (int i = 0; i < 3; i++)
            {
                CCSpriteFrameCache cache = CCSpriteFrameCache.sharedSpriteFrameCache();
                cache.addSpriteFramesWithFile("animations/grossini");
                cache.addSpriteFramesWithFile("animations/grossini_gray", "animations/images/grossini_gray");

                //
                // Animation using Sprite BatchNode
                //
                CCSprite sprite = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");
                sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2));

                CCSprite point = CCSprite.spriteWithFile("Images/r1");
                point.scale    = 0.25f;
                point.position = sprite.position;
                addChild(point, 200);

                switch (i)
                {
                case 0:
                    sprite.anchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
                    break;

                case 2:
                    sprite.anchorPoint = new CCPoint(1, 1);
                    break;
                }

                point.position = sprite.position;

                CCSpriteBatchNode spritebatch = CCSpriteBatchNode.batchNodeWithFile("animations/images/grossini");
                addChild(spritebatch);

                List <CCSpriteFrame> animFrames = new List <CCSpriteFrame>(14);
                string str = "";
                for (int k = 0; k < 14; k++)
                {
                    string temp = "";
                    if (k + 1 < 10)
                    {
                        temp = "0" + (k + 1);
                    }
                    else
                    {
                        temp = k + 1 + "";
                    }
                    str = string.Format("grossini_dance_{0}.png", temp);
                    CCSpriteFrame frame = cache.spriteFrameByName(str);
                    animFrames.Add(frame);
                }

                CCAnimation animation = CCAnimation.animationWithFrames(animFrames);
                sprite.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithAnimation(animation, false)));
                sprite.runAction(CCRepeatForever.actionWithAction(CCRotateBy.actionWithDuration(10, 360)));

                spritebatch.addChild(sprite, i);

                //animFrames.release();    // win32 : memory leak    2010-0415
            }
        }
        public SpriteOffsetAnchorScale()
        {
            CCSize s = CCDirector.sharedDirector().getWinSize();

            for (int i = 0; i < 3; i++)
            {
                CCSpriteFrameCache cache = CCSpriteFrameCache.sharedSpriteFrameCache();
                cache.addSpriteFramesWithFile("animations/grossini");
                cache.addSpriteFramesWithFile("animations/grossini_gray", "animations/images/grossini_gray");

                //
                // Animation using Sprite BatchNode
                //
                CCSprite sprite = CCSprite.spriteWithSpriteFrameName("grossini_dance_01.png");
                sprite.position = (new CCPoint(s.width / 4 * (i + 1), s.height / 2));

                CCSprite point = CCSprite.spriteWithFile("Images/r1");
                point.scale    = 0.25f;
                point.position = sprite.position;
                addChild(point, 1);

                switch (i)
                {
                case 0:
                    sprite.anchorPoint = new CCPoint(0, 0);
                    break;

                case 1:
                    sprite.anchorPoint = new CCPoint(0.5f, 0.5f);
                    break;

                case 2:
                    sprite.anchorPoint = new CCPoint(1, 1);
                    break;
                }

                point.position = sprite.position;

                List <CCSpriteFrame> 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.spriteFrameByName(str);
                    animFrames.Add(frame);
                }

                CCAnimation animation = CCAnimation.animationWithFrames(animFrames);
                sprite.runAction(CCRepeatForever.actionWithAction(CCAnimate.actionWithAnimation(animation, false)));

                CCActionInterval scale      = CCScaleBy.actionWithDuration(2, 2);
                CCActionInterval scale_back = (CCActionInterval)scale.reverse();
                CCActionInterval seq_scale  = (CCActionInterval)(CCSequence.actions(scale, scale_back));
                sprite.runAction(CCRepeatForever.actionWithAction(seq_scale));

                addChild(sprite, 0);

                //animFrames->release();    // win32 : memory leak    2010-0415
            }
        }