Exemplo n.º 1
0
        /** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */

        protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel,
                                                  CCLabelTTF offLabel)
        {
            if (base.Init())
            {
                Debug.Assert(maskSprite != null, "Mask must not be nil.");
                Debug.Assert(onSprite != null, "onSprite must not be nil.");
                Debug.Assert(offSprite != null, "offSprite must not be nil.");
                Debug.Assert(thumbSprite != null, "thumbSprite must not be nil.");

                TouchEnabled = true;
                _on          = true;

                _switchSprite = new CCControlSwitchSprite();
                _switchSprite.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite,
                                                 onLabel, offLabel);
                _switchSprite.Position = new CCPoint(_switchSprite.ContentSize.Width / 2, _switchSprite.ContentSize.Height / 2);
                AddChild(_switchSprite);

                IgnoreAnchorPointForPosition = false;
                AnchorPoint = new CCPoint(0.5f, 0.5f);
                ContentSize = _switchSprite.ContentSize;
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
        /** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */

        protected virtual bool InitWithMaskSprite(CCSprite maskSprite, CCSprite onSprite, CCSprite offSprite, CCSprite thumbSprite, CCLabelTTF onLabel,
                                       CCLabelTTF offLabel)
        {
            if (base.Init())
            {
                Debug.Assert(maskSprite != null, "Mask must not be nil.");
                Debug.Assert(onSprite != null, "onSprite must not be nil.");
                Debug.Assert(offSprite != null, "offSprite must not be nil.");
                Debug.Assert(thumbSprite != null, "thumbSprite must not be nil.");

                TouchEnabled = true;
                m_bOn = true;

                m_pSwitchSprite = new CCControlSwitchSprite();
                m_pSwitchSprite.InitWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite,
                                                   onLabel, offLabel);
                m_pSwitchSprite.Position = new CCPoint(m_pSwitchSprite.ContentSize.Width / 2, m_pSwitchSprite.ContentSize.Height / 2);
                AddChild(m_pSwitchSprite);

                IgnoreAnchorPointForPosition = false;
                AnchorPoint = new CCPoint(0.5f, 0.5f);
                ContentSize = m_pSwitchSprite.ContentSize;
                return true;
            }
            return false;
        }