Skip to content

Run a 2D game on the world2d surface

tutorial lesson Intermediate ⏱ 8 min vgai 0.1.0

Prerequisites: Foundations β€” components in action

What you'll learn

  • Reach the world2d page (it's a dedicated surface, not the 3D editor toolbar)
  • Run an authored Scene2D with Rapier 2D physics and 2D GameComponents
  • Move a player and collect a coin in a 2D game

What you'll build: A look at the shipped PixiJS world2d 2D render surface running a real 2D game.

Walkthrough β€” Run a 2D game on the world2d surface Β· generated by site/media/lessons/surfaces-batch.lesson.ts (4 steps)

vgai has a third render surface beside Three.js 3D and the React HUD: world2d, a 2D surface built on PixiJS v8 with Rapier 2D physics. It reuses the same engine model β€” entities, the GameComponent lifecycle, authored scene data β€” but instantiates PixiJS display objects instead of Object3Ds.

  1. Open a pixijs world β€” a PixiJS 2D render surface. (The video shows the retired standalone page; the running surface is identical.) The banner names what’s running: first-party authored Scene2D β€’ Rapier 2D physics β€’ 2D GameComponents.

    The world2d page loaded
    The PixiJS world2d surface with an authored 2D scene.
  2. It runs an authored Scene2D with Rapier 2D physics + 2D GameComponents. The walls, player, and pickups come from a Scene2DFile; a GameComponent<'pixijs'> subclass drives the player exactly like a 3D GameComponent (same init/update lifecycle and the same unified ComponentManager since T7.3 β€” the display object is a PIXI.Container instead of an Object3D).

    The 2D arena with sprites
    An authored arena: walls (static bodies), colored sprites, and a coin.
  3. Move the player with the arrow keys. Input flows through the same input system; the player body is simulated by Rapier 2D.

    The player moving in the 2D arena
    Arrow keys move the Rapier-2D player body.
  4. Jump with Space β€” the HUD tracks coins as you collect them. Walk into the coin and the Coins: counter ticks up β€” gameplay logic and a 2D trigger, on the 2D surface.

    Coins counter at 1 after collecting
    Collected a coin β€” the HUD reads Coins: 1.

Recap

New functionality

  • Reached and ran the world2d 2D surface
  • Moved a Rapier-2D player and collected a coin

New concepts & skills

  • world2d is a peer render surface (PixiJS v8 + Rapier 2D) to 3D + React UI
  • It reuses the SAME entity/GameComponent model β€” 2D components extend GameComponent<'pixijs'> with the same lifecycle (unified manager since T7.3)
  • You reach it by declaring a pixijs world in vgai.game.json β€” the manifest route; the old standalone world2d.html page is deleted (T6.1)

Next lesson β†’ Foundations: components in action