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();
        }
Example #2
0
        public CCAnimateState(CCAnimate action, CCNode target)
            : base(action, target)
        {
            Animation  = action.Animation;
            SplitTimes = action.SplitTimes;

            var sprite = (CCSprite)(target);

            OriginalFrame = null;

            if (Animation.RestoreOriginalFrame)
            {
                OriginalFrame = sprite.SpriteFrame;
            }

            NextFrame     = 0;
            ExecutedLoops = 0;
        }
Example #3
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));
        }
Example #4
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);
        }
Example #5
0
        public ActionAnimate()
        {
            var animation = new CCAnimation();
            for (var i = 1; i < 15; i++)
            {
                var szName = String.Format("Images/grossini_dance_{0:00}", i);
                animation.AddSpriteFrame(szName);
            }

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

            action = new CCAnimate(animation);

            var cache = CCAnimationCache.SharedAnimationCache;
            cache.AddAnimations("animations/animations-2.plist");
            var animation2 = cache["dance_1"];

            action2 = new CCAnimate (animation2);

            var animation3 = animation2.Copy();
            animation3.Loops = 4;

            action3 = new CCAnimate (animation3);
        }
        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;
        }
Example #7
0
        public CCAnimateState (CCAnimate action, CCNode target)
            : base (action, target)
        { 
            Animation = action.Animation;
            SplitTimes = action.SplitTimes;

            var sprite = (CCSprite)(target);

            OriginalFrame = null;

            if (Animation.RestoreOriginalFrame)
            {
                OriginalFrame = sprite.SpriteFrame;
            }

            NextFrame = 0;
            ExecutedLoops = 0;
        }