Help

Practical notes for getting started. This site is a gate around an early development build.

Not signed in. Sign in or create an account.

Viewing: Scripting

Scripting (Phaser-powered)

Tulio scripts are plain JavaScript modules that run at play-time.

Tulio does not attempt to hide Phaser. In practice, you’ll often use Phaser APIs when writing gameplay code.

The mental model

  • You write a class that extends TulioBehaviour.
  • Tulio attaches your behaviour(s) to a runtime game object. You can attach multiple scripts to the same object.
  • Your behaviour can use:
    • ctx.scene (a Phaser Scene)
    • this.gameObject (a Phaser Game Object)
    • this.transform (a Tulio convenience wrapper around transform)

Behaviour lifecycle

If present, Tulio calls:

  • create(ctx, props) — once when the object is created/spawned
  • update(dt, ctx, props) — every frame

Where:

  • dt is delta time in seconds
  • props are inspector properties resolved for the script
  • ctx contains runtime helpers (and always includes ctx.scene)

Example

export default class PlayerController extends TulioBehaviour {
  static properties = {
    speed: { type: 'number', default: 200 }
  };

  create(ctx, props) {
    this.keys = ctx.scene.input.keyboard.addKeys({
      left: 'A',
      right: 'D'
    });
  }

  update(dt, ctx, props) {
    const speed = Number(props.speed) || 0;

    if (this.keys.left.isDown) this.x -= speed * dt;
    if (this.keys.right.isDown) this.x += speed * dt;
  }
}

Helper functions

Tulio exposes a small set of GameMaker-style math helpers.

  • point_distance / pointDistance
  • point_direction / pointDirection
  • lengthdir_x / lengthdirX
  • lengthdir_y / lengthdirY
  • degToRad, radToDeg, clamp, lerp

When to use Phaser docs

You’ll most likely reach for Phaser documentation when you:

  • Use physics and collisions
  • Use cameras, containers, animations, particles
  • Do advanced input handling
  • Optimize performance