public class MovableEntity extends AbstractEntity implements java.lang.Cloneable
Controllable
or modify the movemnet via setMovement(com.badlogic.gdx.math.Vector3)
.GAME_DIAGLENGTH, GAME_DIAGLENGTH2, GAME_EDGELENGTH, GAME_EDGELENGTH2, OBJECTTYPESNUM, VALUESNUM, VIEW_DEPTH, VIEW_DEPTH2, VIEW_DEPTH4, VIEW_HEIGHT, VIEW_HEIGHT2, VIEW_HEIGHT4, VIEW_WIDTH, VIEW_WIDTH2, VIEW_WIDTH4, ZAXISSHORTENING
Constructor and Description |
---|
MovableEntity(byte id)
Simple MovableEntity with no animation.
|
MovableEntity(byte id,
int spritesPerDir)
Constructor of MovableEntity.
|
MovableEntity(MovableEntity entity)
copy constructor
|
Modifier and Type | Method and Description |
---|---|
void |
addMovement(com.badlogic.gdx.math.Vector2 movement)
Adds speed and direction.
|
void |
addMovement(com.badlogic.gdx.math.Vector3 movement)
Adds speed and direction.
|
void |
addToHor(float speed)
Adds speed to horizontal moving directio.
|
MovableEntity |
clone() |
void |
damage(byte value)
called when gets damage
|
com.badlogic.gdx.math.Vector3 |
getAiming()
Defines the direction of the gun - if no gun available - the direction of the head.
|
float |
getFriction()
The factor which slows donw movement.
|
java.lang.String |
getLandingSound() |
com.badlogic.gdx.math.Vector3 |
getMovement()
Get the movement vector as the product of diretion and speed.
|
com.badlogic.gdx.math.Vector2 |
getMovementHor()
Get the movement vector.
|
com.badlogic.gdx.math.Vector2 |
getOrientation()
Direction of movement.
|
float |
getSpeed()
get the speed of the object in m/s.
|
float |
getSpeedHor()
get the gorizontalspeed of the object in m/s.
|
void |
heal(byte value)
heals the entity
|
boolean |
isColiding() |
boolean |
isFloating()
Is the object be affected by gravity?
|
boolean |
isIndestructible() |
boolean |
isInLiquid()
Is the character standing in a liquid?
|
boolean |
isOnGround()
Checks if standing on blocks.
|
void |
jump()
This method should define what happens when the object jumps.
|
void |
jump(float velo,
boolean playSound)
Jump with a specific speed
|
void |
onCollide()
called when in contact with floor or wall.
|
void |
onLand()
called when objects lands
|
void |
render(GameView view,
int xPos,
int yPos)
Renders at a custom position.
|
void |
setColiding(boolean coliding) |
void |
setDamageSounds(java.lang.String[] sound) |
void |
setFallingSound(java.lang.String fallingSound)
Sets the sound to be played when falling.
|
void |
setFloating(boolean floating)
Should the object be affected by gravity?
|
void |
setFriction(float friction)
Automatically slows speed down.
|
void |
setHorMovement(com.badlogic.gdx.math.Vector2 movement)
Set the horizontal movement and keeps z
|
void |
setIndestructible(boolean indestructible) |
void |
setJumpingSound(java.lang.String jumpingSound)
Set the value of jumpingSound
|
void |
setLandingSound(java.lang.String landingSound)
Set sound played when the character lands on the feet.
|
void |
setMovement(com.badlogic.gdx.math.Vector2 movement)
Sets speed and direction combined in one vector.
|
void |
setMovement(com.badlogic.gdx.math.Vector3 movement)
Sets speed and direction.
|
void |
setOrientation(com.badlogic.gdx.math.Vector2 orientation)
Turns an object in a different direction.
|
void |
setRunningSound(java.lang.String runningSound)
Set the sound to be played when running.
|
void |
setSpeedHorizontal(float speed)
Set the speed and only take x and y into account.
|
void |
setSpeedIncludingZ(float speed)
Set the speed.
|
void |
setStepSound1Grass(java.lang.String sound) |
void |
setWalkingAnimationCycling(boolean cycle)
Bounce back and forth (1,2,3,2,1,2 etc.) or cycle (1,2,3,1,2,3 etc.)
|
void |
setWalkingSpeedIndependentAnimation(float walkOnTheSpot)
Enable this to have a walking cycle even if not moving
|
void |
setWalkingStepMode(boolean stepmode)
Set step mode or disable step mode. if no step mode plays animation back and forth.
|
static void |
setWaterSound(java.lang.String waterSound)
Set the value of waterSound
|
void |
step()
performs a step.
|
void |
update(float dt)
Updates the character.
|
disableShadow, dispose, disposeFromMap, enableShadow, getAnimation, getCategory, getDimensionZ, getName, getPosition, getRegisteredEntities, isGettingSaved, isInMemoryArea, isObstacle, isTransparent, registerEngineEntities, registerEntity, setAnimation, setDimensionZ, setHeight, setName, setObstacle, setPosition, setSaveToDisk, shouldBeDisposed, shouldBeDisposedFromMap, spawn, spawned
getAtlasRegion, getColor, getCoreData, getDepth, getDrawCalls, getHealth, getId, getLightlevel, getPixmap, getRotation, getScaling, getSprite, getSpriteId, getSprites, getSpritesheet, getSpritesheetPath, getTextureDiffuse, getTextureNormal, getValue, increaseDrawCalls, isHidden, loadSheet, render, render, render, resetDrawCalls, setColor, setCustomSpritesheet, setGraphicsId, setHealth, setHidden, setLightlevel, setRotation, setScaling, setValue, staticDispose
public MovableEntity(byte id)
id
- public MovableEntity(byte id, int spritesPerDir)
id
- spritesPerDir
- The number of animation sprites per walking direction. if 0 then it only uses the value 0public MovableEntity(MovableEntity entity)
entity
- public static void setWaterSound(java.lang.String waterSound)
waterSound
- new value of waterSoundpublic void setWalkingAnimationCycling(boolean cycle)
cycle
- true if cycle, false if bouncepublic void setWalkingSpeedIndependentAnimation(float walkOnTheSpot)
walkOnTheSpot
- the speed of the animation: ~1. To disable pass 0.public void setWalkingStepMode(boolean stepmode)
stepmode
- stepmode = true,public void jump()
jump(float, boolean)
public void jump(float velo, boolean playSound)
velo
- the velocity in m/splaySound
- public com.badlogic.gdx.math.Vector3 getAiming()
public void update(float dt)
update
in class AbstractEntity
dt
- time since last update in mspublic void render(GameView view, int xPos, int yPos)
AbstractGameObject
render
in class AbstractGameObject
xPos
- rendering position, center of sprite in projection (?) spaceyPos
- rendering position, center of sprite in projection (?) spacepublic void setFallingSound(java.lang.String fallingSound)
fallingSound
- public void setRunningSound(java.lang.String runningSound)
runningSound
- public void setJumpingSound(java.lang.String jumpingSound)
jumpingSound
- new value of jumpingSoundpublic void setLandingSound(java.lang.String landingSound)
landingSound
- new value of landingSoundpublic java.lang.String getLandingSound()
public void setDamageSounds(java.lang.String[] sound)
sound
- public void setStepSound1Grass(java.lang.String sound)
sound
- public com.badlogic.gdx.math.Vector2 getOrientation()
public com.badlogic.gdx.math.Vector3 getMovement()
public com.badlogic.gdx.math.Vector2 getMovementHor()
public void setMovement(com.badlogic.gdx.math.Vector2 movement)
movement
- containing direction and speed (length).public void setMovement(com.badlogic.gdx.math.Vector3 movement)
movement
- containing direction and speed in m/s without the unit so no "5*AbstractGameObject.GAME_EDGELENGTH
" for 5 m/s but just "5".public void addMovement(com.badlogic.gdx.math.Vector2 movement)
movement
- containing direction and speed in m/s without the unit so no "5*AbstractGameObject.GAME_EDGELENGTH
" for 5 m/s but just "5".public void addMovement(com.badlogic.gdx.math.Vector3 movement)
movement
- containing direction and speed in m/s without the unit so no "5*AbstractGameObject.GAME_EDGELENGTH
" for 5 m/s but just "5".public void addToHor(float speed)
speed
- speed in m/s without the unit so no "5*AbstractGameObject.GAME_EDGELENGTH
" for 5 m/s but just "5".public void setHorMovement(com.badlogic.gdx.math.Vector2 movement)
movement
- public void setSpeedHorizontal(float speed)
speed
- public void setSpeedIncludingZ(float speed)
speed
- public float getSpeedHor()
public float getSpeed()
public void setOrientation(com.badlogic.gdx.math.Vector2 orientation)
orientation
- the new orientationpublic boolean isColiding()
public void setColiding(boolean coliding)
coliding
- public boolean isFloating()
public void setFloating(boolean floating)
floating
- public boolean isOnGround()
isOnGround
in class AbstractEntity
public boolean isInLiquid()
public void damage(byte value)
value
- public void heal(byte value)
value
- public boolean isIndestructible()
public void setIndestructible(boolean indestructible)
indestructible
- public float getFriction()
public void setFriction(float friction)
friction
- The higher the value, the less "slide". If =0 friciton is disabled. Value should be ~0.01fpublic void onCollide()
public void onLand()
public MovableEntity clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public void step()