Skip to main content

FlixelGroupable

View source

interface

org.flixelgdx.group.FlixelGroupable

public interface FlixelGroupable<T>

Group-like containers with a typed member list. This interface is intentionally generic so libGDX projects can use FlixelGroup with any member type without adopting FlixelBasic.

FlixelGDX gameplay code that uses lifecycle flags and FlixelBasic.destroy() should implement FlixelBasicGroupable instead (or use FlixelBasicGroup / FlixelSpriteGroup).

Methods

add(T)

public void add(T member)

Adds a member to this group.


remove(T)

public void remove(T member)

Removes the member from this group only. Does not interpret or tear down the member; see FlixelBasicGroupable for optional destroy semantics on FlixelBasic members.


clear()

public void clear()

Removes all members from the group without touching member instances.


getMembers()

public SnapshotArray<T> getMembers()

Returns the backing array, or null if the implementation has not allocated it yet (FlixelGroup).


getMaxSize()

public int getMaxSize()

Returns the maximum number of members allowed. When 0, the group can grow without limit.


setMaxSize(int)

public void setMaxSize(int maxSize)

Sets the maximum number of members allowed. Values less than 0 are clamped to 0 (unlimited).


detach(T)

public default void detach(T member)

Removes the member from the group without additional teardown.

Parameters:

NameDescription
memberThe member to remove.

getFirstNullIndex()

public default int getFirstNullIndex()

Index of the first null slot in FlixelGroupable.getMembers(), or -1 if none.


forEachMember(Consumer<T>)

public default void forEachMember(Consumer<T> callback)

Invokes callback for each non-null member using snapshot iteration.

Parameters:

NameDescription
callbackThe callback to call for each member.

forEachMemberType(Class<C>, Consumer<C>)

public default void forEachMemberType(Class<C> type, Consumer<C> callback)

Invokes callback for each member assignable to type.

Parameters:

NameDescription
typeThe type to check.
callbackThe callback.