How to check is a display object has a physics body???
I have display object & will be using “physics.addBody” and “physics.removeBody”. Can’t work out how to tell if a display object has a physics body or not (else I’ll get “bad argument #-1 to ‘removeBody’ (Proxy expected, got nil)” if I try to remove the physics body and it has already been removed)
You could try to check the .isBodyActive property, which should be nil if the object has no body.
[LUA]
if yourObject.isBodyActive ~= true and yourObject.isBodyActive ~= false then
physics.removeBody(…)
end
[/LUA]
I didn’t test this, but it should work.
You could try to check the .isBodyActive property, which should be nil if the object has no body.
[LUA]
if yourObject.isBodyActive ~= true and yourObject.isBodyActive ~= false then
physics.removeBody(…)
end
[/LUA]
I didn’t test this, but it should work.