Check if has body

hy,

i am wondering if there is a way to check if an object has a body.
Because i am removing bodys from an array full of objects, some have bodys other’s dont, and i get the message : WARNING: physics.removeBody() given a display object that is not a physics object.

want to do something like this

if physics.“hasBody”( Deck[row][column] ) then
physics.removeBody( Deck[row][column] )
end

thks,
Edou [import]uid: 92107 topic_id: 19936 reply_id: 319936[/import]

since it is a table, there will be a
[lua]object.physicsBody[/lua]
value, however I don’t think Ansca tells this. [import]uid: 79135 topic_id: 19936 reply_id: 77594[/import]

how do you use it? cuz i am always getting nil [import]uid: 92107 topic_id: 19936 reply_id: 77754[/import]

You could just keep track of whether objects have a body yourself, just add this flag to all elements in the table and set it to true/false whenever you add or remove a physics body.

[lua]deck[row][column].hasBody = false
for a = 1, 10, 1 do

for b = 1, 10, 1 do

local obj = deck[a][b]

if obj.hasBody then physics.removeBody(obj); end

end
end [import]uid: 93133 topic_id: 19936 reply_id: 77758[/import]

>> edou
The variable is private. We don’t know it. [import]uid: 79135 topic_id: 19936 reply_id: 78307[/import]