game.onMessage

Section: Game / Entities

What it does

game.onMessage listens for Message on game: the function you hand it is called back each time. It takes a function.

Signature

game.onMessage((msg, data, senderId) => {})

Arguments

  • (msg, data, senderId) => {}

    Accepts:msgdatasenderId

Example · generated

function start() {  game.onMessage((msg, data, senderId) => {});}

game.onMessage is called with values of the shape its signature asks for. The code sits in start(), which the engine calls once, when the entity spawns.

12 members in game