Package-level declarations

Types

Link copied to clipboard
class LetterboxingViewport(var targetPpiX: Float = defaultTargetPpi, var targetPpiY: Float = defaultTargetPpi, var aspectRatio: Float = 4f / 3f) : ScalingViewport

Combines screen and fit viewports. Similarly to ScreenViewport, world size is changed on each update (resize), so update should be generally called with true parameter (camera should be centered). Tries to keep the passed aspect ratio by applying letterboxing - horizontal or vertical black bars.

Functions

Link copied to clipboard
fun ShapeRenderer.arc(position: Vector2, radius: Float, start: Float, degrees: Float)

See ShapeRenderer.arc. Estimates the number of segments needed for a smooth arc.

fun ShapeRenderer.arc(position: Vector2, radius: Float, start: Float, degrees: Float, segments: Int)

See ShapeRenderer.arc.

Link copied to clipboard
fun <B : Batch> B.begin(camera: Camera)

Sets the batch's projection matrix to the camera's Camera.combined matrix and calls Batch.begin.

fun <B : Batch> B.begin(projectionMatrix: Matrix4)

Automatically calls Batch.begin with the provided matrix

Link copied to clipboard
fun ShapeRenderer.box(position: Vector3, width: Float, height: Float, depth: Float)

See ShapeRenderer.box.

Link copied to clipboard
fun Camera.center(width: Float = Gdx.graphics.width.toFloat(), height: Float = Gdx.graphics.height.toFloat(), x: Float = 0.0f, y: Float = 0.0f)

Centers this Camera in the middle of the given rectangle. width and height represent the size of the rectangle in world (camera/viewport) units. x and y are optional offsets in world units that will modify camera position.

fun BitmapFont.center(text: String, width: Float, height: Float, x: Float = 0.0f, y: Float = 0.0f): Vector2

Calculates center position of the chosen text written with this BitmapFont on an object with given width and height drawn at x and y coordinates.

Link copied to clipboard
fun ShapeRenderer.circle(position: Vector2, radius: Float)

See ShapeRenderer.circle. Estimates the number of segments needed for a smooth circle.

fun ShapeRenderer.circle(position: Vector2, radius: Float, segments: Int)

See ShapeRenderer.circle.

Link copied to clipboard
fun color(red: Float, green: Float, blue: Float, alpha: Float = 1.0f): Color

Factory methods for libGDX Color class. Allows using named parameters.

Link copied to clipboard
inline operator fun Color.component1(): Float

Returns the red component of the color. Allows using destructuring declarations when working with libGDX Color class, for example:

Link copied to clipboard
inline operator fun Color.component2(): Float

Returns the green component of the color. Allows using destructuring declarations when working with libGDX Color class, for example:

Link copied to clipboard
inline operator fun Color.component3(): Float

Returns the blue component of the color. Allows using destructuring declarations when working with libGDX Color class, for example:

Link copied to clipboard
inline operator fun Color.component4(): Float

Returns the alpha component of the color. Allows using destructuring declarations when working with libGDX Color class, for example:

Link copied to clipboard
fun ShapeRenderer.cone(position: Vector3, radius: Float, height: Float)

See ShapeRenderer.cone. Estimates the number of segments needed for a smooth cone.

fun ShapeRenderer.cone(position: Vector3, radius: Float, height: Float, segments: Int)

See ShapeRenderer.cone.

Link copied to clipboard
fun Color.copy(red: Float? = null, green: Float? = null, blue: Float? = null, alpha: Float? = null): Color

Allows to copy this Color instance, optionally changing chosen properties.

Link copied to clipboard
fun ShapeRenderer.ellipse(position: Vector2, width: Float, height: Float, degrees: Float)

See ShapeRenderer.ellipse. Estimates the number of segments needed for a smooth ellipse.

fun ShapeRenderer.ellipse(position: Vector2, width: Float, height: Float, degrees: Float, segments: Int)

See ShapeRenderer.ellipse

Link copied to clipboard
fun Camera.lerpTo(target: Vector2, lerp: Float, x: Float = 0.0f, y: Float = 0.0f)

Will smoothly move the Camera at the selected target coordinated. The Camera will follow a target with a smooth linear interpolation, based on a lerp amount. lerp should be in range of 0 (slowest) to 1 (fastest). The lower that interpolation amount, the smoother - and thus slower - the following motion.

Link copied to clipboard
fun Camera.moveTo(target: Vector2, x: Float = 0.0f, y: Float = 0.0f)

Immediately moves Camera to the selected target coordinates. Not suitable for all cases, as it may cause a very rough motion when used every frame. x and y are optional offsets in world units that will modify camera position.

Link copied to clipboard
fun ShapeRenderer.rect(position: Vector2, size: Vector2)
fun ShapeRenderer.rect(position: Vector2, width: Float, height: Float)

See ShapeRenderer.rect.

Link copied to clipboard
fun ShapeRenderer.rectLine(positionA: Vector2, positionB: Vector2, width: Float, colorA: Color, colorB: Color)

See ShapeRenderer.rectLine.

Link copied to clipboard
fun ShapeRenderer.rotate(axis: Vector3, degrees: Float)

See ShapeRenderer.rotate. Multiplies the current transformation matrix by a rotation matrix.

Link copied to clipboard
fun ShapeRenderer.scale(scale: Vector2)

See ShapeRenderer.scale. Multiplies the current transformation matrix by a scale matrix, with z not scaled.

fun ShapeRenderer.scale(scale: Vector3)

See ShapeRenderer.scale. Multiplies the current transformation matrix by a scale matrix.

Link copied to clipboard
fun takeScreenshot(fileHandle: FileHandle)

Takes a screenshot of the entire screen and saves the image using the given fileHandle.

Link copied to clipboard
fun ShapeRenderer.translate(transform: Vector3)

See ShapeRenderer.translate. Multiplies the current transformation matrix by a translation matrix.

Link copied to clipboard
fun ShapeRenderer.triangle(pointA: Vector2, pointB: Vector2, pointC: Vector2)
fun ShapeRenderer.triangle(pointA: Vector2, pointB: Vector2, pointC: Vector2, colorA: Color, colorB: Color, colorC: Color)

See ShapeRenderer.triangle.

Link copied to clipboard
inline fun Camera.update(operation: Camera.() -> Unit)

Inlines the operation, which can update the camera position. Automatically calls Camera.update after the operation is finished.

Link copied to clipboard
inline fun <B : GLFrameBuffer<*>> B.use(action: (B) -> Unit)

Automatically calls GLFrameBuffer.begin and GLFrameBuffer.end.

inline fun <S : ShaderProgram> S.use(action: (S) -> Unit)

Automatically calls ShaderProgram.bind.

inline fun <B : Batch> B.use(camera: Camera, action: (B) -> Unit)
inline fun <B : Batch> B.use(projectionMatrix: Matrix4? = null, action: (B) -> Unit)

Automatically calls Batch.begin and Batch.end.

inline fun <SR : ShapeRenderer> SR.use(type: ShapeRenderer.ShapeType, camera: Camera, action: (SR) -> Unit)
inline fun <SR : ShapeRenderer> SR.use(type: ShapeRenderer.ShapeType, projectionMatrix: Matrix4? = null, action: (SR) -> Unit)

Automatically calls ShapeRenderer.begin and ShapeRenderer.end.