i'm trying to understand Lua , love and all the rest ...( female , world war ... )
I have write this :
Code: Select all
--AutoGenerated by DEVotion
PhyRect={}
PhyRect.Rect={}
function Add(Tx,Ty)
local R={}
R.Body= love.physics.newBody(PhyWorld, Tx*32, Ty*32,0)
R.Shape=love.physics.newRectangleShape(R.Body,32,32)
R.Shape:setRestitution(0.5)
print( table.getn(PhyRect.Rect))
table.insert(PhyRect.Rect,R)
--return Rect
end
function RemoveAll()
for k,v in ipairs(PhyRect.Rect) do
v.Shape:destroy()
v.Body:destroy()
table.remove(PhyRect.Rect,k)
print("remove ="..k.." tgn"..table.getn(PhyRect.Rect).."")
end
end
Why my function don't remove all ?
If i 'm add :
while table.getn(PhyRect.Rect) > 0 do .......end
in the function , it's ok
thank for help !