Add a new collectible
Gems worth counting separately from coins: a prefab with Pickup, a rule that counts it, and a HUD counter.
Prefab game/prefabs/gem.json (reuses the coin art, tinted):
{ "schemaVersion": "0.1", "id": "gem", "components": { "Transform": {}, "Sprite": { "texture": "sprite.items", "frame": 0, "tint": "#7fe3ff", "z": 15 }, "SpriteAnimation": { "animation": "spin" }, "Collider": { "w": 8, "h": 10, "offsetX": 4, "offsetY": 3, "trigger": true, "layer": "pickup", "mask": ["player"] }, "Pickup": { "kind": "gem", "effectColor": "#7fe3ff" } }}Scene rules (add to the level scene’s rules):
[ { "on": "pickup:gem", "do": [ { "action": "addToCounter", "counter": "gems", "amount": 1 }, { "action": "playSound", "sound": "sfx.coin" } ] }]HUD entry (add to the scene’s hud); gemTotal is set automatically from the gems in the level:
[{ "widget": "counter", "anchor": "top", "label": "GEMS {value}/{game.gemTotal}", "bind": "game.gems" }]Then place gems with add_entity or a legend character, and check with run_headless:
expect: [{ "event": "pickup:gem" }].