Setting up touch controls for Android project

yes exactly, use Rectangle.Contains(point)

here’s a function I think I found on these forums originally. The more complex part for me was calculating the bounding rectangle, but depending on your project this is probably quite easy (I had to navigate a scene graph to calculate bounds, but in a simpler case just give it whatever box your sprite uses for drawing)

    private bool CheckTouch(Rectangle target, TouchCollection touchCollection)
    {
        if (touchCollection.Count > 0)
        {
            foreach (var touch in touchCollection)
            {
                if (target.Contains(touch.Position))
                {
                    return true;
                }
            }
        }
        return false;
    }
2 Likes