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.BodyactiveBodyTheBodyreference belonging to the currentAreacontextprivate java.util.Map<Area.Name,com.badlogic.gdx.physics.box2d.Body>bodiesThe relationship between theAreaand theBody, with standard area keysprivate static floatHEIGHTThe height of aCharacter, in in-game metresprivate static floatMOVEMENT_VELOCITYThe standard moving velocity, across both axes, of a mobileCharacter.private static floatMOVEMENT_VELOCITY_CORRECTIONThe velocity correction factor by which movement should be slowed if theCharacteris traversing both axes simultaneously; i.e.private com.badlogic.gdx.graphics.TextureplayerTextureThe visual representation of theCharacterprivate static java.lang.StringTEXTURE_PATHThe file path of theCharacterprivate com.badlogic.gdx.math.Vector2velocityThe transient velocity of theCharacterprivate static floatWIDTHThe width of aCharacter, in in-game metres
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Releases all resources used by theCharactercom.badlogic.gdx.math.Vector2getPosition()Retrieves theCharacterpositionvoidmove()Updates the position of theCharactergiven its transient velocityvoidmoveDown()Moves theCharacterdownwards on the Y-axisvoidmoveLeft()Moves theCharacterleftwards on the X-axisvoidmoveRight()Moves theCharacterrightwards on the X-axisvoidmoveUp()Moves theCharacterupwards on the Y-axisvoidrender(com.badlogic.gdx.graphics.g2d.SpriteBatch batch)Registers the currentCharacteronto the given game instanceSpriteBatchvoidsetPosition(com.badlogic.gdx.math.Vector2 position)Sets the position of theCharactervoidswitchCharacterContext(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 theCharacteris 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 theAreaand theBody, with standard area keys- See Also:
activeBody,switchCharacterContext(Area.Name)
-
activeBody
private com.badlogic.gdx.physics.box2d.Body activeBody
TheBodyreference belonging to the currentAreacontext- See Also:
bodies,switchCharacterContext(Area.Name)
-
-
Method Detail
-
moveUp
public void moveUp()
Moves theCharacterupwards on the Y-axis
-
moveDown
public void moveDown()
Moves theCharacterdownwards on the Y-axis
-
moveLeft
public void moveLeft()
Moves theCharacterleftwards on the X-axis
-
moveRight
public void moveRight()
Moves theCharacterrightwards on the X-axis
-
move
public void move()
Updates the position of theCharactergiven its transient velocity- See Also:
moveUp(),moveDown(),moveLeft(),moveRight()
-
getPosition
public com.badlogic.gdx.math.Vector2 getPosition()
Retrieves theCharacterposition- 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:
disposein interfacecom.badlogic.gdx.utils.Disposable
-
-