tagFor

inline fun <T : Component> tagFor(singleton: Boolean = true, noinline provider: () -> T): TagDelegate<T>

Returns a delegated property for the Entity class that check if the given Component is present within the entity. Changing the boolean value of the property will either add or remove the component from the entity, depending on whether the value is true or false respectively.

Assigning true to this property will obtain a Component instance with the passed provider.

If singleton setting is set to true, provider will be called once to obtain a component instance that will be reused by the property. If the setting is set to false, provider will be called each time true is assigned to the property.

See also


inline fun <T : Component> tagFor(singleton: Boolean = true): TagDelegate<T>

Returns a delegated property for the Entity class that check if the given Component is present within the entity. Changing the boolean value of the property will either add or remove the component from the entity, depending on whether the value is true or false respectively.

If singleton setting is set to true, an instance of the Component will be created once with reflection and reused by the property. If the setting is set to false, an instance will be created each time true is assigned to the property.

To use this property, ensure that the component class has a no-argument constructor. Otherwise, com.badlogic.gdx.utils.reflect.ReflectionException might be thrown.

See also


inline fun <T : Component> tagFor(component: T): TagDelegate<T>

Returns a delegated property for the Entity class that check if the given Component is present within the entity. Changing the boolean value of the property will either add or remove the component from the entity, depending on whether the value is true or false respectively.

Assigning true to this property will assign the component instance to the Entity.

This property delegate should be used only for stateless components without any mutable properties.

See also