Ejemplo n.º 1
0
        public bool IsEntityHovered(Transform2DComponent transform2D, Interaction2DComponent interaction2D, MouseState mouseState)
        {
            var bounds = RectangleExtension.Transform(interaction2D.Bounds, transform2D.WorldMatrix);

            var mousePosition =
                _viewportAdapter == null ?
                mouseState.Position : _viewportAdapter.PointToScreen(mouseState.Position);

            return(bounds.Intersects(mousePosition));

            //return mouseState.Position.X >= bounds.X &&
            //       mouseState.Position.X <= bounds.X + bounds.Width &&
            //       mouseState.Position.Y >= bounds.Y &&
            //       mouseState.Position.Y <= bounds.Y + bounds.Height;
        }
Ejemplo n.º 2
0
        public Rectangle GetBoundingRectangle(Transform2DComponent transform2D)
        {
            var rectBody = new Rectangle(Offset.ToPoint(), Size.ToPoint());

            return(RectangleExtension.Transform(rectBody, transform2D.WorldMatrix));
        }