Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How do you really buster a ghost completely? — Gideros Forum

How do you really buster a ghost completely?

GeoCoderGeoCoder Member
edited May 2014 in General questions
While running my benchmark program, I am unable to remove animated sprites completely from the stage. Here is what happened. When starting the benchmark with a bunch of live sprites, an indicator displays a steady rate of 60 fps. After adding dynamically a load of invisible sprites (namely, ghosts) to the stage. The fps rate slows down considerably to, say, 45. After removing dynamically the army of ghosts completely, the rate stays about the same, never going back to 60. How come?

I have enclosed a piece of code where it adds/removes a bunch of ghosts. Hopefully, you might catch the culprit who won't let ghosts bustered away completely.
local ghosts = {}
 
plusButton:addEventListener( "click",
	function()
		for i = #ghosts + 1, #ghosts + 100 do
		    local ghost = AnimSprite.new( "Images/blowfish.png", screenW, screenH )
			ghost:setAlpha( 0.0 )		-- invisible sprite -> a ghost
			stage:addChild( ghost )
			ghosts[i] = ghost
		end
		print( "*** Ghosts: " .. #ghosts )
	end
)
 
minusButton:addEventListener( "click",
	function()
		if #ghosts > 0 then
			for i = #ghosts - 99, #ghosts do
				stage:removeChild( ghosts[i] )
				ghosts[i] = nil
			end
			print( "*** Ghosts: " .. #ghosts ) 
		end
	end
)
PS Sorry for the catchy title. :)

Comments

Sign In or Register to comment.