Class Character
- java.lang.Object
-
- com.badlogic.gdx.graphics.g2d.TextureRegion
-
- com.badlogic.gdx.graphics.g2d.Sprite
-
- bytemusketeers.heslingtonhustle.scene.Character
-
-
Field Summary
Fields Modifier and Type Field Description private com.badlogic.gdx.physics.box2d.Body
activeBody
TheBody
reference belonging to the currentArea
contextprivate java.util.Map<Area.Name,com.badlogic.gdx.physics.box2d.Body>
bodies
The relationship between theArea
and theBody
, with standard area keysprivate static float
HEIGHT
The height of aCharacter
, in in-game metresprivate static float
MOVEMENT_VELOCITY
The standard moving velocity, across both axes, of a mobileCharacter
.private static float
MOVEMENT_VELOCITY_CORRECTION
The velocity correction factor by which movement should be slowed if theCharacter
is traversing both axes simultaneously; i.e.private com.badlogic.gdx.graphics.Texture
playerTexture
The visual representation of theCharacter
private static java.lang.String
TEXTURE_PATH
The file path of theCharacter
private com.badlogic.gdx.math.Vector2
velocity
The transient velocity of theCharacter
private static float
WIDTH
The width of aCharacter
, in in-game metres
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
dispose()
Releases all resources used by theCharacter
com.badlogic.gdx.math.Vector2
getPosition()
Retrieves theCharacter
positionvoid
move()
Updates the position of theCharacter
given its transient velocityvoid
moveDown()
Moves theCharacter
downwards on the Y-axisvoid
moveLeft()
Moves theCharacter
leftwards on the X-axisvoid
moveRight()
Moves theCharacter
rightwards on the X-axisvoid
moveUp()
Moves theCharacter
upwards on the Y-axisvoid
render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)
Registers the currentCharacter
onto the given game instanceSpriteBatch
void
setPosition(com.badlogic.gdx.math.Vector2 position)
Sets the position of theCharacter
void
switchCharacterContext(Area.Name areaName)
-
Methods inherited from class com.badlogic.gdx.graphics.g2d.Sprite
draw, draw, flip, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getWidth, getX, getY, rotate, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setFlip, setOrigin, setOriginBasedPosition, setOriginCenter, setPackedColor, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
-
Methods inherited from class com.badlogic.gdx.graphics.g2d.TextureRegion
getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
-
-
-
-
Field Detail
-
WIDTH
private static final float WIDTH
The width of aCharacter
, in in-game metres- See Also:
- Constant Field Values
-
HEIGHT
private static final float HEIGHT
The height of aCharacter
, in in-game metres- See Also:
- Constant Field Values
-
MOVEMENT_VELOCITY
private static final float MOVEMENT_VELOCITY
The standard moving velocity, across both axes, of a mobileCharacter
. Specified in in-game metres per second of continuous input.- See Also:
moveUp()
,moveDown()
,moveLeft()
,moveRight()
,move()
, Constant Field Values
-
MOVEMENT_VELOCITY_CORRECTION
private static final float MOVEMENT_VELOCITY_CORRECTION
The velocity correction factor by which movement should be slowed if theCharacter
is traversing both axes simultaneously; i.e. moving diagonally.- See Also:
MOVEMENT_VELOCITY
,move()
-
TEXTURE_PATH
private static final java.lang.String TEXTURE_PATH
The file path of theCharacter
- See Also:
playerTexture
, Constant Field Values
-
playerTexture
private final com.badlogic.gdx.graphics.Texture playerTexture
The visual representation of theCharacter
- See Also:
TEXTURE_PATH
,render(SpriteBatch)
-
velocity
private final com.badlogic.gdx.math.Vector2 velocity
The transient velocity of theCharacter
- See Also:
MOVEMENT_VELOCITY
,move()
-
bodies
private final java.util.Map<Area.Name,com.badlogic.gdx.physics.box2d.Body> bodies
The relationship between theArea
and theBody
, with standard area keys- See Also:
activeBody
,switchCharacterContext(Area.Name)
-
activeBody
private com.badlogic.gdx.physics.box2d.Body activeBody
TheBody
reference belonging to the currentArea
context- See Also:
bodies
,switchCharacterContext(Area.Name)
-
-
Method Detail
-
moveUp
public void moveUp()
Moves theCharacter
upwards on the Y-axis
-
moveDown
public void moveDown()
Moves theCharacter
downwards on the Y-axis
-
moveLeft
public void moveLeft()
Moves theCharacter
leftwards on the X-axis
-
moveRight
public void moveRight()
Moves theCharacter
rightwards on the X-axis
-
move
public void move()
Updates the position of theCharacter
given its transient velocity- See Also:
moveUp()
,moveDown()
,moveLeft()
,moveRight()
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()
Retrieves theCharacter
position- Returns:
- The position
-
setPosition
public void setPosition(com.badlogic.gdx.math.Vector2 position)
Sets the position of theCharacter
- Parameters:
position
- The new position
-
switchCharacterContext
public void switchCharacterContext(Area.Name areaName)
-
dispose
public void dispose()
Releases all resources used by theCharacter
- Specified by:
dispose
in interfacecom.badlogic.gdx.utils.Disposable
-
-