miaoda-game-juice-phaser
v0.3.2
Published
Phaser game-feel helpers for reliable impact profiles, deformation, recoil, blinking, floating text, and hit-stop.
Readme
miaoda-game-juice-phaser
Reusable Phaser 4 presentation for impacts, pickups, jumps, UI feedback, and floating combat text. Choose it when the game owns the rules and needs cancelable effects that clean up their Tweens and restore original properties.
pnpm add miaoda-game-juice-phaserimport {IMPACT_PROFILES, playImpact} from 'miaoda-game-juice-phaser';
playImpact({
profile: IMPACT_PROFILES.heavy,
tweens: this.tweens,
host: this,
target: enemy,
camera: this.cameras.main,
text: {factory: this.add, value: '-12', x: enemy.x, y: enemy.y},
});Profiles are light, heavy, critical, and explosion; explicit options override a profile. Presentation helpers do not decide damage, invulnerability, knockback, or combat state.
Individual effects
import {blink, cameraShake, hitFlash, hitStop, punchScale, recoil, squashStretch} from 'miaoda-game-juice-phaser';
hitFlash(this.tweens, enemy);
punchScale(this.tweens, pickup);
squashStretch(this.tweens, player, {axis: 'y'});
recoil(this.tweens, weapon, {angle: weapon.rotation});
const blinkEffect = blink(this.tweens, player, {durationMs: 900});
cameraShake(this.cameras.main, {intensity: 0.01});
const stop = hitStop(this, {durationMs: 45});
blinkEffect.cancel();
stop();Cancelable effects restore the property they changed. Replaying the same effect type replaces only that effect; unrelated game Tweens remain untouched. hitStop restores previous physics and Tween time scales.
Floating text
Use spawnFloatingText(add, tweens, value, x, y) for occasional text, or keep a FloatingTextPool for frequent damage numbers. Destroy the pool with the Scene. Replaying floating text on the same object stops the older Tween, and only the latest completion may recycle or destroy it. Coordinates, durations, effect amounts, time scales, and camera intensity must be finite; values documented as magnitudes are non-negative.
