Class Switch

java.lang.Object
com.codename1.gaming.platformer.LevelEntity
com.codename1.gaming.platformer.Switch

public class Switch extends LevelEntity

A lever or a pressure plate on a channel.

A lever toggles its channel when the player presses Input#ACTIVATE at it; a plate (plate = true) holds the channel on while any actor stands on it.

  • Constructor Details

    • Switch

      public Switch(String id, int x, int y, int w, int h, int channel, boolean plate)

      Creates a switch.

      Parameters
      • id: the id
      • x: left, fixed point
      • y: top, fixed point
      • w: width, fixed point
      • h: height, fixed point
      • channel: the channel, 0 to 31
      • plate: true for a pressure plate, false for a lever
  • Method Details

    • getPhase

      public int getPhase()
      Description copied from class: LevelEntity

      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

      Overrides:
      getPhase in class LevelEntity
    • step

      public void step(PlatformWorld world)
      Description copied from class: LevelEntity

      Advances one tick. The default does nothing.

      Parameters
      • world: the world
      Overrides:
      step in class LevelEntity
    • onTouch

      public void onTouch(PlatformWorld world, Actor c)
      Description copied from class: LevelEntity

      Called each tick a living actor overlaps the entity.

      Parameters
      • world: the world
      • c: the actor
      Overrides:
      onTouch in class LevelEntity
    • 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