Class Entity
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
- All Implemented Interfaces:
EntityRenderedListener,EntityRenderListener,IEntity,Tweenable,EventListener
- Direct Known Subclasses:
CollisionEntity,Emitter,LightSource,MapArea,SoundSource,Spawnpoint
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactions()All registered actions of this entity.voidaddController(IEntityController controller) Adds a controller to the entity.voidaddEntityRenderListener(EntityRenderListener listener) Adds the specifiedEntityRenderListenerto receive events and callbacks about the rendering process of entities.voidaddListener(EntityListener listener) Adds aEntityListenerto this entity that fires whenever the entity is added to or removed from the environment.voidAdds a tag to the entity.voidaddTransformListener(EntityTransformListener listener) Adds aEntityTransformListenerto receive transform events for this entity.Gets the entities animation controller.voidAttaches all controllers to this entity.behavior()Gets the behavior controller of the entity.booleanThis method gets called before anEntityis about to be rendered.voidDetaches all controllers from this entity.doublegetAngle()Gets the bounding box of the entity.Gets the center point of the entity.<T extends IEntityController>
TgetController(Class<T> clss) Gets a specific controller of the entity.protected EntityControllersGets the environment the entity was loaded to or null if it is not loaded.doubleGets the height of the entity.Gets the location of the entity.intgetMapId()Gets the map ID of the entity.getName()Gets the name of this entity.Gets the custom properties of the entity.Gets the render type of the entity.getTags()Gets the list of tags associated with the entity.float[]getTweenValues(TweenType tweenType) Gets one or many values from the target object associated to the given tween type.doublegetWidth()Gets the width of the entity.doublegetX()Gets the X coordinate of the entity.doublegetY()Gets the Y coordinate of the entity.booleanChecks if the entity has the specified tag.booleanisLoaded()Indicates whether this entity is loaded on the currently active environment.booleanChecks if the entity is visible.voidloaded(Environment environment) This method provides the possibility to implement behavior whenever this entity was added to the environment.voidonMessage(EntityMessageListener listener) Adds aEntityMessageListenerto receive messages sent to this entity.voidonMessage(String message, EntityMessageListener listener) Adds aEntityMessageListenerto receive messages with a specific content sent to this entity.voidonRendered(EntityRenderedListener listener) Adds the specifiedEntityRenderedListenerto receive events when entities were rendered.voidPerforms anEntityActionthat was previously registered for this entity.Registers anEntityActionwith the specified name.voidremoved(Environment environment) This method provides the possibility to implement behavior whenever this entity was removed from the environment.voidremoveListener(EntityListener listener) Removes aEntityListenerfrom this entity.voidremoveListener(EntityMessageListener listener) Removes aEntityMessageListenerfrom this entity.voidremoveListener(EntityRenderedListener listener) Removes the specifiedEntityRenderedListener.voidremoveListener(EntityRenderListener listener) Removes the specifiedEntityRenderListener.voidremoveListener(EntityTransformListener listener) Removes aEntityTransformListenerfrom this entity.voidRemoves a tag from the entity.voidrendered(EntityRenderEvent event) This method gets called after an entity was rendered.voidrendering(EntityRenderEvent event) This method gets called after all rendering checks have successfully passed and right before the entity is about to be rendered.booleanDetermines whether this entity is being rendered with the layer it's originating from.sendMessage(Object sender, String message) Sends a message from the specified sender to this entity.voidsetAngle(double angle) Sets the angle (in degrees) in which the entity is directed.<T extends IEntityController>
voidsetController(Class<T> clss, T controller) Sets a specific controller for the entity.voidsetHeight(double height) Sets the height of the entity.voidsetLocation(double x, double y) Sets the location of the entity.voidsetLocation(Point2D location) Sets the map location.voidsetMapId(int mapId) Sets an id which should only be filled when an entity gets added due to map information.voidSets the name of the entity.voidsetRenderType(RenderType renderType) Sets the render type of the entity.voidsetRenderWithLayer(boolean renderWithLayer) Sets whether the entity should be rendered with its layer.voidsetSize(double width, double height) Sets the size of the entity.voidsetTweenValues(TweenType tweenType, float[] newValues) This method is called in a Tween's update() method to set the new interpolated values.voidsetVisible(boolean visible) Sets the visibility of the entity.voidsetWidth(double width) Sets the width of the entity.voidsetX(double x) Sets the X coordinate of the entity.voidsetY(double y) Sets the Y coordinate of the entity.toString()
-
Field Details
-
ANY_MESSAGE
- See Also:
-
-
Constructor Details
-
Entity
protected Entity() -
Entity
protected Entity(boolean renderWithLayer) -
Entity
protected Entity(int mapId) -
Entity
-
Entity
-
-
Method Details
-
addTransformListener
Description copied from interface:IEntityAdds aEntityTransformListenerto receive transform events for this entity.- Specified by:
addTransformListenerin interfaceIEntity- Parameters:
listener- TheEntityTransformListenerto add.
-
removeListener
Description copied from interface:IEntityRemoves aEntityTransformListenerfrom this entity.- Specified by:
removeListenerin interfaceIEntity- Parameters:
listener- TheEntityTransformListenerto remove.
-
addListener
Description copied from interface:IEntityAdds aEntityListenerto this entity that fires whenever the entity is added to or removed from the environment.- Specified by:
addListenerin interfaceIEntity- Parameters:
listener- TheEntityListenerto add.
-
removeListener
Description copied from interface:IEntityRemoves aEntityListenerfrom this entity.- Specified by:
removeListenerin interfaceIEntity- Parameters:
listener- TheEntityListenerto remove.
-
onRendered
Description copied from interface:IEntityAdds the specifiedEntityRenderedListenerto receive events when entities were rendered.- Specified by:
onRenderedin interfaceIEntity- Parameters:
listener- TheEntityRenderedListenerto add.
-
removeListener
Description copied from interface:IEntityRemoves the specifiedEntityRenderedListener.- Specified by:
removeListenerin interfaceIEntity- Parameters:
listener- TheEntityRenderedListenerto remove.
-
addEntityRenderListener
Description copied from interface:IEntityAdds the specifiedEntityRenderListenerto receive events and callbacks about the rendering process of entities.- Specified by:
addEntityRenderListenerin interfaceIEntity- Parameters:
listener- TheEntityRenderListenerto add.
-
removeListener
Description copied from interface:IEntityRemoves the specifiedEntityRenderListener.- Specified by:
removeListenerin interfaceIEntity- Parameters:
listener- TheEntityRenderListenerto remove.
-
onMessage
Description copied from interface:IEntityAdds aEntityMessageListenerto receive messages sent to this entity.- Specified by:
onMessagein interfaceIEntity- Parameters:
listener- TheEntityMessageListenerto add.
-
onMessage
Description copied from interface:IEntityAdds aEntityMessageListenerto receive messages with a specific content sent to this entity.- Specified by:
onMessagein interfaceIEntity- Parameters:
message- The message content to listen for.listener- TheEntityMessageListenerto add.
-
removeListener
Description copied from interface:IEntityRemoves aEntityMessageListenerfrom this entity.- Specified by:
removeListenerin interfaceIEntity- Parameters:
listener- TheEntityMessageListenerto remove.
-
attachControllers
public void attachControllers()Description copied from interface:IEntityAttaches all controllers to this entity.- Specified by:
attachControllersin interfaceIEntity
-
detachControllers
public void detachControllers()Description copied from interface:IEntityDetaches all controllers from this entity.- Specified by:
detachControllersin interfaceIEntity
-
getProperties
Description copied from interface:IEntityGets the custom properties of the entity.- Specified by:
getPropertiesin interfaceIEntity- Returns:
- The custom property provider of the entity.
-
getAngle
public double getAngle() -
animations
Description copied from interface:IEntityGets the entities animation controller.- Specified by:
animationsin interfaceIEntity- Returns:
- The entities animation controller or null if none was registered.
- See Also:
-
behavior
Description copied from interface:IEntityGets the behavior controller of the entity. -
addController
Description copied from interface:IEntityAdds a controller to the entity.- Specified by:
addControllerin interfaceIEntity- Parameters:
controller- The controller to add.
-
setController
Description copied from interface:IEntitySets a specific controller for the entity.- Specified by:
setControllerin interfaceIEntity- Type Parameters:
T- The type of the controller.- Parameters:
clss- The class of the controller.controller- The controller to set.
-
getController
Description copied from interface:IEntityGets a specific controller of the entity.- Specified by:
getControllerin interfaceIEntity- Type Parameters:
T- The type of the controller.- Parameters:
clss- The class of the controller.- Returns:
- The controller of the specified type.
-
getBoundingBox
Description copied from interface:IEntityGets the bounding box of the entity.- Specified by:
getBoundingBoxin interfaceIEntity- Returns:
- The bounding box of the entity.
-
getCenter
Description copied from interface:IEntityGets the center point of the entity. -
getHeight
public double getHeight()Description copied from interface:IEntityGets the height of the entity. -
getLocation
Description copied from interface:IEntityGets the location of the entity.- Specified by:
getLocationin interfaceIEntity- Returns:
- The location of the entity.
-
getMapId
public int getMapId()Description copied from interface:IEntityGets the map ID of the entity. -
getName
Description copied from interface:IEntityGets the name of this entity. -
getRenderType
Description copied from interface:IEntityGets the render type of the entity.- Specified by:
getRenderTypein interfaceIEntity- Returns:
- The render type of the entity.
-
getWidth
public double getWidth()Description copied from interface:IEntityGets the width of the entity. -
getX
public double getX()Description copied from interface:IEntityGets the X coordinate of the entity. -
getY
public double getY()Description copied from interface:IEntityGets the Y coordinate of the entity. -
isVisible
public boolean isVisible()Description copied from interface:IEntityChecks if the entity is visible. -
setVisible
public void setVisible(boolean visible) Description copied from interface:IEntitySets the visibility of the entity.- Specified by:
setVisiblein interfaceIEntity- Parameters:
visible- True to make the entity visible; false to make it invisible.
-
actions
Description copied from interface:IEntityAll registered actions of this entity. -
perform
Description copied from interface:IEntityPerforms anEntityActionthat was previously registered for this entity.Does nothing in case no action has been registered for the specified
actionName. -
register
Description copied from interface:IEntityRegisters anEntityActionwith the specified name. It's later possible to execute these actions on the entity by using theEntity.perform(String actionName)method. -
sendMessage
Description copied from interface:IEntitySends a message from the specified sender to this entity.- Specified by:
sendMessagein interfaceIEntity- Parameters:
sender- The sender of the message.message- The message to send.- Returns:
- The response to the message.
-
setHeight
public void setHeight(double height) Description copied from interface:IEntitySets the height of the entity. -
setLocation
public void setLocation(double x, double y) Description copied from interface:IEntitySets the location of the entity.- Specified by:
setLocationin interfaceIEntity- Parameters:
x- The X coordinate of the new location.y- The Y coordinate of the new location.
-
setLocation
Sets the map location.- Specified by:
setLocationin interfaceIEntity- Parameters:
location- the new map location
-
setMapId
public void setMapId(int mapId) Sets an id which should only be filled when an entity gets added due to map information. -
setName
Description copied from interface:IEntitySets the name of the entity. -
setRenderType
Description copied from interface:IEntitySets the render type of the entity.- Specified by:
setRenderTypein interfaceIEntity- Parameters:
renderType- The new render type of the entity.
-
setSize
public void setSize(double width, double height) Description copied from interface:IEntitySets the size of the entity. -
setWidth
public void setWidth(double width) Description copied from interface:IEntitySets the width of the entity. -
setX
public void setX(double x) Description copied from interface:IEntitySets the X coordinate of the entity. -
setY
public void setY(double y) Description copied from interface:IEntitySets the Y coordinate of the entity. -
getTags
Description copied from interface:IEntityGets the list of tags associated with the entity. -
hasTag
Description copied from interface:IEntityChecks if the entity has the specified tag. -
addTag
Description copied from interface:IEntityAdds a tag to the entity. -
removeTag
Description copied from interface:IEntityRemoves a tag from the entity. -
getTweenValues
Description copied from interface:TweenableGets one or many values from the target object associated to the given tween type. It is used by the Tween Engine to determine starting values.- Specified by:
getTweenValuesin interfaceTweenable- Parameters:
tweenType- The tween type of this interpolation, determining which values are modified.- Returns:
- The array of current tween values.
-
setTweenValues
Description copied from interface:TweenableThis method is called in a Tween's update() method to set the new interpolated values.- Specified by:
setTweenValuesin interfaceTweenable- Parameters:
tweenType- The tween type of this interpolation, determining which values are modified.newValues- The new values determined by the tween equation.
-
setAngle
public void setAngle(double angle) Description copied from interface:IEntitySets the angle (in degrees) in which the entity is directed. -
toString
-
getEnvironment
Description copied from interface:IEntityGets the environment the entity was loaded to or null if it is not loaded.- Specified by:
getEnvironmentin interfaceIEntity- Returns:
- The entity's environment.
-
loaded
Description copied from interface:IEntityThis method provides the possibility to implement behavior whenever this entity was added to the environment. -
removed
Description copied from interface:IEntityThis method provides the possibility to implement behavior whenever this entity was removed from the environment. -
isLoaded
public boolean isLoaded()Description copied from interface:IEntityIndicates whether this entity is loaded on the currently active environment. -
renderWithLayer
public boolean renderWithLayer()Description copied from interface:IEntityDetermines whether this entity is being rendered with the layer it's originating from. This ignores the specifiedRenderTypeand makes the entity dependent upon the visibility of its layer.This can only be used, of course, if the entity is related to a
MapObject.
This defaults tofalseif not explicitly set on theMapObject.- Specified by:
renderWithLayerin interfaceIEntity- Returns:
- True if the entity should be rendered with the layer of the corresponding map object; otherwise false.
- See Also:
-
setRenderWithLayer
public void setRenderWithLayer(boolean renderWithLayer) Description copied from interface:IEntitySets whether the entity should be rendered with its layer.- Specified by:
setRenderWithLayerin interfaceIEntity- Parameters:
renderWithLayer- True to render with the layer; otherwise false.
-
rendering
Description copied from interface:EntityRenderListenerThis method gets called after all rendering checks have successfully passed and right before the entity is about to be rendered.- Specified by:
renderingin interfaceEntityRenderListener- Parameters:
event- The event that contains the render data.
-
rendered
Description copied from interface:EntityRenderedListenerThis method gets called after an entity was rendered.- Specified by:
renderedin interfaceEntityRenderedListener- Parameters:
event- The event that contains the render data.
-
canRender
Description copied from interface:EntityRenderListenerThis method gets called before anEntityis about to be rendered. Returning false prevents the rendering of the specified entity.- Specified by:
canRenderin interfaceEntityRenderListener- Parameters:
entity- The entity to be rendered.- Returns:
- True if the entity should be rendered; otherwise false.
-
getControllers
-