Hello,
Here is a stupid? question:
I’ve got 4 files: mail.lua, menu.lua, scene.lua and the_module.lua
In the the_module.lua one I display an image and I want to “unload” that image when I change scene.
Here is the code:
main.lua
widget = require( "widget" )
storyboard = require "storyboard"
\_W,\_H = display.contentWidth,display.contentHeight
storyboard.gotoScene( "menu" )
menu.lua
local menuScene = storyboard.newScene()
function menuScene:createScene( event )
local group = self.view
local myText = display.newText("Welcome to the menu scene!",0,0,native.systemFont,26)
myText.x = \_W/2
myText.y = 100
local function playF()
storyboard.gotoScene( "scene" )
end
local playBtn = widget.newButton{
id = "play",
left = 0,
top = 0,
width = 150, height = 100,
label = "Play",
onRelease = playF,
}
playBtn.x = \_W/2
playBtn.y = \_H/2
group:insert(myText)
group:insert(playBtn)
end
function menuScene:enterScene( event )
local group = self.view
end
function menuScene:exitScene( event )
local group = self.view
end
function menuScene:destroyScene( event )
local group = self.view
end
menuScene:addEventListener( "createScene", menuScene )
menuScene:addEventListener( "enterScene", menuScene )
menuScene:addEventListener( "exitScene", menuScene )
menuScene:addEventListener( "destroyScene", menuScene )
return menuScene
scene.lua
local theModule
local myScene = storyboard.newScene()
function myScene:createScene( event )
local group = self.view
theModule = require "the\_module"
local bg = display.newRect(0,0,\_W,\_H)
bg:setFillColor(255,255,255)
local myText = display.newText("Welcome to my scene!",0,0,native.systemFont,26)
myText:setTextColor(0,0,0)
myText.x = \_W/2
myText.y = 100
local function backF()
storyboard.gotoScene( "menu" )
end
local backBtn = widget.newButton{
id = "back",
left = 0,
top = 0,
width = 150, height = 100,
label = "Go back",
onRelease = backF,
}
backBtn.x = \_W/2
backBtn.y = \_H/2
group:insert(bg)
group:insert(myText)
group:insert(backBtn)
end
function myScene:enterScene( event )
local group = self.view
end
function myScene:exitScene( event )
local group = self.view
theModule.objGroup:removeSelf()
theModule.objGroup=nil
end
function myScene:destroyScene( event )
local group = self.view
end
myScene:addEventListener( "createScene", myScene )
myScene:addEventListener( "enterScene", myScene )
myScene:addEventListener( "exitScene", myScene )
myScene:addEventListener( "destroyScene", myScene )
return myScene
And, at last, the_modle.lua
local public = {}
local objGroup = display.newGroup()
local img = display.newImageRect( "ilustracion\_contadorpuntos\_x\_normal.png", 195, 93 )
img.x = \_W/2
img.y = \_H/2 - 100
objGroup:insert(img)
public.objGroup = objGroup
return public
Anybody knows what am I doing wrong?
How can I “unload” the img?
Thanks in advance! [import]uid: 44013 topic_id: 31605 reply_id: 331605[/import]