public class Block extends AbstractGameObject
Modifier and Type | Field and Description |
---|---|
static byte |
LEFTSIDE
The id of the left side of a block.
|
static java.lang.String[] |
NAMELIST
Containts the names of the objects. index=id
|
static byte |
RIGHTSIDE
The id of the right side of a block.
|
static byte |
TOPSIDE
The id of the top side of a block.
|
GAME_DIAGLENGTH, GAME_DIAGLENGTH2, GAME_EDGELENGTH, OBJECTTYPESCOUNT, SCREEN_DEPTH, SCREEN_DEPTH2, SCREEN_DEPTH4, SCREEN_HEIGHT, SCREEN_HEIGHT2, SCREEN_HEIGHT4, SCREEN_WIDTH, SCREEN_WIDTH2, SCREEN_WIDTH4, VALUESCOUNT
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,
int side)
Returns a sprite sprite of a specific side of the block
|
static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion[][][] |
getBlocksprites() |
char |
getCategory() |
int |
getDepth(AbstractPosition coords)
Returns the depth of the object.
|
static Block |
getInstance(int id)
Create a block.
|
static Block |
getInstance(int id,
int value)
Create a block.
|
static Block |
getInstance(int id,
int value,
Coordinate coords)
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 |
render(View view,
Camera camera,
AbstractPosition coords)
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 and checks for clipping and hidden.
|
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,
int 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,
int side,
float scale)
Render a side of a block at the position of the coordinates.
|
void |
renderSide(View view,
int xPos,
int yPos,
int sidenumb)
Ignores lightlevel.
|
void |
renderSide(View view,
int xPos,
int yPos,
int sidenumb,
com.badlogic.gdx.graphics.Color color,
float scale)
Draws a side of a block at a custom position.
|
void |
setClipped(boolean clipped)
Hide this object and prevent it from beeing rendered.
|
void |
setNoSides()
Removes the flag that this block has sides.
|
void |
setSideClipping(int side,
boolean clipping)
Make a side (in)clipping.
|
static void |
staticDispose() |
void |
update(float delta)
Updates the logic of the object.
|
getDimensionZ, getDrawCalls, getId, getLightlevel, getPixmap, getSprite, getSprites, getSpritesheet, getValue, increaseDrawCalls, isClipped, isHidden, isObstacle, isTransparent, loadSheet, prepareColor, render, render, render, render, resetDrawCalls, setDimensionZ, setHidden, setLightlevel, setObstacle, setTransparent, setValue, updateStaticUpdates
public static final byte LEFTSIDE
public static final byte TOPSIDE
public static final byte RIGHTSIDE
public static final java.lang.String[] NAMELIST
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 block's idvalue
- it's valuepublic static Block getInstance(int id, int value, Coordinate coords)
id
- the id of the blockvalue
- the value of the block, which is like a sub-idcoords
- the coordinates where the block is going to be places. If the block does not need this information it can be null.public static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion getBlockSprite(int id, int value, int side)
id
- the id of the blockvalue
- the value of teh blockside
- Which side? (0 - 2)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 setClipped(boolean clipped)
AbstractGameObject
setClipped
in class AbstractGameObject
clipped
- When it is set to false, every side will also get clipped..AbstractGameObject.setHidden(boolean)
public void setSideClipping(int side, boolean clipping)
side
- 0 = left, 1 = top, 2 = rightclipping
- true when it should be clipped.public void render(View view, Camera camera, AbstractPosition coords)
AbstractGameObject
render
in class AbstractGameObject
view
- the view using this render methodcamera
- The camera rendering the scenecoords
- 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
- i don't know what this does. This only makes it a bit brighter???scale
- the scale factor of the imagepublic void renderSide(View view, Camera camera, AbstractPosition coords, int 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, int 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, int 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, int sidenumb, com.badlogic.gdx.graphics.Color color, float scale)
view
- the view using this render methodxPos
- rendering positionyPos
- rendering positionsidenumb
- 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)
AbstractGameObject
update
in class AbstractGameObject
delta
- time since last updatepublic int getDepth(AbstractPosition coords)
AbstractGameObject
getDepth
in class AbstractGameObject
public char getCategory()
getCategory
in class AbstractGameObject
public java.lang.String getName()
AbstractGameObject
getName
in class AbstractGameObject
public static com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion[][][] getBlocksprites()
public void setNoSides()
public static void staticDispose()