Exemplo n.º 1
0
 /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */
 public static CCControlSwitch Create(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel,
                                      CCLabelTTF offLabel)
 {
     var pRet = new CCControlSwitch();
     pRet.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel);
     return pRet;
 }
Exemplo n.º 2
0
        public override bool Init()
        {
            if (base.Init())
            {
                CCSize screenSize = CCDirector.SharedDirector.WinSize;

                CCNode layer = new CCNode ();
                layer.Position = new CCPoint(screenSize.Width / 2, screenSize.Height / 2);
                AddChild(layer, 1);

                float layer_width = 0.0f;

                // Add the black background for the text
                CCScale9Sprite background = new CCScale9SpriteFile("extensions/buttonBackground");
                background.ContentSize = new CCSize(80, 50);
                background.Position = new CCPoint(layer_width + background.ContentSize.Width / 2.0f, 0);
                layer.AddChild(background);

                layer_width += background.ContentSize.Width;

                m_pDisplayValueLabel = new CCLabelTTF("#color", "Marker Felt", 30);

                m_pDisplayValueLabel.Position = background.Position;
                layer.AddChild(m_pDisplayValueLabel);

                // Create the switch
                CCControlSwitch switchControl = new CCControlSwitch
                    (
                        new CCSprite("extensions/switch-mask"),
                        new CCSprite("extensions/switch-on"),
                        new CCSprite("extensions/switch-off"),
                        new CCSprite("extensions/switch-thumb"),
                        new CCLabelTTF("On", "Arial-BoldMT", 16),
                        new CCLabelTTF("Off", "Arial-BoldMT", 16)
                    );
                switchControl.Position = new CCPoint(layer_width + 10 + switchControl.ContentSize.Width / 2, 0);
                layer.AddChild(switchControl);

                switchControl.AddTargetWithActionForControlEvents(this, valueChanged, CCControlEvent.ValueChanged);

                // Set the layer size
                layer.ContentSize = new CCSize(layer_width, 0);
                layer.AnchorPoint = new CCPoint(0.5f, 0.5f);

                // Update the value label
                valueChanged(switchControl, CCControlEvent.ValueChanged);
                return true;
            }
            return false;
        }
Exemplo n.º 3
0
 /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */
 public static CCControlSwitch Create(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite)
 {
     var pRet = new CCControlSwitch();
     pRet.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, null, null);
     return pRet;
 }