It looks like you're new here. If you want to get involved, click one of these buttons!
Hi kind folks, I'm in the process of creating a fun (maybe) game about mazes, but I have problem with clearing array of physical objects, could you help me out a couple of lines of code? I would be very grateful to your if you suggestion/solution helps
P.s Should I attach the code?
Comments
Yes, code helps
@Ignatz i make it like dave1707's example of multiple objects, so i attach his example .
And this is my main class . I tried call body:destroy() func in line 53 , but this attempt didn't work
@lupino8211 To get rid of physics objects you don't want anymore, just use
body:destroy() . If they're also in a table, remove that entry after the destroy.
@lupino8211 Here's an example. I create 200 physics objects in a table, destroy them and remove them from the table when they get to the line. The number below the line shows how many objects are in the table.
@dave1707 thank you very much
@dave1707 wtf is wrong?
@dave1707 wait. I think i have got it
Upd : no, i dont
@lupino8211 - should be
b:destroy()
@dave1707 @ Ignatz , thank you for you suggestions, but I decide not to mess around with physics no more
@lupino8211 A lot of what I showed will be used even if you don't use physics objects. So don't give up on physics just because you don't understand it. Physics objects are used in a lot of games and make the games easier to code then if you tried to do it without physics objects.
@lupino In that for loop,
a
is the index of the variable, andb
is the variable itself. So since the variable is your physics body, you should callb:destroy()
.a
is just the information of where the variable is in the table.@dave1707 thank you, hope everything else will work good
@SkyTheCoder thank you, but i knew this. It's typo