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

since it is a table, there will be a

1
object.physicsBody

how do you use it? cuz i am always getting nil

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
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

>> edou
The variable is private. We don't know it.

views:1439 update:2012/1/9 8:53:30
corona forums © 2003-2011