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 Pickup
- Object
- LevelEntity
- Pickup
A collectible: a coin or gem that scores, a heart that heals, a key, an extra life, or a power-up that switches an ability on.
Only the player collects pickups. The kind is the entity type, and decides the effect:
| Type | Effect |
|---|---|
coin | +1 coin, + value score |
gem | + value score, counted as a secret |
heart | heals value |
life | +1 life |
key | adds key name to the inventory |
powerup | enables the ability named name ("dash", "walljump", "jetpack", …) |
| anything else | + value score |
Constructors
public Pickup(String id, String type, int x, int y, int size, int value, String name) | Creates a pickup. |
Methods
public int getValue() | The pickup’s value. |
public String getName() | The key or ability name. |
public void onTouch(PlatformWorld world, Actor c) | Called each tick a living actor overlaps the entity. |
Inherited fields
From LevelEntity
Inherited methods
From LevelEntity
getId, getType, isActive, deactivate, getPhase, getTouchMargin, onAdded, step, hashState
Constructor details
Pickup
public Pickup(String id, String type, int x, int y, int size, int value, String name)Creates a pickup.
Parameters
idString- the id
typeString- the kind, see the class description
xint- left, fixed point
yint- top, fixed point
sizeint- width and height, fixed point
valueint- score or healing
nameString- the key or ability name, may be null
Method details
getValue
public int getValue()The pickup’s value.
Returns
score or healing
getName
public String getName()The key or ability name.
Returns
the name, or null
onTouch
public void onTouch(PlatformWorld world, Actor c)Called each tick a living actor overlaps the entity.
Parameters
worldPlatformWorld- the world
cActor- the actor