Esempio n. 1
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("Images/ui.plist");

            float x = winSize.Width / 4;
            float y = 0 + (winSize.Height / 2);

            var buttonNormal = CCScale9Sprite.SpriteWithFrameName("button_normal.png");

            buttonNormal.Position = new CCPoint(x, y);

            buttonNormal.ContentSize = new CCSize(14 * 16, 10 * 16);

            AddChild(buttonNormal);

            x = winSize.Width * 3 / 4;

            var buttonActivated = CCScale9Sprite.SpriteWithFrameName("button_actived.png");

            buttonActivated.Position = new CCPoint(x, y);

            buttonActivated.ContentSize = new CCSize(14 * 16, 10 * 16);

            AddChild(buttonActivated);
        }
Esempio n. 2
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);
            var    rgba    = new CCLayer();

            rgba.IsColorCascaded   = true;
            rgba.IsOpacityCascaded = true;
            AddChild(rgba);

            CCLog.Log("S9CascadeOpacityAndColor ...");

            var blocks_scaled_with_insets = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            CCLog.Log("... created");

            blocks_scaled_with_insets.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            rgba.AddChild(blocks_scaled_with_insets);
            var actions = new CCSequence(new CCFadeIn(1),
                                         new CCTintTo(1, 0, 255, 0),
                                         new CCTintTo(1, 255, 255, 255),
                                         new CCFadeOut(1));
            var repeat = new CCRepeatForever(actions);

            rgba.RunAction(repeat);
            CCLog.Log("AddChild");

            CCLog.Log("... S9CascadeOpacityAndColor done.");
        }
Esempio n. 3
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            CCLog.Log("Scale9FrameNameSpriteSheetRotatedSetCapInsetLater ...");

            var blocks_scaled_with_insets = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            CCLog.Log("... created");

            blocks_scaled_with_insets.InsetLeft  = 32;
            blocks_scaled_with_insets.InsetRight = 32;

            blocks_scaled_with_insets.PreferredSize = new CCSize(32 * 5.5f, 32 * 4);
            blocks_scaled_with_insets.Position      = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            AddChild(blocks_scaled_with_insets);
            CCLog.Log("AddChild");

            CCLog.Log("... Scale9FrameNameSpriteSheetRotatedSetCapInsetLater done.");
        }
Esempio n. 4
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            var blocksWithInsets = CCScale9Sprite.SpriteWithFrameName("blocks9r.png", new CCRect(32, 32, 32, 32));

            blocksWithInsets.Position = new CCPoint(x, y);

            AddChild(blocksWithInsets);
        }
Esempio n. 5
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize  = Layer.VisibleBoundsWorldspace.Size;
            var    position = winSize.Center;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("Images/blocks9ss.plist");

            var blocks = CCScale9Sprite.SpriteWithFrameName("blocks9cr.png");

            blocks.Position = position;

            AddChild(blocks);
        }
Esempio n. 6
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            var blocksScaled = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            blocksScaled.Position = new CCPoint(x, y);

            blocksScaled.ContentSize = new CCSize(96 * 4, 96 * 2);

            AddChild(blocksScaled);
        }
Esempio n. 7
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            var blocksScaledWithInsets = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            blocksScaledWithInsets.InsetLeft  = 32;
            blocksScaledWithInsets.InsetRight = 32;

            blocksScaledWithInsets.PreferredSize = new CCSize(32 * 5.5f, 32 * 4);
            blocksScaledWithInsets.Position      = new CCPoint(x, y);

            AddChild(blocksScaledWithInsets);
        }
Esempio n. 8
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;

            CCSpriteFrameCache.SharedSpriteFrameCache.AddSpriteFrames("Images/ui.plist");

            float x = winSize.Width / 4;
            float y = 0 + (winSize.Height / 2);

            CCLog.Log("S9_TexturePacker ...");

            var s = CCScale9Sprite.SpriteWithFrameName("button_normal.png");

            CCLog.Log("... created");

            s.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            s.ContentSize = new CCSize(14 * 16, 10 * 16);
            CCLog.Log("... setContentSize");

            AddChild(s);
            CCLog.Log("AddChild");

            x = winSize.Width * 3 / 4;

            var s2 = CCScale9Sprite.SpriteWithFrameName("button_actived.png");

            CCLog.Log("... created");

            s2.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            s2.ContentSize = new CCSize(14 * 16, 10 * 16);
            CCLog.Log("... setContentSize");

            AddChild(s2);
            CCLog.Log("AddChild");

            CCLog.Log("... S9_TexturePacker done.");
        }
Esempio n. 9
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            CCLog.Log("S9FrameNameSpriteSheet ...");

            var blocks = CCScale9Sprite.SpriteWithFrameName("blocks9.png");

            CCLog.Log("... created");

            blocks.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            AddChild(blocks);
            CCLog.Log("AddChild");

            CCLog.Log("... S9FrameNameSpriteSheet done.");
        }
Esempio n. 10
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);
            var    rgba    = new CCLayer();

            rgba.IsColorCascaded   = true;
            rgba.IsOpacityCascaded = true;
            AddChild(rgba);

            var blocksScaledWithInsets = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            blocksScaledWithInsets.Position = new CCPoint(x, y);

            rgba.AddChild(blocksScaledWithInsets);
            var actions = new CCSequence(new CCFadeIn(1),
                                         new CCTintTo(1, 0, 255, 0),
                                         new CCTintTo(1, 255, 255, 255),
                                         new CCFadeOut(1));

            rgba.RepeatForever(actions);
        }
Esempio n. 11
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            CCLog.Log("S9FrameNameSpriteSheetRotatedInsetsScaled ...");

            var blocks_scaled_with_insets = CCScale9Sprite.SpriteWithFrameName("blocks9.png", new CCRect(32, 32, 32, 32));

            CCLog.Log("... created");

            blocks_scaled_with_insets.ContentSize = new CCSize(96 * 4.5f, 96 * 2.5f);
            CCLog.Log("... setContentSize");

            blocks_scaled_with_insets.Position = new CCPoint(x, y);
            CCLog.Log("... setPosition");

            AddChild(blocks_scaled_with_insets);
            CCLog.Log("AddChild");

            CCLog.Log("... S9FrameNameSpriteSheetRotatedInsetsScaled done.");
        }
Esempio n. 12
0
        public override void OnEnter()
        {
            base.OnEnter();
            CCSize winSize = Layer.VisibleBoundsWorldspace.Size;
            float  x       = winSize.Width / 2;
            float  y       = 0 + (winSize.Height / 2);

            var statusLabel = new CCLabel("Scale9Enabled", "arial", 10, CCLabelFormat.SpriteFont);

            statusLabel.PositionX = x;
            statusLabel.PositionY = winSize.Height - statusLabel.ContentSize.Height - 100;
            AddChild(statusLabel);

            var normalSprite = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            normalSprite.PositionX = x;
            normalSprite.PositionY = y;
            AddChild(normalSprite);


            var normalLabel = new CCLabel("Normal Sprite", "Arial", 10, CCLabelFormat.SpriteFont);

            normalLabel.Position += normalSprite.Position +
                                    new CCPoint(0, normalSprite.ScaledContentSize.Height / 2 + 10);
            AddChild(normalLabel);



            var flipXSprite = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            flipXSprite.PositionX = x - 150;
            flipXSprite.PositionY = y;
            flipXSprite.Scale     = 1.2f;
            AddChild(flipXSprite);
            flipXSprite.IsFlippedX = false;

            var flipXLabel = new CCLabel("sprite is not flipped!", "Arial", 10, CCLabelFormat.SpriteFont);

            flipXLabel.Position = flipXSprite.Position +
                                  new CCPoint(0, flipXSprite.ScaledContentSize.Height / 2 + 10);
            AddChild(flipXLabel);


            var flipYSprite = CCScale9Sprite.SpriteWithFrameName("blocks9r.png");

            flipYSprite.PositionX = x + 150;
            flipYSprite.PositionY = y;
            flipYSprite.Scale     = 0.8f;
            AddChild(flipYSprite);
            flipYSprite.IsFlippedY = true;

            var flipYLabel = new CCLabel("sprite is flipped!", "Arial", 10, CCLabelFormat.SpriteFont);

            flipYLabel.Position = flipYSprite.Position +
                                  new CCPoint(0, flipYSprite.ScaledContentSize.Height / 2 + 10);
            AddChild(flipYLabel);


            var toggleFlipXButton = new CCControlButton("Toggle FlipX", "arial", 12);

            toggleFlipXButton.Position = flipXSprite.Position +
                                         new CCPoint(0, -20 - flipXSprite.ScaledContentSize.Height / 2);


            toggleFlipXButton.Clicked += (obj, cevent) =>
            {
                flipXSprite.IsFlippedX = !flipXSprite.IsFlippedX;
                if (flipXSprite.IsFlippedX)
                {
                    flipXLabel.Text = "sprite is flipped";
                }
                else
                {
                    flipXLabel.Text = "sprite is not flipped";
                }
            };

            AddChild(toggleFlipXButton);

            var toggleFlipYButton = new CCControlButton("Toggle FlipY", "arial", 12);

            toggleFlipYButton.Position = flipYSprite.Position +
                                         new CCPoint(0, -20 - flipYSprite.ScaledContentSize.Height / 2);

            toggleFlipYButton.Clicked += (obj, cevent) =>
            {
                flipYSprite.IsFlippedY = !flipYSprite.IsFlippedY;
                if (flipYSprite.IsFlippedY)
                {
                    flipYLabel.Text = "sprite is flipped";
                }
                else
                {
                    flipYLabel.Text = "sprite is not flipped";
                }
            };

            AddChild(toggleFlipYButton);

            var toggleScale9Button = new CCControlButton("Toggle Scale9", "arial", 12);

            toggleScale9Button.Position = normalSprite.Position +
                                          new CCPoint(0, -20 - normalSprite.ContentSize.Height / 2);

            toggleScale9Button.Clicked += (obj, cevent) =>
            {
                flipXSprite.IsScale9Enabled = !flipXSprite.IsScale9Enabled;
                flipYSprite.IsScale9Enabled = !flipYSprite.IsScale9Enabled;

                if (flipXSprite.IsScale9Enabled)
                {
                    statusLabel.Text = "Scale9Enabled";
                }
                else
                {
                    statusLabel.Text = "Scale9Disabled";
                }

                if (flipXSprite.IsFlippedX)
                {
                    flipXLabel.Text = "sprite is flipped";
                }
                else
                {
                    flipXLabel.Text = "sprite is not flipped";
                }

                if (flipYSprite.IsFlippedY)
                {
                    flipYLabel.Text = "sprite is flipped";
                }
                else
                {
                    flipYLabel.Text = "sprite is not flipped";
                }
            };

            AddChild(toggleScale9Button);
        }
 public static CCScale9Sprite SpriteWithFrameName(string spriteFrameName)
 {
     return(CCScale9Sprite.SpriteWithFrameName(spriteFrameName, CCRect.Zero));
 }