Hi,

For destroying physics bodies in Corona SDK, use any of the following methods.

urBody:removeSelf()

OR

urBody.parent:remove( urBody )

Note :
While Box2D objects will be safely retained until the end of the current world step, their Lua references will be deleted immediately. Therefore, be careful not to accidentally delete the same Lua object more than once. This situation could occur when deleting objects involved in collisions, which can potentially have many event phases before the collision is fully resolved. The solution is simple:

local function onCollision( self, event )
        if ( event.phase == "began" ) then

                -- Check if body still exists before removing!
                if ( urBody ) then
                        urBody:removeSelf()
                        urBody = nil
                end

        end
end

🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.