ktx
ktx copied to clipboard
Property delegate for component boolean flags in Ashley
The goal of this task is to add property delegates to ktx-ashley module to support checking for existence of specific components via entity properties. For example:
class Visible: Component
var Entity.isVisible: Boolean by tagFor<Visible>()
// Usage examples:
val engine = Engine()
val entity = Entity()
engine.addEntity(entity)
println(entity.isVisible) // false
// Adds a Visible component to entity:
entity.isVisible = true
println(entity.isVisible) // true
// Removes the Visible component from entity:
entity.isVisible = false
println(entity.isVisible) // false
Originally posted by @pylvain July 30, 2022, see #421