public class Block extends AbstractGameObject
GAME_DIAGLENGTH, GAME_DIAGLENGTH2, GAME_EDGELENGTH, GAME_EDGELENGTH2, OBJECTTYPESNUM, SCREEN_DEPTH, SCREEN_DEPTH2, SCREEN_DEPTH4, SCREEN_HEIGHT, SCREEN_HEIGHT2, SCREEN_HEIGHT4, SCREEN_WIDTH, SCREEN_WIDTH2, SCREEN_WIDTH4, VALUESNUM
Modifier | Constructor and Description |
---|---|
protected |
Block(int id)
Don't use this constructor to get a new block.
|
Modifier and Type | Method and Description |
---|---|
static Block |
createBasicInstance(int id)
You can create a basic block if its id is not reserved.
|
static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion |
getBlockSprite(int id,
int value,
Sides side)
Returns a sprite sprite of a specific side of the block
|
static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion[][][] |
getBlocksprites() |
char |
getCategory()
Get the category letter for accessing sprites.
|
static Block |
getInstance(int id)
Create a block.
|
static Block |
getInstance(int id,
int value)
Create a block through this factory method.
|
java.lang.String |
getName()
Returns the name of the object
|
static com.badlogic.gdx.graphics.Color |
getRepresentingColor(int id,
int value)
Returns a color representing the block.
|
boolean |
hasSides()
Is the block a true block with sides or represents it another thing like a flower?
|
boolean |
isLiquid()
Check if the block is liquid.
|
void |
onDestroy(AbstractPosition pos)
Overwrite to define what should happen if the block is getting destroyed?
|
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,
int xPos,
int yPos)
Render the whole block at a custom position.
|
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,
com.badlogic.gdx.graphics.Color color,
float scale,
boolean staticShade)
Renders the whole block at a custom position with a scale.
|
void |
renderSide(View view,
Camera camera,
AbstractPosition coords,
Sides side,
com.badlogic.gdx.graphics.Color color,
float scale)
Render a side of a block at the position of the coordinates.
|
void |
renderSide(View view,
Camera camera,
AbstractPosition coords,
Sides side,
float scale)
Render a side of a block at the position of the coordinates.
|
void |
renderSide(View view,
int xPos,
int yPos,
Sides sidenumb)
Ignores lightlevel.
|
void |
renderSide(View view,
int xPos,
int yPos,
Sides side,
com.badlogic.gdx.graphics.Color color,
float scale)
Draws a side of a block at a custom position.
|
void |
setNoSides()
Removes the flag that this block has sides.
|
Block |
spawn(Coordinate coord)
places the object on the map.
|
static void |
staticDispose() |
void |
update(float delta,
int x,
int y,
int z)
Update the block.
|
getDrawCalls, getHealth, getId, getLightlevel, getPixmap, getRotation, getSprite, getSpriteId, getSprites, getSpritesheet, getValue, increaseDrawCalls, isHidden, isObstacle, isTransparent, loadSheet, render, render, render, render, resetDrawCalls, setGraphicsId, setHealth, setHidden, setLightlevel, setObstacle, setRotation, setTransparent, setValue, updateStaticUpdates
protected Block(int id)
id
- com.BombingGames.WurfelEngine.Core.Gameobjects.Block#getInstance()
public static Block createBasicInstance(int id)
id
- non-reserved id's=> id>39public static Block getInstance(int id)
id
- the block's idpublic static Block getInstance(int id, int value)
id
- the id of the blockvalue
- the value of the block, which is like a sub-idpublic Block spawn(Coordinate coord)
IsSelfAware
.coord
- the position on the mappublic static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion getBlockSprite(int id, int value, Sides side)
id
- the id of the blockvalue
- the value of teh blockside
- Which side?public static com.badlogic.gdx.graphics.Color getRepresentingColor(int id, int value)
id
- id of the Blockvalue
- the value of the block.public boolean isLiquid()
public boolean hasSides()
public void render(View view, Camera camera, AbstractPosition pos)
AbstractGameObject
render
in class AbstractGameObject
view
- the view using this render methodcamera
- The camera rendering the scenepos
- the coordinates where the object should be renderedpublic void render(View view, int xPos, int yPos)
render
in class AbstractGameObject
view
- the view using this render methodxPos
- rendering position (screen)yPos
- rendering position (screen)public void render(View view, int xPos, int yPos, com.badlogic.gdx.graphics.Color color, float scale)
AbstractGameObject
render
in class AbstractGameObject
xPos
- rendering position, center of sprite (screen space?)yPos
- rendering position, center of sprite (screen space?)color
- custom blending colorscale
- relative valuepublic void render(View view, int xPos, int yPos, com.badlogic.gdx.graphics.Color color, float scale, boolean staticShade)
view
- the view using this render methodxPos
- rendering positionyPos
- rendering positioncolor
- when the block has sides its sides gets shaded using this color.staticShade
- makes one side brighter, opposite side darkerscale
- the scale factor of the imagepublic void renderSide(View view, Camera camera, AbstractPosition coords, Sides side, float scale)
view
- the view using this render methodcamera
- The camera rendering the scenecoords
- the coordinates where the side is renderedside
- The number identifying the side. 0=left, 1=top, 2=rightscale
- public void renderSide(View view, Camera camera, AbstractPosition coords, Sides side, com.badlogic.gdx.graphics.Color color, float scale)
view
- the view using this render methodcamera
- The camera rendering the scenecoords
- the coordinates where to renderside
- The number identifying the side. 0=left, 1=top, 2=rightcolor
- a tint in which the sprite gets renderedscale
- public void renderSide(View view, int xPos, int yPos, Sides sidenumb)
view
- the view using this render methodxPos
- rendering positionyPos
- rendering positionsidenumb
- The number identifying the side. 0=left, 1=top, 2=rightpublic void renderSide(View view, int xPos, int yPos, Sides side, com.badlogic.gdx.graphics.Color color, float scale)
view
- the view using this render methodxPos
- rendering positionyPos
- rendering positionside
- The number identifying the side. 0=left, 1=top, 2=rightcolor
- a tint in which the sprite gets renderedscale
- if you want to scale it up use scale > 0 else negative values scales downpublic void update(float delta, int x, int y, int z)
delta
- time in ms since last updatex
- relative posy
- relative posz
- relative pospublic char getCategory()
AbstractGameObject
getCategory
in class AbstractGameObject
public static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion[][][] getBlocksprites()
public void setNoSides()
public static void staticDispose()
public java.lang.String getName()
AbstractGameObject
getName
in class AbstractGameObject
public void onDestroy(AbstractPosition pos)
pos
- the position of the block, can be null if not needed