Floating Score Text
Demonstrates a custom BitmapText class that animates upwards and automatically destroys itself using a Tween, creating a classic floating score effect for points.
1024 × 768
import SPRITE_KEYS from "../spriteKeys.js";
export class Score extends Phaser.GameObjects.BitmapText
{
moveY = 96;
constructor (scene, x, y, points)
{
super(scene, x, y, SPRITE_KEYS.FONT_NOKIA16, points);
this.setOrigin(0.5);
scene.add.existing(this);
scene.tweens.add({
targets: this,
y: y - this.moveY,
duration: 1000,
ease: 'Quad.easeOut',
onComplete: () => {
this.destroy();
}
});
}
}More in GameObjects13 examples
Hamster Player ClassA demonstration of extending the Arcade Physics Sprite class to create a controllable character with encapsulated movement, jumping, and animation logic.Key Sprite ClassA custom Sprite class for a collectible item that demonstrates a floating tween animation, cross-scene audio triggering, and self-destruction.Mystery Box Platformer MechanicA custom Arcade Physics Sprite that reacts to being hit from below, triggering a bump animation and spawning an item.Platformer Enemy Edge DetectionA sprite that uses an Arcade Physics sensor to detect the edges of platforms and automatically change direction.