Touches

The touches of one kind that one step reported, filled in by Events. Read it in the step's systems and do not keep it: the next step writes over it. Reading allocates nothing.

toString gives how many touches it holds, for example Touches(size=2).

Samples

val world = PhysicsWorld()
val ground = world.rigidBody(Shape.box(200f, 10f), x = 0f, y = 30f, kind = BodyKind.STATIC)
val ball = world.rigidBody(Shape.circle(5f), x = 0f, y = 0f)
var landed = false
repeat(60) {
    world.step(1.seconds / 60)
    if (world.events.contactsBegun.has(TouchSide.of(ball), TouchSide.of(ground))) landed = true
}
assertPrints(landed, "true")

Properties

Link copied to clipboard
var size: Int

Number of touches.

Functions

Link copied to clipboard
operator fun get(index: Int): Touch

Returns touch index.

Link copied to clipboard

Returns true if there is a touch between a and b, either way round.

Link copied to clipboard

Returns true if any touch has side on either side.

Link copied to clipboard
open override fun toString(): String