Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public class Feedback
- Object
- Feedback
“Juice”: what the player sees and hears when something happens, chosen per
WorldEvent type – the role of Corgi Engine’s MMFeedbacks.
A Reaction bundles a camera shake, a screen flash, a sound name and a
particle burst. PlatformView runs every event of every tick through
#react, which shakes the GameCamera and hands the sound and the burst
to a Sink the game supplies (a com.codename1.gaming.SoundPool, a
com.codename1.gaming.ParticleEmitter, a haptic tap). The defaults make a
level feel alive before any tuning: landings thud, stomps pop, hits shake.
Nested types
interface Feedback.Sink | Receives what a reaction plays. |
class Feedback.Reaction | What one kind of event does. |
Constructors
public Feedback() | Creates feedback with the stock reactions. |
Methods
public final Feedback.Reaction on(int eventType) | The reaction to an event type, created empty if it had none. |
public void off(int eventType) | Removes the reaction to an event type. |
public void setIntensity(double intensity) | Scales every shake and flash, for an accessibility “reduce motion” setting. |
public double getIntensity() | How strong shakes, flashes and particle bursts are. |
public void react(WorldEvent e, boolean aboutPlayer, GameCamera camera, Feedback.Sink sink) | Plays an event. |
public void update(double seconds) | Fades the flash. |
public int getFlash() | The flash color with its current opacity, 0 when none is showing. |
Inherited methods
Constructor details
Feedback
public Feedback()Creates feedback with the stock reactions.
Method details
on
public final Feedback.Reaction on(int eventType)The reaction to an event type, created empty if it had none.
Parameters
eventTypeint- a
WorldEventconstant
Returns
the reaction to configure
off
public void off(int eventType)Removes the reaction to an event type.
Parameters
eventTypeint- a
WorldEventconstant
setIntensity
public void setIntensity(double intensity)Scales every shake and flash, for an accessibility “reduce motion” setting.
Parameters
intensitydouble- 0 for none, 1 for full
getIntensity
public double getIntensity()How strong shakes, flashes and particle bursts are.
Returns
0 for none, 1 for full
react
public void react(WorldEvent e, boolean aboutPlayer, GameCamera camera, Feedback.Sink sink)Plays an event.
Parameters
eWorldEvent- the event
aboutPlayerboolean- whether the player is its subject
cameraGameCamera- shaken, may be null
sinkFeedback.Sink- receives sounds and particles, may be null
update
public void update(double seconds)Fades the flash.
Parameters
secondsdouble- time since the last frame
getFlash
public int getFlash()The flash color with its current opacity, 0 when none is showing.
Returns
ARGB