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 final class MovingPlatform

  1. Object
  2. MovingPlatform

A platform that travels back and forth along a path of waypoints and carries whatever stands on it.

It is solid from above only, like Tile#ONE_WAY, so an actor can jump up through it. A PlatformWorld moves every platform before it moves the actors, and a Body standing on one is shifted by the platform’s step before its own move, so a rider never slides or sinks.

Constructors

public MovingPlatform(int[] path, int width, int height, int speed, int pauseTicks)Creates a platform at the first waypoint.

Methods

public void step()Advances one tick.
public int getX()Left edge, fixed point.
public int getY()Top edge, fixed point.
public int getWidth()Width, fixed point.
public int getHeight()Height, fixed point.
public int getDx()How far the platform moved horizontally in the last tick.
public int getDy()How far the platform moved vertically in the last tick.

Inherited methods

Constructor details

MovingPlatform

public MovingPlatform(int[] path, int width, int height, int speed, int pauseTicks)
Creates a platform at the first waypoint.

Parameters

path int[]
waypoint coordinates of the platform’s top-left corner, fixed point, as x0, y0, x1, y1, ...; at least one point
width int
the width, fixed point
height int
the height, fixed point
speed int
distance per tick, fixed point
pauseTicks int
ticks to wait at each end of the path

Method details

step

public void step()
Advances one tick.

getX

public int getX()
Left edge, fixed point.

Returns

the x of the top-left corner

getY

public int getY()
Top edge, fixed point.

Returns

the y of the top-left corner

getWidth

public int getWidth()
Width, fixed point.

Returns

the width

getHeight

public int getHeight()
Height, fixed point.

Returns

the height

getDx

public int getDx()
How far the platform moved horizontally in the last tick.

Returns

the x delta, fixed point

getDy

public int getDy()
How far the platform moved vertically in the last tick.

Returns

the y delta, fixed point