destroy() vs release()
destroy() vs release()
If I want to free a physics body from memory, is there any difference between calling Body:destroy and Object:release?
Re: destroy() vs release()
(if you couldn't find an answer yet)
I cannot answer directly but this is what you could try to find out :
Create an object with a fixture "fixture".
Destroy() is supposed to delete the object and its fixtures, so using destroy(), "fixture" will be deleted.
Release the object and try to use a function on "fixture".
If it has been deleted as well, you should get an error ( => "After this method has been called, attempting to call any other method on the object or using the object as an argument in another LÖVE API will cause an error." from Object:release() documentation).
I cannot answer directly but this is what you could try to find out :
Create an object with a fixture "fixture".
Destroy() is supposed to delete the object and its fixtures, so using destroy(), "fixture" will be deleted.
Release the object and try to use a function on "fixture".
If it has been deleted as well, you should get an error ( => "After this method has been called, attempting to call any other method on the object or using the object as an argument in another LÖVE API will cause an error." from Object:release() documentation).
Re: destroy() vs release()
Okay, after some testing and poking around, I found that Object:release simply disables the body's Lua reference. The body itself will still remain active within the physics world. Body:destroy removes it from the world and disables its reference.
In the C++ source, destroy() also calls release(), but not vice-versa.
In the C++ source, destroy() also calls release(), but not vice-versa.
Who is online
Users browsing this forum: Ahrefs [Bot] and 2 guests