screenToWorld

fun View.screenToWorld(xPx: Float, yPx: Float, z: Float = 1.0f): Position

Get a world space position from a screen space position

Screen space is in Android device screen coordinates

Return

The world position of the point

Parameters

xPx

Horizontal screen coordinate in pixels where you want the world position. (0 = left, View Width = right) The x value is negative when the point is left of the View.getViewport, between 0 and the width of the View.getViewport width when the point is within the viewport, and greater than the width when the point is to the right of the viewport.

yPx

Vertical screen coordinate in pixels where you want the world position. (0 = top, View Height = bottom) The y value is negative when the point is above the View.getViewport, between 0 and the height of the View.getViewport height when the point is within the viewport, and greater than the height when the point is below the viewport.

z

Z is used for the depth between 1 and 0 (1 = near, 0 = infinity).