Package com.mygdx.game.Entitys
Class Entity
java.lang.Object
com.mygdx.game.Entitys.Entity
public class Entity
extends java.lang.Object
The base class for all entities in the game.
I am calling an entity pretty much anything that the user sees or interacts with except the UI.
However, there is over head with this class so in some cases it's better to just use raw sprites
-
Constructor Summary
-
Method Summary
Modifier and Type Method Description voidaddComponent(Component component)voidaddComponents(Component... components)voidcleanUp()Similar to the Component's cleanUp eventComponentgetComponent(ComponentType type)gets component of type<T> TgetComponent(java.lang.Class<T> type)Gets the first component that is of the same type as T<T> java.util.ArrayList<T>getComponents(java.lang.Class<T> type)Gets the list of components that is of the same type as Tjava.lang.StringgetName()voidraiseEvents(ComponentEvent... events)Raises the appropriate events on each component with exception to renderingvoidsetName(java.lang.String name)voidupdate()Similar to the Component's update eventMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Entity
public Entity() -
Entity
public Entity(int numComponents)Allocates the correct amount of memory for components- Parameters:
numComponents- number of components to allocate memory for
-
-
Method Details
-
setName
public final void setName(java.lang.String name) -
getName
public final java.lang.String getName() -
addComponent
-
addComponents
-
getComponent
gets component of type- Parameters:
type- the type of the desired component- Returns:
- the component not cast
-
getComponent
public <T> T getComponent(java.lang.Class<T> type)Gets the first component that is of the same type as T- Type Parameters:
T- the type of the desired component- Parameters:
type- [T].class- Returns:
- the component cast to the appropriate type
-
getComponents
public <T> java.util.ArrayList<T> getComponents(java.lang.Class<T> type)Gets the list of components that is of the same type as T- Type Parameters:
T- the type of the desired component- Parameters:
type- [T].class- Returns:
- the components cast to the appropriate type
-
raiseEvents
Raises the appropriate events on each component with exception to rendering -
cleanUp
public void cleanUp()Similar to the Component's cleanUp event -
update
public void update()Similar to the Component's update event
-