Steve
Steve

Reputation: 3

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 }];

Upvotes: 0

Views: 114

Answers (1)

MiMo
MiMo

Reputation: 11953

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

Upvotes: 1

Related Questions