Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public class CrumbleBlock
- Object
- LevelEntity
- BlockEntity
- CrumbleBlock
A floor that gives way:
delayTicks after the player first stands on it, its
cells vanish, and they come back respawnTicks later (never, if 0).Constructors
public CrumbleBlock(String id, int x, int y, int w, int h, int delayTicks, int respawnTicks) | Creates a crumbling block. |
Methods
public int getPhase() | A small number the view reads to pick a frame: open or closed, lit or not, how cracked. |
public void onAdded(PlatformWorld world) | Called once when the entity is added to a world, before the first step: the place to write solid cells. |
public void step(PlatformWorld world) | Advances one tick. |
public void onTouch(PlatformWorld world, Actor c) | Called each tick a living actor overlaps the entity. |
public long hashState(long h) | Mixes the entity’s play-relevant state into a hash. |
Inherited fields
From LevelEntity
Inherited methods
From LevelEntity
Constructor details
CrumbleBlock
public CrumbleBlock(String id, int x, int y, int w, int h, int delayTicks, int respawnTicks)Creates a crumbling block.
Parameters
idString- the id
xint- left, fixed point, on a tile edge
yint- top, fixed point, on a tile edge
wint- width, whole tiles, fixed point
hint- height, whole tiles, fixed point
delayTicksint- ticks between first being stood on and giving way
respawnTicksint- ticks until it returns, 0 for never
Method details
getPhase
public int getPhase()A small number the view reads to pick a frame: open or closed, lit or not,
how cracked. The default is 0.
Returns
the visual phase
onAdded
public void onAdded(PlatformWorld world)Called once when the entity is added to a world, before the first step: the
place to write solid cells. The default does nothing.
Parameters
worldPlatformWorld- the world
step
public void step(PlatformWorld world)Advances one tick. The default does nothing.
Parameters
worldPlatformWorld- the world
onTouch
public void onTouch(PlatformWorld world, Actor c)Called each tick a living actor overlaps the entity.
Parameters
worldPlatformWorld- the world
cActor- the actor
hashState
public long hashState(long h)Mixes the entity’s play-relevant state into a hash. The default mixes the
position and whether it is active.
Parameters
hlong- the running hash
Returns
the updated hash