Hitbox2D

class Hitbox2D(val minX: Float, val minY: Float, val maxX: Float, val maxY: Float, val inside: (ERROR CLASS: Symbol not found for Pair<kotlin/Float, kotlin/Float>) -> Boolean) : Hitbox

A 2D hitbox for collision detection.

Constructors

Link copied to clipboard
constructor(minX: Float, minY: Float, maxX: Float, maxY: Float, inside: (ERROR CLASS: Symbol not found for Pair<kotlin/Float, kotlin/Float>) -> Boolean)
constructor(minX: Float, minY: Float, maxX: Float, maxY: Float)

Creates a rectangular hitbox defined by its minimum and maximum x and y coordinates.

constructor(min: ERROR CLASS: Symbol not found for Pair<kotlin/Float, kotlin/Float>, max: ERROR CLASS: Symbol not found for Pair<kotlin/Float, kotlin/Float>)

Creates a rectangular hitbox defined by its minimum and maximum points.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val id: Long

The unique ID of this hitbox.

Link copied to clipboard
val inside: (ERROR CLASS: Symbol not found for Pair<kotlin/Float, kotlin/Float>) -> Boolean

A function that takes a pair of (x, y) coordinates and returns true if the point is inside the hitbox.

Link copied to clipboard
val maxX: Float

The right-most side of the hitbox

Link copied to clipboard
val maxY: Float

The bottom-most side of the hitbox

Link copied to clipboard
val minX: Float

The left-most side of the hitbox

Link copied to clipboard
val minY: Float

The top-most side of the hitbox

Functions

Link copied to clipboard
fun add(other: Hitbox2D): Hitbox2D

Combines this hitbox with another hitbox using a union operation. The resulting hitbox contains all points that are inside either of the original hitboxes.

fun add(x: Float, y: Float, width: Float, height: Float): Hitbox2D

Adds a rectangular hitbox to this hitbox. The resulting hitbox contains all points that are inside either the original hitbox or the new rectangle.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun inside(point: ERROR CLASS: Symbol not found for Pair<kotlin/Double, kotlin/Double>): Boolean

Checks if the given double point is inside the hitbox.

fun inside(point: ERROR CLASS: Symbol not found for Pair<kotlin/Int, kotlin/Int>): Boolean

Checks if the given integer point is inside the hitbox.

Checks if the given double coordinates are inside the hitbox.

fun inside(x: Float, y: Float): Boolean

Checks if the given float coordinates are inside the hitbox.

fun inside(x: Int, y: Int): Boolean

Checks if the given integer coordinates are inside the hitbox.

Link copied to clipboard

Returns whether the sprite is above the given Y boundary using minY.

Link copied to clipboard

Returns whether the sprite is below the given Y boundary using maxY.

Link copied to clipboard
fun isLeft(x: Float, position: Float = 0.0f): Boolean

Returns whether the sprite is left of the given X boundary using minX.

Link copied to clipboard

Returns whether the sprite is right of the given X boundary using maxX.

Link copied to clipboard
operator fun plus(other: Hitbox2D): Hitbox2D
Link copied to clipboard
open override fun toString(): String