Package com.mygdx.game.Entitys
Class Entity
- java.lang.Object
-
- com.mygdx.game.Entitys.Entity
-
- Direct Known Subclasses:
Building
,CannonBall
,Chest
,College
,Indicator
,Obstacle
,PowerUpPickup
,Ship
,WorldMap
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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addComponent(Component component)
void
addComponents(Component... components)
void
cleanUp()
Similar to the Component's cleanUp eventvoid
dispose()
disposes of any components attached to this objectComponent
getComponent(ComponentType type)
gets component of type<T> T
getComponent(java.lang.Class<T> type)
Gets the first component that is of the same type as Tjava.lang.String
getName()
void
raiseEvents(ComponentEvent... events)
Raises the appropriate events on each component with exception to renderingvoid
setName(java.lang.String name)
Sets the name of the entityvoid
update()
Similar to the Component's update event
-
-
-
Method Detail
-
setName
public final void setName(java.lang.String name)
Sets the name of the entity- Parameters:
name
- string to set the name to
-
getName
public final java.lang.String getName()
- Returns:
- the name of the Entity
-
addComponent
public void addComponent(Component component)
- Parameters:
component
- the component to be added
-
addComponents
public void addComponents(Component... components)
- Parameters:
components
- the components to be added
-
getComponent
public Component getComponent(ComponentType type)
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
-
raiseEvents
public final void raiseEvents(ComponentEvent... events)
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
-
dispose
public void dispose()
disposes of any components attached to this object
-
-