public abstract class AbstractGameObject
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
GAME_DIAGLENGTH
The game space dimension size's aequivalent to SCREEN_DEPTH or SCREEN_WIDTH.
|
static int |
GAME_DIAGLENGTH2
Half (1/2) of GAME_DIAGLENGTH
|
static int |
GAME_EDGELENGTH
The game spaces dimension in pixel (edge length). 1 game meter ^= 1 GAME_EDGELENGTH
The value is calculated by SCREEN_HEIGHT*sqrt(2) because of the axis shortening.
|
static int |
OBJECTTYPESNUM
the max. amount of different object types
|
static int |
SCREEN_DEPTH
Screen depth of a block/object sprite in pixels.
|
static int |
SCREEN_DEPTH2
The half (1/2) of SCREEN_DEPTH.
|
static int |
SCREEN_DEPTH4
A quarter (1/4) of SCREEN_DEPTH.
|
static int |
SCREEN_HEIGHT
The height (y-axis) of the sprite size
|
static int |
SCREEN_HEIGHT2
The half (1/2) of SCREEN_HEIGHT.
|
static int |
SCREEN_HEIGHT4
A quarter (1/4) of SCREEN_HEIGHT.
|
static int |
SCREEN_WIDTH
The width (x-axis) of the sprite size
|
static int |
SCREEN_WIDTH2
The half (1/2) of SCREEN_WIDTH.
|
static int |
SCREEN_WIDTH4
A quarter (1/4) of SCREEN_WIDTH.
|
static int |
VALUESNUM
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()
Get the category letter for accessing sprites.
|
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() |
float |
getRotation()
Returns the rotation of the object.
|
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 |
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 |
setRotation(float rotation) |
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 OBJECTTYPESNUM
public static final int VALUESNUM
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 static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion[][][] getSprites()
public static void resetDrawCalls()
public static int getDrawCalls()
protected void increaseDrawCalls()
public 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 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
- relative valuepublic 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
- relative valuepublic 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 int getId()
public float getLightlevel()
public abstract java.lang.String getName()
public int getValue()
public float getRotation()
public boolean isHidden()
public boolean isObstacle()
public boolean isTransparent()
public boolean isClipped()
public void setLightlevel(float lightlevel)
lightlevel
- 1 is full bright. 0 is black.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 setRotation(float rotation)
rotation
- set the rotation in degrees.public static void staticDispose()