public abstract class AbstractGameObject
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
GAME_DIAGLENGTH
The game size's aequivalent to SCREEN_DEPTH.
|
static int |
GAME_DIAGLENGTH2
Half of GAME_DIAGLENGTH
This is in the normal case aqueivalent to SCREEN_HEIGHT. |
static int |
GAME_EDGELENGTH
The real game world dimension in pixel (edge length). 1 game meter ^= 1 GAME_DIMENSION
Usually the use of SCREEN_DEPTH is enough because of the map format every coordinate center is straight.
|
static int |
OBJECTTYPESCOUNT
the max. amount of different object types
|
static int |
SCREEN_DEPTH
Screen SCREEN_DEPTH of a block/object sprite in pixels.
|
static int |
SCREEN_DEPTH2
The half (2) of SCREEN_DEPTH.
|
static int |
SCREEN_DEPTH4
A quarter (4) of SCREEN_DEPTH.
|
static int |
SCREEN_HEIGHT
The height (y-axis) of the sprite size
|
static int |
SCREEN_HEIGHT2
The half (2) of SCREEN_HEIGHT.
|
static int |
SCREEN_HEIGHT4
A quarter (4) of SCREEN_HEIGHT.
|
static int |
SCREEN_WIDTH
The width (x-axis) of the sprite size
|
static int |
SCREEN_WIDTH2
The half (2) of SCREEN_WIDTH.
|
static int |
SCREEN_WIDTH4
A quarter (4) of SCREEN_WIDTH.
|
static int |
VALUESCOUNT
the max. amount of different values
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractGameObject(int id,
int value)
Creates an object.
|
Modifier and Type | Method and Description |
---|---|
abstract char |
getCategory() |
abstract int |
getDepth(AbstractPosition pos)
Returns the depth of the object.
|
int |
getDimensionZ() |
static int |
getDrawCalls()
Maybe not quite correct.
|
int |
getId()
returns the id of a object
|
float |
getLightlevel()
How bright is the object?
|
abstract java.lang.String |
getName()
Returns the name of the object
|
static com.badlogic.gdx.graphics.Pixmap |
getPixmap() |
static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion |
getSprite(char category,
int id,
int value)
Returns a sprite texture.
|
static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion[][][] |
getSprites() |
static com.badlogic.gdx.graphics.g2d.TextureAtlas |
getSpritesheet()
Returns the spritesheet used for rendering.
|
int |
getValue()
Get the value.
|
protected void |
increaseDrawCalls()
When calling sprite.draw this hsould also be called for statistics.
|
boolean |
isClipped()
Is the object clipped?
|
boolean |
isHidden()
Returns true, when set as hidden.
|
boolean |
isObstacle()
Is this object an obstacle or can you pass through?
|
boolean |
isTransparent()
Can light travel through object?
|
static void |
loadSheet()
Load the spritesheet from memory.
|
void |
prepareColor(View view,
com.badlogic.gdx.graphics.Color color)
Transform the color that it works with the blending mode which is also set in this method.
|
void |
render(View view,
Camera camera,
AbstractPosition pos)
Draws an object in the color of the light engine and with the lightlevel.
|
void |
render(View view,
Camera camera,
AbstractPosition pos,
com.badlogic.gdx.graphics.Color color)
Draws an object if it is not hidden and not clipped.
|
void |
render(View view,
Camera camera,
AbstractPosition pos,
com.badlogic.gdx.graphics.Color color,
float scale)
Draws an object if it is not hidden and not clipped.
|
void |
render(View view,
Camera camera,
AbstractPosition pos,
float scale)
Draws an object in the color of the light engine and with the lightlevel.
|
void |
render(View view,
int xPos,
int yPos)
Renders at a custom position with the global light.
|
void |
render(View view,
int xPos,
int yPos,
com.badlogic.gdx.graphics.Color color,
float scale)
Renders at a custom position with a custom light.
|
void |
render(View view,
int xPos,
int yPos,
float scale)
Renders at a custom position with the global light.
|
static void |
resetDrawCalls()
Reset couner for this frame
|
void |
setClipped(boolean clipped)
Hide this object and prevent it from beeing rendered.
|
void |
setDimensionZ(int dimensionZ)
Set the height of the object.
|
void |
setHidden(boolean hidden)
Hide an object.
|
void |
setLightlevel(float lightlevel)
Set the brightness of the object.
|
void |
setObstacle(boolean obstacle)
Make the object to an obstacle or passable.
|
void |
setTransparent(boolean transparent)
Has the object transparent areas?
|
void |
setValue(int value)
Set the value of the object.
|
static void |
staticDispose() |
abstract void |
update(float delta)
Updates the logic of the object.
|
static void |
updateStaticUpdates(float delta)
Place you static update methods here.
|
public static final int SCREEN_DEPTH
public static final int SCREEN_DEPTH2
public static final int SCREEN_DEPTH4
public static final int SCREEN_WIDTH
public static final int SCREEN_WIDTH2
public static final int SCREEN_WIDTH4
public static final int SCREEN_HEIGHT
public static final int SCREEN_HEIGHT2
public static final int SCREEN_HEIGHT4
public static final int GAME_EDGELENGTH
public static final int GAME_DIAGLENGTH
public static final int GAME_DIAGLENGTH2
public static final int OBJECTTYPESCOUNT
public static final int VALUESCOUNT
protected AbstractGameObject(int id, int value)
id
- the id of the objectvalue
- Block.getInstance(int)
public abstract void update(float delta)
delta
- time since last updatepublic abstract char getCategory()
public static void updateStaticUpdates(float delta)
delta
- public void render(View view, Camera camera, AbstractPosition pos)
pos
- the coordinates where the object should be renderedview
- the view using this render methodcamera
- The camera rendering the scenepublic void render(View view, Camera camera, AbstractPosition pos, float scale)
pos
- the coordinates where the object should be renderedview
- the view using this render methodcamera
- The camera rendering the scenescale
- public void render(View view, Camera camera, AbstractPosition pos, com.badlogic.gdx.graphics.Color color)
pos
- the coordinates where the object is renderedview
- the view using this render methodcamera
- The camera rendering the scenecolor
- custom blending colorpublic void render(View view, Camera camera, AbstractPosition pos, com.badlogic.gdx.graphics.Color color, float scale)
pos
- the posiiton where the object is rendered. The center of the object.view
- the view using this render methodcamera
- The camera rendering the scenecolor
- custom blending colorscale
- public void render(View view, int xPos, int yPos)
view
- the view using this render methodxPos
- rendering positionyPos
- rendering positionpublic void render(View view, int xPos, int yPos, float scale)
view
- the view using this render methodxPos
- rendering positionyPos
- rendering positionscale
- public void render(View view, int xPos, int yPos, com.badlogic.gdx.graphics.Color color, float scale)
view
- xPos
- rendering position, center of sprite (screen space?)yPos
- rendering position, center of sprite (screen space?)color
- custom blending colorscale
- relative valuepublic void prepareColor(View view, com.badlogic.gdx.graphics.Color color)
view
- color
- a tint in which the sprite should be renderedpublic static void loadSheet()
public static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion getSprite(char category, int id, int value)
category
- the category of the sprite e.g. "b" for blocksid
- the id of the objectvalue
- the value of the objectpublic static com.badlogic.gdx.graphics.g2d.TextureAtlas getSpritesheet()
public static com.badlogic.gdx.graphics.Pixmap getPixmap()
public int getId()
public float getLightlevel()
public abstract int getDepth(AbstractPosition pos)
pos
- public abstract java.lang.String getName()
public int getValue()
public int getDimensionZ()
public boolean isHidden()
public boolean isObstacle()
public boolean isTransparent()
public boolean isClipped()
public void setLightlevel(float lightlevel)
lightlevel
- public void setObstacle(boolean obstacle)
obstacle
- true when obstacle. False when passable.public void setTransparent(boolean transparent)
transparent
- public void setValue(int value)
value
- public void setClipped(boolean clipped)
clipped
- Sets the visibility.setHidden(boolean)
public void setHidden(boolean hidden)
hidden
- public void setDimensionZ(int dimensionZ)
dimensionZ
- public static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion[][][] getSprites()
public static void resetDrawCalls()
public static int getDrawCalls()
protected void increaseDrawCalls()
public static void staticDispose()