Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Destroy class — Gideros Forum

Destroy class

amaximovamaximov Member
edited March 2013 in General questions
Hi I am new to Gideros and have a small question regarding classes. My game has a calls called bullet that as you may guess creates bullets with intial velocities. I do not use physics but instead use a runtime listener that updates the bullets location via the self:setPosition() method. This bullet checks if it is off the screen on every frame and if it is I remove it from its parent and nil it using self = nil to be garbage collected and removed from texture memory. The problem is that my texture memory starts at about 1.6mb without the bullet, goes up to 1.7 mb and stays there even after it remove it from its parent. I have checked that it does in fact leave the screen and get nilled. Any suggestions?

Note: within my if statement that check if the bullet is offscreen I have this code:

local parent = self:getParent()
if parent ~= nil then
parent:removeChild(self)
else
self = nil
end

with a print function call I have checked that it tries to nil itself repeatedly since this is in the runtime listener. shouldnt it stop nilling itself after i nil it once and the class destroys itself. Or am I missing some key piece of Lua knoweldge?
Tagged:

Comments

Sign In or Register to comment.