Class Creature
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.CollisionEntity
de.gurkenlabs.litiengine.entities.CombatEntity
de.gurkenlabs.litiengine.entities.Creature
- All Implemented Interfaces:
EntityRenderedListener
,EntityRenderListener
,ICollisionEntity
,ICombatEntity
,IEntity
,IMobileEntity
,Tweenable
,java.util.EventListener
public class Creature
extends CombatEntity
implements IMobileEntity
TODO: Add idle event
Nested Class Summary
Nested classes/interfaces inherited from interface de.gurkenlabs.litiengine.entities.IMobileEntity
IMobileEntity.EntityMovedListener
Field Summary
Constructor Summary
Method Summary
Modifier and Type Method Description protected IEntityAnimationController<?>
createAnimationController()
protected IMovementController
createMovementController()
int
getAcceleration()
Gets a value that defines how long it takes the entity to reach the full velocity (in ms).int
getDeceleration()
Gets a value that defines how long it takes the entity to stop when slowing down from movements (in ms).Direction
getFacingDirection()
java.lang.String
getSpritesheetName()
Gets the current spritesheet name of this instance.float
getTickVelocity()
Gets the entity's velocity in PIXELS per tick.float[]
getTweenValues(TweenType tweenType)
Gets one or many values from the target object associated to the given tween type.Attribute<java.lang.Float>
getVelocity()
Gets the entity's velocity in PIXELS per Second.boolean
isIdle()
Checks if is idle.boolean
isScaling()
IMovementController
movement()
Gets the movement controller.void
onMoved(IMobileEntity.EntityMovedListener listener)
Adds the specified entity moved listener to receive events when this entity was moved.void
removeMovedListener(IMobileEntity.EntityMovedListener listener)
Removes the specified entity moved listener.void
setAcceleration(int acceleration)
Sets the acceleration for this entity.void
setDeceleration(int deceleration)
Sets the deceleration for this entity.void
setFacingDirection(Direction facingDirection)
void
setLocation(java.awt.geom.Point2D position)
Sets the map location.void
setScaling(boolean scaling)
void
setSpritesheetName(java.lang.String spritesheetName)
void
setTurnOnMove(boolean turn)
Sets the turn on move parameter for this entity.void
setTweenValues(TweenType tweenType, float[] newValues)
This method is called in a Tween's update() method to set the new interpolated values.void
setVelocity(float velocity)
Sets the base value on the velocity attribute of this instance.java.lang.String
toString()
boolean
turnOnMove()
Gets the turn on move parameter for this entity.protected void
updateAnimationController()
Methods inherited from class de.gurkenlabs.litiengine.entities.CombatEntity
addCombatEntityListener, die, getAppliedEffects, getHitBox, getHitPoints, getTarget, getTeam, hit, hit, isDead, isFriendly, isIndestructible, isNeutral, onDeath, onHit, onResurrect, removeCombatEntityListener, removeListener, removeListener, removeListener, resurrect, setIndestructible, setTarget, setTeam, wasHit
Methods inherited from class de.gurkenlabs.litiengine.entities.CollisionEntity
canCollideWith, fireCollisionEvent, getCollisionBox, getCollisionBox, getCollisionBox, getCollisionBoxAlign, getCollisionBoxCenter, getCollisionBoxHeight, getCollisionBoxValign, getCollisionBoxWidth, getCollisionType, hasCollision, onCollision, refreshCollisionBox, removeCollisionListener, setCollision, setCollisionBoxAlign, setCollisionBoxHeight, setCollisionBoxValign, setCollisionBoxWidth, setCollisionType, setHeight, setSize, setWidth
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
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.ICollisionEntity
canCollideWith, fireCollisionEvent, getCollisionBox, getCollisionBox, getCollisionBoxAlign, getCollisionBoxCenter, getCollisionBoxHeight, getCollisionBoxValign, getCollisionBoxWidth, getCollisionType, hasCollision, onCollision, removeCollisionListener, setCollision, setCollisionBoxAlign, setCollisionBoxHeight, setCollisionBoxValign, setCollisionBoxWidth, setCollisionType
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, setHeight, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setSize, setVisible, setWidth, setX, setY
Constructor Details
Creature
public Creature()Creature
public Creature(java.lang.String spritesheetName)Instantiates a newCreature
entity.- Parameters:
spritesheetName
- The spritesheet name that identifies the sprites bound to this instance.- See Also:
CreatureAnimationController.getSpriteName(Creature, de.gurkenlabs.litiengine.graphics.CreatureAnimationState)
Method Details
onMoved
Description copied from interface:IMobileEntity
Adds the specified entity moved listener to receive events when this entity was moved.In comparison to the
EntityTransformListener.locationChanged(IEntity)
event, this provides some additional information about the movement (e.g. distance) and is only fired if the entity instance is currently loaded.- Specified by:
onMoved
in interfaceIMobileEntity
- Parameters:
listener
- The listener to add.
removeMovedListener
Description copied from interface:IMobileEntity
Removes the specified entity moved listener.- Specified by:
removeMovedListener
in interfaceIMobileEntity
- Parameters:
listener
- The listener to remove.
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 classCombatEntity
- 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 classCombatEntity
- Parameters:
tweenType
- The tween type of this interpolation, determining which values are modified.newValues
- The new values determined by the tween equation.
getAcceleration
public int getAcceleration()Description copied from interface:IMobileEntity
Gets a value that defines how long it takes the entity to reach the full velocity (in ms).- Specified by:
getAcceleration
in interfaceIMobileEntity
- Returns:
- the acceleration value
getDeceleration
public int getDeceleration()Description copied from interface:IMobileEntity
Gets a value that defines how long it takes the entity to stop when slowing down from movements (in ms).- Specified by:
getDeceleration
in interfaceIMobileEntity
- Returns:
- the deceleration value
getFacingDirection
movement
Description copied from interface:IMobileEntity
Gets the movement controller.- Specified by:
movement
in interfaceIMobileEntity
- Returns:
- the movement controller
getSpritesheetName
public java.lang.String getSpritesheetName()Gets the current spritesheet name of this instance. Overwriting this allows for a more sophisticated logic that determines the sprite to be used; e.g. This method could append certain properties of the creature (state, weapon, ...) to the default string.
The value of this method will be used e.g. by theCreatureAnimationController
to determine the animation that it should play.- Returns:
- The current spritesheet name of this instance.
getTickVelocity
public float getTickVelocity()Description copied from interface:IMobileEntity
Gets the entity's velocity in PIXELS per tick.- Specified by:
getTickVelocity
in interfaceIMobileEntity
- Returns:
- The velocity in pixel per tick.
getVelocity
Description copied from interface:IMobileEntity
Gets the entity's velocity in PIXELS per Second.- Specified by:
getVelocity
in interfaceIMobileEntity
- Returns:
- the velocity in pixel per second.
isScaling
public boolean isScaling()isIdle
public boolean isIdle()Checks if is idle.- Returns:
- true, if is idle
setAcceleration
public void setAcceleration(int acceleration)Description copied from interface:IMobileEntity
Sets the acceleration for this entity. Acceleration is a value that defines how long it takes the entity to reach the full velocity when starting to move (in ms). *- Specified by:
setAcceleration
in interfaceIMobileEntity
- Parameters:
acceleration
- the new acceleration
setDeceleration
public void setDeceleration(int deceleration)Description copied from interface:IMobileEntity
Sets the deceleration for this entity. deceleration is a value that defines how long it takes the entity to stop when slowing down from movements (in ms).- Specified by:
setDeceleration
in interfaceIMobileEntity
- Parameters:
deceleration
- the new deceleration
setFacingDirection
setLocation
public void setLocation(java.awt.geom.Point2D position)Description copied from class:Entity
Sets the map location.- Specified by:
setLocation
in interfaceIEntity
- Overrides:
setLocation
in classCollisionEntity
- Parameters:
position
- the new map location
setTurnOnMove
public void setTurnOnMove(boolean turn)Description copied from interface:IMobileEntity
Sets the turn on move parameter for this entity. It specifies if the entity will change its angle to the direction of the move destination when moved.- Specified by:
setTurnOnMove
in interfaceIMobileEntity
- Parameters:
turn
- the new turn on move parameter.
setSpritesheetName
public void setSpritesheetName(java.lang.String spritesheetName)setScaling
public void setScaling(boolean scaling)setVelocity
public void setVelocity(float velocity)Description copied from interface:IMobileEntity
Sets the base value on the velocity attribute of this instance.- Specified by:
setVelocity
in interfaceIMobileEntity
- Parameters:
velocity
- The velocity to be set.- See Also:
IMobileEntity.getVelocity()
turnOnMove
public boolean turnOnMove()Description copied from interface:IMobileEntity
Gets the turn on move parameter for this entity. It specifies if the entity will change its angle to the direction of the move destination when moved.- Specified by:
turnOnMove
in interfaceIMobileEntity
- Returns:
- true, if the entity will change its angle to the direction of the move destination when being moved
toString
public java.lang.String toString()updateAnimationController
protected void updateAnimationController()createAnimationController
createMovementController