public void SetOn(bool isOn, bool animated)
        {
            bool bNotify = false;

            if (m_bOn != isOn)
            {
                m_bOn   = isOn;
                bNotify = true;
            }

            m_pSwitchSprite.RunAction(
                new CCActionTween(
                    0.2f,
                    "sliderXPosition",
                    m_pSwitchSprite.SliderXPosition,
                    (m_bOn) ? m_pSwitchSprite.OnPosition : m_pSwitchSprite.OffPosition
                    )
                );

            if (bNotify)
            {
                SendActionsForControlEvents(CCControlEvent.ValueChanged);
                if (OnValueChanged != null)
                {
                    OnValueChanged(this, m_bOn);
                }
            }
        }
Exemplo n.º 2
0
        public void SetOn(bool isOn, bool animated)
        {
            bool bNotify = false;

            if (_on != isOn)
            {
                _on     = isOn;
                bNotify = true;
            }

            if (animated)
            {
                _switchSprite.RunAction(
                    new CCActionTween(
                        0.2f,
                        "sliderXPosition",
                        _switchSprite.SliderXPosition,
                        (_on) ? _switchSprite.OnPosition : _switchSprite.OffPosition
                        )
                    );
            }
            else
            {
                _switchSprite.SliderXPosition = (_on) ? _switchSprite.OnPosition : _switchSprite.OffPosition;
            }

            if (bNotify)
            {
                SendActionsForControlEvents(CCControlEvent.ValueChanged);
                if (OnValueChanged != null)
                {
                    OnValueChanged(this, _on);
                }
            }
        }
Exemplo n.º 3
0
        public void SetOn(bool isOn, bool animated)
        {
            m_bOn = isOn;

            m_pSwitchSprite.RunAction(
                new CCActionTween(
                    0.2f,
                    "sliderXPosition",
                    m_pSwitchSprite.SliderXPosition,
                    (m_bOn) ? m_pSwitchSprite.OnPosition : m_pSwitchSprite.OffPosition
                    )
                );

            SendActionsForControlEvents(CCControlEvent.ValueChanged);
        }