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

  1. Object
  2. LevelEntity
  3. 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:

TypeEffect
coin+1 coin, + value score
gem+ value score, counted as a secret
heartheals value
life+1 life
keyadds key name to the inventory
powerupenables 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

x, y, w, h

Inherited methods

Constructor details

Pickup

public Pickup(String id, String type, int x, int y, int size, int value, String name)
Creates a pickup.

Parameters

id String
the id
type String
the kind, see the class description
x int
left, fixed point
y int
top, fixed point
size int
width and height, fixed point
value int
score or healing
name String
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

world PlatformWorld
the world
c Actor
the actor