示例#1
0
文件: FButton.cs 项目: lbonilla/Mango
    virtual public bool HandleSingleTouchBegan(FTouch touch)
    {
        if (!buttonEnabled)
        {
            return(false);
        }

        _isTouchDown = false;

        if (!IsAncestryVisible())
        {
            return(false);
        }

        if (!_shouldUseCustomHitRect)
        {
            _hitRect = _sprite.textureRect;
        }

        Vector2 touchPos = _sprite.GetLocalTouchPosition(touch);

        if (_hitRect.Contains(touchPos))
        {
            if (_isEnabled)            //swallow touches all the time, but only listen to them when enabled
            {
                _sprite.element = _downElement;
                if (_shouldUseCustomColors)
                {
                    _sprite.color = _downColor;
                }

                if (_clickSoundName != null)
                {
                    FSoundManager.PlaySound(_clickSoundName);
                }

                if (SignalPress != null)
                {
                    SignalPress(this);
                }

                _isTouchDown = true;

                Debug.Log("HandleSingleTouchBegan - Button tapped!");
                _isEnabled = false;
            }

            return(true);
        }

        return(false);
    }