Пример #1
0
	public bool HandleSingleTouchBegan(FTouch touch)
	{
		Vector2 touchPos = _bg.GlobalToLocal(touch.position);
		
		if(_bg.textureRect.Contains(touchPos))
		{
			_bg.element = _downElement;
			
			if(_soundName != null) FSoundManager.PlaySound(_soundName);
			
			if(SignalPress != null) SignalPress(this);
			
			return true;	
		}
		
		return false;
	}
Пример #2
0
    virtual public bool HandleSingleTouchBegan(FTouch touch)
    {
        _isTouchDown = false;

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

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

        Vector2 touchPos = _sprite.GlobalToLocal(touch.position);

        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;
            }

            return(true);
        }

        return(false);
    }
Пример #3
0
    protected void UpdateHoverState()
    {
        if (_hoverElement == null || !_shouldCheckForHoverState)
        {
            return;
        }

        Vector2 touchPos = _bg.GlobalToLocal(Futile.MousePosition());

        Rect expandedRect = _bg.textureRect.CloneWithExpansion(expansionAmount);

        if (expandedRect.Contains(touchPos))
        {
            _bg.element = _hoverElement;
        }
        else
        {
            _bg.element = _upElement;
        }
    }
    public bool HandleSingleTouchBegan(FTouch touch)
    {
        if (!gameHasStarted && gameReadyToStart)
        {
            StartGame();
            return(true);
        }
        if (gameIsOver && !gameFullyOver)
        {
            return(false);
        }
        if (gameFullyOver && !initiatedSceneSwitch)
        {
            if (score >= 1000000)
            {
                TMain.SwitchToScene(TMain.SceneType.PeopleSceneGoalThree);
            }
            else
            {
                TMain.SwitchToScene(TMain.SceneType.ClickHeartsScene);
            }
            initiatedSceneSwitch = true;
        }

        for (int i = hearts.Count - 1; i >= 0; i--)
        {
            FSprite heart = hearts[i];

            if (heart.localRect.Contains(heart.GlobalToLocal(touch.position)))
            {
                previousScore = score;
                FSoundManager.PlaySound("rise");
                score += 40000;
                KillHeart(heart);
                break;
            }
        }

        return(true);
    }
Пример #5
0
    public void HandleMultiTouch(FTouch[] touches)
    {
        foreach (FTouch touch in touches)
        {
            if (touch.phase == TouchPhase.Began)
            {
                for (int i = thingies.Count - 1; i >= 0; i--)
                {
                    Thingy  thingy   = thingies[i];
                    FSprite sprite   = thingy.GetChildAt(0) as FSprite;
                    Vector2 touchPos = sprite.GlobalToLocal(touch.position);
                    Rect    rect     = sprite.textureRect;

                    if (rect.Contains(touchPos))
                    {
                        HandleGotThingy(thingy);
                        break;
                    }
                }
            }
        }
    }
Пример #6
0
 public bool SpriteContainsGlobalPoint(Vector2 globalPoint)
 {
     return(sprite_.localRect.Contains(sprite_.GlobalToLocal(globalPoint)));
 }