Class BlockEntity

java.lang.Object
com.codename1.gaming.platformer.LevelEntity
com.codename1.gaming.platformer.BlockEntity
Direct Known Subclasses:
CrumbleBlock, Door, Gate, PushBlock

public abstract class BlockEntity extends LevelEntity
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.
  • Constructor Details

    • BlockEntity

      protected BlockEntity(String id, String type, int x, int y, int w, int h)

      Creates a block.

      Parameters
      • id: the id
      • type: the kind
      • x: left, fixed point, on a tile edge
      • y: top, fixed point, on a tile edge
      • w: width, fixed point, whole tiles
      • h: height, fixed point, whole tiles
  • Method Details

    • getTouchMargin

      public int getTouchMargin()
      Description copied from class: LevelEntity

      How 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:
      getTouchMargin in class LevelEntity
    • isSolid

      public boolean isSolid()

      Whether the block's cells are currently solid.

      Returns

      true while solid

    • setSolid

      protected boolean setSolid(PlatformWorld world, boolean s)

      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 world
      • s: true for solid
      Returns

      true if the cells now match s

    • hashState

      public long hashState(long h)
      Description copied from class: LevelEntity

      Mixes 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:
      hashState in class LevelEntity