Class Player
java.lang.Object
tech.underoaks.coldcase.state.tileContent.TileContent
tech.underoaks.coldcase.state.tileContent.Player
- All Implemented Interfaces:
Cloneable
The
TileContent representing the Player on the playing field.
This Content will be controlled by the PlayerController in most cases.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic com.badlogic.gdx.graphics.TextureThe texture that the player is currently using.Fields inherited from class tech.underoaks.coldcase.state.tileContent.TileContent
tileContent, visibilityState -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaction(InteractionChain chain, Interaction interaction) Performs the action associated with this TileContent when interacted with.voidrender(com.badlogic.gdx.graphics.g2d.Batch batch, float x, float y) Renders the object at the specified coordinates using theSpriteBatch.booleanupdate(InteractionChain chain, com.badlogic.gdx.math.Vector2 tilePosition, Interaction interaction, TileContent handler) Updates the state of this TileContent based on interactions.voidupdateMovement(com.badlogic.gdx.math.Vector2 tilePosition, Direction actionDirection) Notifies thePlayerControllerabout performed movements of the Playerstatic voidupdateTexture(Direction lookDirection) Updates the texture of an object based on the specified direction the object is facing.Methods inherited from class tech.underoaks.coldcase.state.tileContent.TileContent
clone, dispose, equals, getChildIndex, getNextContent, getTexture, getTileContentByIndex, getVisibilityState, handleAction, handleUpdate, isObjectPassable, isPlayerPassable, popContent, pushContent, setNextContent, setObjectPassable, setPlayerPassable, setTexture, setVisibilityState, topContent
-
Field Details
-
currentTexture
public static com.badlogic.gdx.graphics.Texture currentTextureThe texture that the player is currently using. This texture indicates the facing direction
-
-
Constructor Details
-
Player
public Player()Default Constructor
-
-
Method Details
-
action
public boolean action(InteractionChain chain, Interaction interaction) throws GameStateUpdateException Description copied from class:TileContentPerforms the action associated with this TileContent when interacted with.- Specified by:
actionin classTileContent- Parameters:
chain- InteractionChain managing the snapshot.interaction- The interaction to trigger.- Returns:
- True if the action has been taken care of; False otherwise
- Throws:
GameStateUpdateException- If a GameStateUpdate has failed
-
render
public void render(com.badlogic.gdx.graphics.g2d.Batch batch, float x, float y) Renders the object at the specified coordinates using theSpriteBatch. If a texture is currently set, it draws the object with the texture; otherwise, it invokes the superclass's rendering method.- Overrides:
renderin classTileContent- Parameters:
batch- TheSpriteBatchused to draw the texture.x- The x-coordinate where the texture should be drawn.y- The y-coordinate where the texture should be drawn. The y-coordinate is adjusted by adding 8 units for positioning purposes.
-
update
public boolean update(InteractionChain chain, com.badlogic.gdx.math.Vector2 tilePosition, Interaction interaction, TileContent handler) throws GameStateUpdateException Description copied from class:TileContentUpdates the state of this TileContent based on interactions.- Specified by:
updatein classTileContent- Parameters:
chain- InteractionChain managing the snapshot.tilePosition- The position of the currently selected tile.interaction- The interaction that is currently being handled.handler- The TileContent that has been handling the interaction so far.- Returns:
- True if an update has been performed; False otherwise
- Throws:
GameStateUpdateException- If a GameStateUpdate has failed
-
updateTexture
Updates the texture of an object based on the specified direction the object is facing.- Parameters:
lookDirection- The direction that the object is looking toward. Valid values areNORTH,SOUTH,EAST, andWEST. The method sets the texture according to this direction.
-
updateMovement
Notifies thePlayerControllerabout performed movements of the Player- Parameters:
tilePosition- The new positionactionDirection- The direction in which the player has moved
-