Class Pickup
java.lang.Object
com.codename1.gaming.platformer.LevelEntity
com.codename1.gaming.platformer.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 |
-
Field Summary
Fields inherited from class LevelEntity
h, w, x, y -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class LevelEntity
deactivate, getId, getPhase, getTouchMargin, getType, hashState, isActive, onAdded, step
-
Constructor Details
-
Pickup
Creates a pickup.
Parameters
id: the idtype: the kind, see the class descriptionx: left, fixed pointy: top, fixed pointsize: width and height, fixed pointvalue: score or healingname: the key or ability name, may be null
-
-
Method Details
-
getValue
public int getValue()The pickup's value.
Returns
score or healing
-
getName
The key or ability name.
Returns
the name, or null
-
onTouch
Description copied from class:LevelEntityCalled each tick a living actor overlaps the entity.
Parameters
world: the worldc: the actor
- Overrides:
onTouchin classLevelEntity
-