Class CollisionEntity
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.CollisionEntity
- All Implemented Interfaces:
EntityRenderedListener,EntityRenderListener,ICollisionEntity,IEntity,Tweenable,EventListener
- Direct Known Subclasses:
CollisionBox,CombatEntity,Trigger
-
Field Summary
Fields inherited from class de.gurkenlabs.litiengine.entities.Entity
ANY_MESSAGE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanCollideWith(ICollisionEntity otherEntity) Determines if this entity can collide with another specifiedICollisionEntity.voidfireCollisionEvent(CollisionEvent event) Triggers a collision event for this entity.Gets the collision box.getCollisionBox(Point2D location) Gets the collision box.static Rectangle2DgetCollisionBox(Point2D location, double entityWidth, double entityHeight, double collisionBoxWidth, double collisionBoxHeight, Align align, Valign valign) Retrieves the horizontal alignment of the entity's collision box.Gets the centerPoint2Dof the entities collision box.doubleRetrieves the height of the entity's collision box.Retrieves the vertical alignment of the entity's collision box.doubleRetrieves the width of the entity's collision box.Retrieves the collision type of this entity.float[]getTweenValues(TweenType tweenType) Gets one or many values from the target object associated to the given tween type.booleanChecks for collision.voidonCollision(CollisionListener listener) Registers aCollisionListenerto this entity.protected voidvoidremoveCollisionListener(CollisionListener listener) Removes a previously registeredCollisionListenerfrom this entity.voidsetCollision(boolean collision) Sets the collision.voidsetCollisionBoxAlign(Align align) Sets the horizontal alignment of the entity's collision box.voidsetCollisionBoxHeight(double collisionBoxHeight) Sets the height of the entity's collision box.voidsetCollisionBoxValign(Valign valign) Sets the vertical alignment of the entity's collision box.voidsetCollisionBoxWidth(double collisionBoxWidth) Sets the width of the entity's collision box.voidsetCollisionType(Collision type) Sets the collision type of this entity.voidsetHeight(double height) Sets the height of the entity.voidsetLocation(Point2D location) Sets the map location.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.voidsetWidth(double width) Sets the width of the entity.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, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
public static Rectangle2D getCollisionBox(Point2D location, double entityWidth, double entityHeight, double collisionBoxWidth, double collisionBoxHeight, Align align, Valign valign) -
canCollideWith
Description copied from interface:ICollisionEntityDetermines if this entity can collide with another specifiedICollisionEntity. This method should be implemented to define custom collision logic between entities.- Specified by:
canCollideWithin interfaceICollisionEntity- Parameters:
otherEntity- The otherICollisionEntityto check collision capability with.- Returns:
trueif this entity can collide with the specified entity;falseotherwise.
-
getCollisionBoxAlign
Description copied from interface:ICollisionEntityRetrieves the horizontal alignment of the entity's collision box. This alignment determines the horizontal positioning of the collision box relative to the entity's location.- Specified by:
getCollisionBoxAlignin interfaceICollisionEntity- Returns:
- The
Alignrepresenting the horizontal alignment of the collision box.
-
getCollisionBox
Gets the collision box.- Specified by:
getCollisionBoxin interfaceICollisionEntity- Returns:
- the collision box
-
getCollisionBox
Gets the collision box.- Specified by:
getCollisionBoxin interfaceICollisionEntity- Parameters:
location- the location- Returns:
- the collision box
-
getCollisionBoxHeight
public double getCollisionBoxHeight()Description copied from interface:ICollisionEntityRetrieves the height of the entity's collision box. This height is used in collision detection to determine the vertical bounds of the entity.- Specified by:
getCollisionBoxHeightin interfaceICollisionEntity- Returns:
- The height of the collision box in pixels.
-
getCollisionBoxWidth
public double getCollisionBoxWidth()Description copied from interface:ICollisionEntityRetrieves the width of the entity's collision box. This width is used in collision detection to determine the horizontal bounds of the entity.- Specified by:
getCollisionBoxWidthin interfaceICollisionEntity- Returns:
- The width of the collision box in pixels.
-
getCollisionBoxCenter
Description copied from interface:ICollisionEntityGets the centerPoint2Dof the entities collision box.- Specified by:
getCollisionBoxCenterin interfaceICollisionEntity- Returns:
- The center
Point2Dof the entities collision box
-
getCollisionBoxValign
Description copied from interface:ICollisionEntityRetrieves the vertical alignment of the entity's collision box. This alignment determines the vertical positioning of the collision box relative to the entity's location.- Specified by:
getCollisionBoxValignin interfaceICollisionEntity- Returns:
- The
Valignrepresenting the vertical alignment of the collision box.
-
getCollisionType
Description copied from interface:ICollisionEntityRetrieves the collision type of this entity. The collision type defines how this entity interacts with other entities in terms of physical collisions.- Specified by:
getCollisionTypein interfaceICollisionEntity- Returns:
- The
Collisiontype of this entity, indicating how it should be treated in collision detection and handling.
-
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 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:TweenableThis method is called in a Tween's update() method to set the new interpolated values.- Specified by:
setTweenValuesin interfaceTweenable- Overrides:
setTweenValuesin 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:
hasCollisionin interfaceICollisionEntity- Returns:
- true, if successful
-
setCollision
public void setCollision(boolean collision) Sets the collision.- Specified by:
setCollisionin interfaceICollisionEntity- Parameters:
collision- the new collision
-
setCollisionBoxAlign
Description copied from interface:ICollisionEntitySets the horizontal alignment of the entity's collision box.- Specified by:
setCollisionBoxAlignin interfaceICollisionEntity- Parameters:
align- TheAlignrepresenting the horizontal alignment of the collision box.
-
setCollisionBoxHeight
public void setCollisionBoxHeight(double collisionBoxHeight) Description copied from interface:ICollisionEntitySets the height of the entity's collision box.- Specified by:
setCollisionBoxHeightin interfaceICollisionEntity- Parameters:
collisionBoxHeight- The height of the collision box in pixels.
-
setCollisionBoxValign
Description copied from interface:ICollisionEntitySets the vertical alignment of the entity's collision box.- Specified by:
setCollisionBoxValignin interfaceICollisionEntity- Parameters:
valign- TheValignrepresenting the vertical alignment of the collision box.
-
setCollisionBoxWidth
public void setCollisionBoxWidth(double collisionBoxWidth) Description copied from interface:ICollisionEntitySets the width of the entity's collision box.- Specified by:
setCollisionBoxWidthin interfaceICollisionEntity- Parameters:
collisionBoxWidth- The width of the collision box in pixels.
-
setLocation
Description copied from class:EntitySets the map location.- Specified by:
setLocationin interfaceIEntity- Overrides:
setLocationin classEntity- Parameters:
location- the new map location
-
setSize
-
setHeight
-
setWidth
-
setCollisionType
Description copied from interface:ICollisionEntitySets the collision type of this entity.- Specified by:
setCollisionTypein interfaceICollisionEntity- Parameters:
type- TheCollisiontype indicating how this entity should be treated in collision detection and handling.
-
onCollision
Description copied from interface:ICollisionEntityRegisters aCollisionListenerto this entity. The listener will be notified whenever this entity collides with anotherICollisionEntity.- Specified by:
onCollisionin interfaceICollisionEntity- Parameters:
listener- TheCollisionListenerto be added to this entity. It should not benull.
-
removeCollisionListener
Description copied from interface:ICollisionEntityRemoves a previously registeredCollisionListenerfrom this entity. After removal, the listener will no longer receive collision events involving this entity.- Specified by:
removeCollisionListenerin interfaceICollisionEntity- Parameters:
listener- TheCollisionListenerto be removed. It should match a listener that was previously added withICollisionEntity.onCollision(CollisionListener).
-
fireCollisionEvent
Description copied from interface:ICollisionEntityTriggers a collision event for this entity. This method is used to manually fire a collision event, which can be useful for custom collision handling or for simulating collisions in specific scenarios.- Specified by:
fireCollisionEventin interfaceICollisionEntity- Parameters:
event- TheCollisionEventthat encapsulates the details of the collision. This includes information such as the entities involved in the collision and the collision's impact point.
-
refreshCollisionBox
protected void refreshCollisionBox()
-