Hi all,
I have been trying to get storyboard working but have had some difficulties with the memory. I have set up below two simple screens that when pressed switch between the two screens to one another (back and forth). I am tracking the memory usage with a function in the main lua file. I believe I am following everything correctly but I still see that memory usage rises as I switch back and forth. Could someone please help explain what I am doing wrong.
Thanks,
Chris
[lua]–Main.lua
–
– main.lua
local storyboard = require “storyboard”
– Remove Status Bar –
display.setStatusBar( display.HiddenStatusBar )
local monitorMem = function()
collectgarbage()
print( "MemUsage: " … collectgarbage(“count”) )
local textMem = system.getInfo( “textureMemoryUsed” ) / 1000000
print( "TexMem: " … textMem )
end
Runtime:addEventListener( “enterFrame”, monitorMem )
storyboard.gotoScene( “loadingScreenOne” )
– loadingScreenOne.lua
local loadingImage;
local pressed
function scene:createScene( event )
local group = self.view
end
function scene:enterScene( event )
local group = self.view
loadingImage = display.newImageRect(“images/loadingScreen1.png”, 480, 320);
loadingImage.x = 240; loadingImage.y = 160;
group:insert(loadingImage);
pressed = function(e)
if (e.phase == “ended”) then
storyboard.gotoScene(“loadingScreenTwo”);
end
end
loadingImage:addEventListener(“touch”, pressed);
end
function scene:exitScene( event )
local group = self.view
loadingImage:removeEventListener(“touch”, pressed);
end
function scene:destroyScene( event )
local group = self.view
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
–loadingScreenTwo.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local loadingImage2
local pressed
function scene:createScene( event )
local group = self.view
end
function scene:enterScene( event )
local group = self.view
loadingImage2 = display.newImageRect(“images/loadingScreen2.png”, 480, 320);
loadingImage2.x = 240; loadingImage2.y = 160;
group:insert(loadingImage2);
pressed = function(e)
if (e.phase == “ended”) then
storyboard.gotoScene(“loadingScreenOne”);
end
end
loadingImage2:addEventListener(“touch”, pressed);
end
function scene:exitScene( event )
local group = self.view
loadingImage2:removeEventListener(“touch”, pressed);
end
function scene:destroyScene( event )
local group = self.view
end
scene:addEventListener( “createScene”, scene )
scene:addEventListener( “enterScene”, scene )
scene:addEventListener( “exitScene”, scene )
scene:addEventListener( “destroyScene”, scene )
return scene
[import]uid: 126017 topic_id: 28556 reply_id: 328556[/import]