Example #1
0
        public override void OnEnter()
        {
            base.OnEnter();

            m_tamara.RemoveFromParentAndCleanup(true);
            m_grossini.RemoveFromParentAndCleanup(true);
            m_kathia.RemoveFromParentAndCleanup(true);

            var s = CCDirector.SharedDirector.WinSize;

            CCSize boxSize = new CCSize(100.0f, 100.0f);

            CCLayerColor box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box.ContentSize = boxSize;
            box.IgnoreAnchorPointForPosition = false;
            box.Position = new CCPoint(s.Width / 2, s.Height - 100 - box.ContentSize.Height / 2);
            this.AddChild(box);
            CCLabelTTF label = new CCLabelTTF("Standard cocos2d Skew", "Marker Felt", 16);
            label.Position = new CCPoint(s.Width / 2, s.Height - 100 + label.ContentSize.Height);
            this.AddChild(label);
            CCSkewBy actionTo = new CCSkewBy(2, 360, 0);
            CCSkewBy actionToBack = new CCSkewBy(2, -360, 0);

            box.RunAction(new CCSequence(actionTo, actionToBack));

            box = new CCLayerColor(new CCColor4B(255, 255, 0, 255));
            box.AnchorPoint = new CCPoint(0.5f, 0.5f);
            box.ContentSize = boxSize;
            box.IgnoreAnchorPointForPosition = false;
            box.Position = new CCPoint(s.Width / 2, s.Height - 250 - box.ContentSize.Height / 2);
            this.AddChild(box);
            label = new CCLabelTTF("Rotational Skew", "Marker Felt", 16);
            label.Position = new CCPoint(s.Width / 2, s.Height - 250 + label.ContentSize.Height / 2);
            this.AddChild(label);
            CCRotateBy actionTo2 = new CCRotateBy(2, 360, 0);
            CCRotateBy actionToBack2 = new CCRotateBy(2, -360, 0);
            box.RunAction(new CCSequence(actionTo2, actionToBack2));
        }
        public SpriteOffsetAnchorSkew()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            for (int i = 0; i < 3; i++)
            {
                CCSpriteFrameCache cache = CCSpriteFrameCache.SharedSpriteFrameCache;
                cache.AddSpriteFramesWithFile("animations/grossini.plist");
                cache.AddSpriteFramesWithFile("animations/grossini_gray.plist", "animations/grossini_gray");

                //
                // Animation using Sprite batch
                //
                CCSprite sprite = new CCSprite("grossini_dance_01.png");
                sprite.Position = (new CCPoint(s.Width / 4 * (i + 1), s.Height / 2));

                CCSprite point = new CCSprite("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;

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

                CCAnimation animation = new CCAnimation(animFrames, 0.3f);
                sprite.RunAction(new CCRepeatForever (new CCAnimate (animation)));

                animFrames = null;

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

                CCFiniteTimeAction seq_skew = CCSequence.FromActions(skewX, skewX_back, skewY, skewY_back);
                sprite.RunAction(new CCRepeatForever ((CCActionInterval)seq_skew));

                AddChild(sprite, 0);
            }
        }
Example #3
0
        public override void OnEnter()
        {
            base.OnEnter();

            centerSprites(3);

            var actionTo = new CCSkewTo (2, 37.2f, -37.2f);
            var actionToBack = new CCSkewTo (2, 0, 0);
            var actionBy = new CCSkewBy (2, 0.0f, -90.0f);
            var actionBy2 = new CCSkewBy (2, 45.0f, 45.0f);
            var actionByBack = actionBy.Reverse();

            m_tamara.RunAction(new CCSequence(actionTo, actionToBack));
            m_grossini.RunAction(new CCSequence(actionBy, actionByBack));

            m_kathia.RunAction(new CCSequence(actionBy2, actionBy2.Reverse()));
        }
        /// <summary>
        /// Creates a sequence of actions that causes a sprite to be skewed on the screen.
        /// </summary>
        /// <param name="repeatForever">A boolean value that determines if the action should be repeated indefinitely.</param>
        /// <returns></returns>
        private static CCActionInterval SkewAction(bool repeatForever)
        {
            // Create an action to skew the sprite
            CCActionInterval skewAction = new CCSkewBy(0.2f, 10, 5);

            // Setup an action sequence to perform the skew action, then reverse it
            skewAction = new CCSequence(skewAction, skewAction.Reverse());

            // If necessary, repeat the skew actions above indefinitely
            if (repeatForever) skewAction = new CCRepeatForever(skewAction);

            return skewAction;
        }