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 IMobileEntityTODO: Add idle event
Nested Class Summary
Nested classes/interfaces inherited from interface de.gurkenlabs.litiengine.entities.IMobileEntity
IMobileEntity.EntityMovedListenerField Summary
Constructor Summary
Method Summary
Modifier and Type Method Description protected IEntityAnimationController<?>createAnimationController()protected IMovementControllercreateMovementController()intgetAcceleration()Gets a value that defines how long it takes the entity to reach the full velocity (in ms).intgetDeceleration()Gets a value that defines how long it takes the entity to stop when slowing down from movements (in ms).DirectiongetFacingDirection()java.lang.StringgetSpritesheetName()Gets the current spritesheet name of this instance.floatgetTickVelocity()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.booleanisIdle()Checks if is idle.booleanisScaling()IMovementControllermovement()Gets the movement controller.voidonMoved(IMobileEntity.EntityMovedListener listener)Adds the specified entity moved listener to receive events when this entity was moved.voidremoveMovedListener(IMobileEntity.EntityMovedListener listener)Removes the specified entity moved listener.voidsetAcceleration(int acceleration)Sets the acceleration for this entity.voidsetDeceleration(int deceleration)Sets the deceleration for this entity.voidsetFacingDirection(Direction facingDirection)voidsetLocation(java.awt.geom.Point2D position)Sets the map location.voidsetScaling(boolean scaling)voidsetSpritesheetName(java.lang.String spritesheetName)voidsetTurnOnMove(boolean turn)Sets the turn on move parameter for this entity.voidsetTweenValues(TweenType tweenType, float[] newValues)This method is called in a Tween's update() method to set the new interpolated values.voidsetVelocity(float velocity)Sets the base value on the velocity attribute of this instance.java.lang.StringtoString()booleanturnOnMove()Gets the turn on move parameter for this entity.protected voidupdateAnimationController()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, wasHitMethods 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, setWidthMethods 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, setYMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, setCollisionTypeMethods 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 newCreatureentity.- 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:IMobileEntityAdds 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:
onMovedin interfaceIMobileEntity- Parameters:
listener- The listener to add.
removeMovedListener
Description copied from interface:IMobileEntityRemoves the specified entity moved listener.- Specified by:
removeMovedListenerin interfaceIMobileEntity- Parameters:
listener- The listener to remove.
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- Overrides:
getTweenValuesin 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:TweenableThis method is called in a Tween's update() method to set the new interpolated values.- Specified by:
setTweenValuesin interfaceTweenable- Overrides:
setTweenValuesin 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:IMobileEntityGets a value that defines how long it takes the entity to reach the full velocity (in ms).- Specified by:
getAccelerationin interfaceIMobileEntity- Returns:
- the acceleration value
getDeceleration
public int getDeceleration()Description copied from interface:IMobileEntityGets a value that defines how long it takes the entity to stop when slowing down from movements (in ms).- Specified by:
getDecelerationin interfaceIMobileEntity- Returns:
- the deceleration value
getFacingDirection
movement
Description copied from interface:IMobileEntityGets the movement controller.- Specified by:
movementin 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 theCreatureAnimationControllerto determine the animation that it should play.- Returns:
- The current spritesheet name of this instance.
getTickVelocity
public float getTickVelocity()Description copied from interface:IMobileEntityGets the entity's velocity in PIXELS per tick.- Specified by:
getTickVelocityin interfaceIMobileEntity- Returns:
- The velocity in pixel per tick.
getVelocity
Description copied from interface:IMobileEntityGets the entity's velocity in PIXELS per Second.- Specified by:
getVelocityin 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:IMobileEntitySets 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:
setAccelerationin interfaceIMobileEntity- Parameters:
acceleration- the new acceleration
setDeceleration
public void setDeceleration(int deceleration)Description copied from interface:IMobileEntitySets 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:
setDecelerationin interfaceIMobileEntity- Parameters:
deceleration- the new deceleration
setFacingDirection
setLocation
public void setLocation(java.awt.geom.Point2D position)Description copied from class:EntitySets the map location.- Specified by:
setLocationin interfaceIEntity- Overrides:
setLocationin classCollisionEntity- Parameters:
position- the new map location
setTurnOnMove
public void setTurnOnMove(boolean turn)Description copied from interface:IMobileEntitySets 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:
setTurnOnMovein 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:IMobileEntitySets the base value on the velocity attribute of this instance.- Specified by:
setVelocityin interfaceIMobileEntity- Parameters:
velocity- The velocity to be set.- See Also:
IMobileEntity.getVelocity()
turnOnMove
public boolean turnOnMove()Description copied from interface:IMobileEntityGets 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:
turnOnMovein 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
