Class BlockEntity
java.lang.Object
com.codename1.gaming.platformer.LevelEntity
com.codename1.gaming.platformer.BlockEntity
- Direct Known Subclasses:
CrumbleBlock, Door, Gate, PushBlock
Base for entities that are made of solid tiles which come and go: doors, gates
and crumbling blocks. The rectangle must be aligned to whole tiles.
-
Field Summary
Fields inherited from class LevelEntity
h, w, x, y -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBlockEntity(String id, String type, int x, int y, int w, int h) Creates a block. -
Method Summary
Modifier and TypeMethodDescriptionintHow far outside its rectangle the entity still counts as touched.longhashState(long h) Mixes the entity's play-relevant state into a hash.booleanisSolid()Whether the block's cells are currently solid.protected booleansetSolid(PlatformWorld world, boolean s) Makes the cells solid or empty.Methods inherited from class LevelEntity
deactivate, getId, getPhase, getType, isActive, onAdded, onTouch, step
-
Constructor Details
-
BlockEntity
-
-
Method Details
-
getTouchMargin
public int getTouchMargin()Description copied from class:LevelEntityHow far outside its rectangle the entity still counts as touched. An entity that writes solid cells (a door) needs a margin, since an actor can never overlap a solid cell. The default is 0.
Returns
the margin, fixed point
- Overrides:
getTouchMarginin classLevelEntity
-
isSolid
public boolean isSolid()Whether the block's cells are currently solid.
Returns
true while solid
-
setSolid
Makes the cells solid or empty. Becoming solid waits while an actor is inside, so nobody is ever trapped in a wall.
Parameters
world: the worlds: true for solid
Returns
true if the cells now match
s -
hashState
public long hashState(long h) Description copied from class:LevelEntityMixes the entity's play-relevant state into a hash. The default mixes the position and whether it is active.
Parameters
h: the running hash
Returns
the updated hash
- Overrides:
hashStatein classLevelEntity
-