SolidTags

value class SolidTags(val bits: Int)(source)

A set of up to 32 tags a game gives its solids, such as "bounce pad" or "ice", one bit each. Events.floorTagsOf reports the tags of the floors a particle stood on.

Build a set from single tags with of and plus: SolidTags.of(0) + SolidTags.of(3). bits holds tag i in bit i. toString lists the tag numbers in ascending order, as SolidTags(0, 3), and NONE prints as SolidTags().

Samples

val ice = SolidTags.of(0)
val lava = SolidTags.of(1)
val both = ice + lava
assertPrints(both, "SolidTags(0, 1)")
assertPrints(both.intersects(lava), "true")
assertPrints(ice.intersects(lava), "false")

Constructors

Link copied to clipboard
constructor(bits: Int)

Types

Link copied to clipboard
object Companion

Holds the empty set and builds the set of a single tag.

Properties

Link copied to clipboard
val bits: Int

The tags as bits: tag i is in the set when bit i is set.

Functions

Link copied to clipboard

Returns true if this set and other have at least one tag in common.

Link copied to clipboard
operator fun plus(other: SolidTags): SolidTags

Returns the set of tags that are in this set, in other, or in both.

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