Class MovingPlatform
java.lang.Object
com.codename1.gaming.platformer.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.
-
Constructor Summary
ConstructorsConstructorDescriptionMovingPlatform(int[] path, int width, int height, int speed, int pauseTicks) Creates a platform at the first waypoint. -
Method Summary
Modifier and TypeMethodDescriptionintgetDx()How far the platform moved horizontally in the last tick.intgetDy()How far the platform moved vertically in the last tick.intHeight, fixed point.intgetWidth()Width, fixed point.intgetX()Left edge, fixed point.intgetY()Top edge, fixed point.voidstep()Advances one tick.
-
Constructor Details
-
MovingPlatform
public MovingPlatform(int[] path, int width, int height, int speed, int pauseTicks) Creates a platform at the first waypoint.
Parameters
path: waypoint coordinates of the platform's top-left corner, fixed point, asx0, y0, x1, y1, ...; at least one pointwidth: the width, fixed pointheight: the height, fixed pointspeed: distance per tick, fixed pointpauseTicks: 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
-