Skip to content

Waves of enemies (arcade)

Enemies that sway down the screen, worth points, removed when shot down or when they leave the view. They hurt the player on contact (ContactDamage) and need the tag your bullets target:

{
"schemaVersion": "0.1",
"id": "drone",
"tags": ["enemy"],
"components": {
"Transform": {},
"Sprite": { "texture": "sprite.drone", "frame": 0, "z": 15 },
"Collider": { "w": 12, "h": 10, "offsetX": 2, "offsetY": 3, "trigger": true, "layer": "enemy", "mask": ["player", "shot"] },
"Health": { "hp": 1, "max": 1, "invulnerableTime": 0.08, "knockback": 0 },
"ContactDamage": { "amount": 1, "stompable": false },
"Mover": { "pattern": "sine", "vy": 40, "amplitude": 24, "period": 2 },
"Score": { "points": 10 },
"Offscreen": { "margin": 24 }
}
}

The player’s bullet (its Shooter has "bullet": "laser"):

{
"schemaVersion": "0.1",
"id": "laser",
"components": {
"Transform": {},
"Sprite": { "texture": "sprite.items", "frame": 0, "z": 12 },
"Collider": { "w": 4, "h": 8, "trigger": true, "layer": "shot", "mask": ["enemy"] },
"Projectile": { "damage": 1, "targetTag": "enemy" },
"Offscreen": { "margin": 8 }
}
}

The scene’s waves: five drones in a column, then six side by side, then a fan of divers:

[
{ "at": 1, "prefab": "drone", "count": 5, "every": 0.5, "x": 0.5 },
{ "at": 5, "prefab": "drone", "count": 6, "every": 0.05, "x": 0.5, "formation": "line", "spacing": 24 },
{ "at": 9, "prefab": "drone", "count": 5, "formation": "v", "spacing": 18, "components": { "Mover": { "pattern": "dive", "delay": 1.2 } } }
]

When every wave is cleared, keep the best score and show the end:

[
{
"on": "waves:done",
"do": [
{ "action": "recordBest", "value": "session.score", "key": "score" },
{ "action": "goToScene", "scene": "victory", "delayMs": 1500 }
]
}
]

On phones, a top-down ship gets a floating joystick by itself; to choose the layout, add to game.json:

{ "move": { "type": "joystick", "x": "moveX", "y": "moveY" }, "buttons": [], "pause": "pause" }