Difference Betwen object = nil AND then object:removeSelf(). Why want just =nil work ?

I have code to "destroy" a ball
theBall = nil once it hits another object.
but it just drops like through the platform and game play area.

but if I use the below code, it get "destroyed " just as I thought doing = nil would.
if theBall ~= nil then
theBall:removeSelf()
end

any technical reason why this happens ?

Im using the removeself code and it works, I just wanna know why the object=nil
does not work ?

theBall has a body of dynamic.
the platform has a body of static.

Could be totally wrong about this...but removeSelf() (as listed in the API docs) only removes the display object (hence it's a display.* command). When you removeSelf() there is still a leftover lua table but it seems functionally a spare appendage at that point. If you nil first the descriptive data is gone but I guess the hooks remain?

If you really want to wipe something without any kind of lingering memory, you need to do removeSelf() and then nil, I suspect...

funny yes!!!

i set object = nil AND
put it in "debug" mode.
THEN I see the object just drop.

but i removeself() on object and it dissappears from "debug" mode.

but yes, I did I quick print(type(object)) debug to console
and the object was indeed showing a 'table'

so I did exactly and it "wiped" it clean(i.e. set object to nil) as well as remove remove self.

I'm finding printing out the type(object) to be really useful. I use a programming style
of DO one line of code, SAVE file and RUN in simulator. IT works for me.

Cuz nil clear remove from memory in Obj-C :)

views:1515 update:2011/12/2 15:07:10
corona forums © 2003-2011