sprite.setPhysicsForce

Section: Sprite Physics

What it does

sprite.setPhysicsForce sets PhysicsForce on a sprite object. It takes id, fx, fy, wx and wy. wx and wy are optional.

Signature

sprite.setPhysicsForce(id, fx, fy, wx?, wy?)

Arguments

  • id
  • fx
  • fy
  • wxoptional
  • wyoptional

Example · generated

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

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

49 members in sprite