Skip to content

sapling2d用代码写 2D 游戏

Godot 风格的节点树,PixiJS 渲染,Box2D 物理。浏览器里开发,同一份代码发布成微信小游戏;场景树能在 Node 里逐帧跑测试。

30 秒看懂 ​

ts
import { Node2D, Scene, v } from 'sapling2d'
import { startGame } from 'sapling2d/browser'

class Mover extends Node2D {
  speed = 120 // 像素/秒
  override process(dt: number) {
    this.x += this.speed * dt
  }
}

class Main extends Scene {
  override ready() {
    this.add(new Mover({ position: v(100, 200) }))
  }
}

await startGame({ main: Main })

从安装开始 →

MIT 许可证