Search code examples
javascriptphysicsjs

PhysicsJS - How to find a body by its label (or other value)


How should the findOne method be properly used? (http://wellcaffeinated.net/PhysicsJS/docs/#Physics-world-prototype-findOne)

This code returns the error: Uncaught TypeError: Cannot read property 'label' of undefined

var theBall = world.findOne([{ label: ball }];

Solution

  • I think it does not expect an array but an object: world.findOne({ label: ball });