Class CollisionEntity
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.CollisionEntity
- All Implemented Interfaces:
EntityRenderedListener
,EntityRenderListener
,ICollisionEntity
,IEntity
,Tweenable
,java.util.EventListener
- Direct Known Subclasses:
CollisionBox
,CombatEntity
,Trigger
public abstract class CollisionEntity
extends Entity
implements ICollisionEntity
Field Summary
Constructor Summary
Constructors Modifier Constructor Description protected
CollisionEntity()
Method Summary
Modifier and Type Method Description boolean
canCollideWith(ICollisionEntity otherEntity)
void
fireCollisionEvent(CollisionEvent event)
java.awt.geom.Rectangle2D
getCollisionBox()
Gets the collision box.java.awt.geom.Rectangle2D
getCollisionBox(java.awt.geom.Point2D location)
Gets the collision box.static java.awt.geom.Rectangle2D
getCollisionBox(java.awt.geom.Point2D location, double entityWidth, double entityHeight, double collisionBoxWidth, double collisionBoxHeight, Align align, Valign valign)
Align
getCollisionBoxAlign()
java.awt.geom.Point2D
getCollisionBoxCenter()
Gets the centerPoint2D
of the entities collision box.double
getCollisionBoxHeight()
Valign
getCollisionBoxValign()
double
getCollisionBoxWidth()
Collision
getCollisionType()
float[]
getTweenValues(TweenType tweenType)
Gets one or many values from the target object associated to the given tween type.boolean
hasCollision()
Checks for collision.void
onCollision(CollisionListener listener)
protected void
refreshCollisionBox()
void
removeCollisionListener(CollisionListener listener)
void
setCollision(boolean collision)
Sets the collision.void
setCollisionBoxAlign(Align align)
void
setCollisionBoxHeight(double collisionBoxHeight)
void
setCollisionBoxValign(Valign valign)
void
setCollisionBoxWidth(double collisionBoxWidth)
void
setCollisionType(Collision type)
void
setHeight(double height)
void
setLocation(java.awt.geom.Point2D location)
Sets the map location.void
setSize(double width, double height)
void
setTweenValues(TweenType tweenType, float[] newValues)
This method is called in a Tween's update() method to set the new interpolated values.void
setWidth(double width)
Methods inherited from class de.gurkenlabs.litiengine.entities.Entity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, canRender, detachControllers, getAngle, getBoundingBox, getCenter, getController, getControllers, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, rendered, rendering, renderWithLayer, sendMessage, setAngle, setController, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setVisible, setX, setY, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface de.gurkenlabs.litiengine.entities.IEntity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, detachControllers, getAngle, getBoundingBox, getCenter, getController, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, renderWithLayer, sendMessage, setAngle, setController, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setVisible, setX, setY
Constructor Details
CollisionEntity
protected CollisionEntity()
Method Details
getCollisionBox
canCollideWith
- Specified by:
canCollideWith
in interfaceICollisionEntity
getCollisionBoxAlign
- Specified by:
getCollisionBoxAlign
in interfaceICollisionEntity
getCollisionBox
public java.awt.geom.Rectangle2D getCollisionBox()Gets the collision box.- Specified by:
getCollisionBox
in interfaceICollisionEntity
- Returns:
- the collision box
getCollisionBox
public java.awt.geom.Rectangle2D getCollisionBox(java.awt.geom.Point2D location)Gets the collision box.- Specified by:
getCollisionBox
in interfaceICollisionEntity
- Parameters:
location
- the location- Returns:
- the collision box
getCollisionBoxHeight
public double getCollisionBoxHeight()- Specified by:
getCollisionBoxHeight
in interfaceICollisionEntity
getCollisionBoxWidth
public double getCollisionBoxWidth()- Specified by:
getCollisionBoxWidth
in interfaceICollisionEntity
getCollisionBoxCenter
public java.awt.geom.Point2D getCollisionBoxCenter()Description copied from interface:ICollisionEntity
Gets the centerPoint2D
of the entities collision box.- Specified by:
getCollisionBoxCenter
in interfaceICollisionEntity
- Returns:
- The center
Point2D
of the entities collision box
getCollisionBoxValign
- Specified by:
getCollisionBoxValign
in interfaceICollisionEntity
getCollisionType
- Specified by:
getCollisionType
in interfaceICollisionEntity
getTweenValues
Description copied from interface:Tweenable
Gets 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:
getTweenValues
in interfaceTweenable
- Overrides:
getTweenValues
in classEntity
- 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:Tweenable
This method is called in a Tween's update() method to set the new interpolated values.- Specified by:
setTweenValues
in interfaceTweenable
- Overrides:
setTweenValues
in classEntity
- Parameters:
tweenType
- The tween type of this interpolation, determining which values are modified.newValues
- The new values determined by the tween equation.
hasCollision
public boolean hasCollision()Checks for collision.- Specified by:
hasCollision
in interfaceICollisionEntity
- Returns:
- true, if successful
setCollision
public void setCollision(boolean collision)Sets the collision.- Specified by:
setCollision
in interfaceICollisionEntity
- Parameters:
collision
- the new collision
setCollisionBoxAlign
- Specified by:
setCollisionBoxAlign
in interfaceICollisionEntity
setCollisionBoxHeight
public void setCollisionBoxHeight(double collisionBoxHeight)- Specified by:
setCollisionBoxHeight
in interfaceICollisionEntity
setCollisionBoxValign
- Specified by:
setCollisionBoxValign
in interfaceICollisionEntity
setCollisionBoxWidth
public void setCollisionBoxWidth(double collisionBoxWidth)- Specified by:
setCollisionBoxWidth
in interfaceICollisionEntity
setLocation
public void setLocation(java.awt.geom.Point2D location)Description copied from class:Entity
Sets the map location.- Specified by:
setLocation
in interfaceIEntity
- Overrides:
setLocation
in classEntity
- Parameters:
location
- the new map location
setSize
public void setSize(double width, double height)setHeight
public void setHeight(double height)setWidth
public void setWidth(double width)setCollisionType
- Specified by:
setCollisionType
in interfaceICollisionEntity
onCollision
- Specified by:
onCollision
in interfaceICollisionEntity
removeCollisionListener
- Specified by:
removeCollisionListener
in interfaceICollisionEntity
fireCollisionEvent
- Specified by:
fireCollisionEvent
in interfaceICollisionEntity
refreshCollisionBox
protected void refreshCollisionBox()