Vector2 MousePosition { get; set; }

book_4_sparkGenerated
code_blocksInput

Description

The MousePosition property of the MapView class provides the current position of the mouse cursor within the map view. This position is represented as a Vector2, which includes the X and Y coordinates of the mouse cursor relative to the map view's coordinate system.

Usage

Use the MousePosition property to retrieve the current mouse cursor position within the map view. This can be useful for implementing interactive features such as selecting or manipulating objects within the map view based on the mouse position.

Example

// Example of accessing the MousePosition property

// Assume 'mapView' is an instance of MapView
Vector2 currentMousePosition = mapView.MousePosition;

// Use the mouse position for further processing
float mouseX = currentMousePosition.x;
float mouseY = currentMousePosition.y;

// Example: Print the mouse position
// Note: Avoid using Console.WriteLine in s&box
// Instead, use appropriate logging or UI display methods
Log.Info($"Mouse Position: X = {mouseX}, Y = {mouseY}");