I’m using the cleangroup page set up by Jon Beebe, and methinks I may be doing something wrong. Or maybe it doesn’t work with sprites? Here’s a splash screen I’m working on. It has a sprite that is set in the localGroup which I’m calling on the cleangroup to wipe out when this page changes to the main menu. Also, I have the collectgarbage function going on every page which is showing the texture Memory is stacking up massively between the later levels of the games that use sprites. So, I’m guessing this means that they are not being removed either and it’s the cause of the crashes I’m getting on the iPad build.
module(..., package.seeall)
-- Main function - MUST return a display.newGroup()
function new()
local function garbagePrinting()
collectgarbage("collect")
print("loadmainmenu.lua")
print("Memory: " .. collectgarbage("count"))
print(system.getInfo("textureMemoryUsed"))
end
garbagePrinting()
local localGroup = display.newGroup()
local theTimer
local loadingImage
local backgroundFill
local sprite = require "sprite"
local chimeSound = audio.loadSound( "chime.mp3" , false)
audio.play( chimeSound, { onComplete=audio.stop( chimeSound ) } )
local showLoadingScreen = function()
backgroundFill = display.newRect( screenX, screenY, screenWidth, screenHeight )
backgroundFill:setFillColor( 96, 57, 19, 255 )
localGroup:insert( backgroundFill )
--SPRITES
local walker = sprite.newSpriteSheetFromData( "walker"..suffix..".png", require("walker"..suffix).getSpriteSheetData() )
local spriteSet = sprite.newSpriteSet(walker,1,59)
sprite.add(spriteSet,"walker",1,59,1000,0)
local spriteWalker = sprite.newSprite(spriteSet)
spriteWalker:play()
spriteWalker.x = display.contentCenterX
spriteWalker.y = display.contentCenterY-105
spriteWalker.xScale, spriteWalker.yScale = displayScale, displayScale
localGroup:insert( spriteWalker )
--LOGO
loadingImage = display.newImageRect( "ratatat.png", 480, 320 )
loadingImage.x = centerX; loadingImage.y = centerY
local goToLevel = function()
cleanGroup( localGroup )
localGroup = nil
audio.stop( chimeSound )
audio.dispose( chimeSound )
chimeSound = nil
director:changeScene( "mainmenu" )
end
theTimer = timer.performWithDelay( 3000, goToLevel, 1 )
end
r = display.newRect( screenX, screenY, screenWidth, screenHeight)
r:setFillColor( 0, 0, 0 )
local function repeatFade (event)
r.alpha = 1
transition.to( r, { alpha=0, time=700 } )
end
-- Fade out rectangle every second 20x using transition.to()
timer.performWithDelay(700, repeatFade, 1 )
showLoadingScreen()
unloadMe = function()
if theTimer then
timer.cancel( theTimer )
theTimer = nil
end
if loadingImage then
loadingImage:removeSelf()
loadingImage = nil
end
end
-- MUST return a display.newGroup()
return localGroup
end
If cleangroup doesn’t work for these, any other ways to get the sprites to get wiped out so their memory doesn’t stack? Oh, and that spriteSheet:dispose() has not been working for me at all. [import]uid: 14032 topic_id: 8978 reply_id: 308978[/import]