Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public class Feedback

  1. Object
  2. 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.SinkReceives what a reaction plays.
class Feedback.ReactionWhat 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

eventType int
a WorldEvent constant

Returns

the reaction to configure

off

public void off(int eventType)
Removes the reaction to an event type.

Parameters

eventType int
a WorldEvent constant

setIntensity

public void setIntensity(double intensity)
Scales every shake and flash, for an accessibility “reduce motion” setting.

Parameters

intensity double
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

e WorldEvent
the event
aboutPlayer boolean
whether the player is its subject
camera GameCamera
shaken, may be null
sink Feedback.Sink
receives sounds and particles, may be null

update

public void update(double seconds)
Fades the flash.

Parameters

seconds double
time since the last frame

getFlash

public int getFlash()
The flash color with its current opacity, 0 when none is showing.

Returns

ARGB