sprite.setPhysicsOn

Section: Sprite Physics

What it does

sprite.setPhysicsOn sets PhysicsOn on a sprite object. It takes id and a value. The accepted values are dynamic, static and kinematic.

Signature

sprite.setPhysicsOn(id, "dynamic"|"static"|"kinematic")

Arguments

  • id
  • "dynamic"|"static"|"kinematic"

    Accepts:dynamicstatickinematic

Example · generated

function start() {  const id = sprite.create('/sprites/hero.png', 100, 120);  sprite.setPhysicsOn(id, 'dynamic');}

sprite.create is there to give the call something to act on; sprite.setPhysicsOn is the line that matters. The code sits in start(), which the engine calls once, when the entity spawns.

49 members in sprite