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 Switch
- Object
- LevelEntity
- Switch
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.
Constructors
public Switch(String id, int x, int y, int w, int h, int channel, boolean plate) | Creates a switch. |
Methods
public int getPhase() | A small number the view reads to pick a frame: open or closed, lit or not, how cracked. |
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
Constructor details
Switch
public Switch(String id, int x, int y, int w, int h, int channel, boolean plate)Creates a switch.
Parameters
idString- the id
xint- left, fixed point
yint- top, fixed point
wint- width, fixed point
hint- height, fixed point
channelint- the channel, 0 to 31
plateboolean- true for a pressure plate, false for a lever
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
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