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. 2
0
        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. 3
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(new CCSequence(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(new CCSequence(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. 4
0
 protected CCAnimate(CCAnimate animate) : base(animate)
 {
     InitWithAnimation((CCAnimation) animate.m_pAnimation.Copy());
 }
Esempio n. 5
0
 protected CCAnimate(CCAnimate animate) : base(animate)
 {
     InitWithAnimation((CCAnimation)animate.m_pAnimation.Copy());
 }
Esempio n. 6
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 = new CCSequence(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 CCAnimate CreateAnimateAction()
        {
            var frameList = new List<CCSpriteFrame>();

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

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

            return animate;
        }
Esempio n. 8
0
 public static CCAnimate CreateAnimate(string[] spriteFrmaeName, float delay, uint loops = 0)
 {
     List<CCSpriteFrame> frames = new List<CCSpriteFrame>();
     for (int i = 0; i < spriteFrmaeName.Length; i++)
         frames.Add(Factory.CreateSpriteFrame(spriteFrmaeName[i]));
     CCAnimation animation = new CCAnimation(frames, delay);
     if (loops != 0) animation.Loops = loops;
     CCAnimate animate = new CCAnimate(animation);
     return animate;
 }