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 Spring

  1. Object
  2. LevelEntity
  3. Spring
A spring pad that launches whoever lands on it upward at power, restoring their air jumps.

Constructors

public Spring(String id, int x, int y, int w, int h, int power)Creates a spring.

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

x, y, w, h

Inherited methods

Constructor details

Spring

public Spring(String id, int x, int y, int w, int h, int power)
Creates a spring.

Parameters

id String
the id
x int
left, fixed point
y int
top, fixed point
w int
width, fixed point
h int
height, fixed point
power int
launch speed, fixed point per tick

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

world PlatformWorld
the world

onTouch

public void onTouch(PlatformWorld world, Actor c)
Called each tick a living actor overlaps the entity.

Parameters

world PlatformWorld
the world
c Actor
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

h long
the running hash

Returns

the updated hash