Hi there. I have something to ask about deallocation. Before the questions, let’s take a look at two files:
- first of them - showandanim.lua
module(..., package.seeall);
function showAndAnim(x, y)
local grp = display.newGroup();
local img = display.newImage(grp, "star.png");
img.alpha = 0;
local twn;
function grp:fadeIn()
local function fadeOut()
twn = transition.to(img, {time = 500, alpha = 0.3, onComplete = fadeIn};
end;
twn = transition.to(img, {time = 500, alpha = 0.7, onComplete = fadeOut};
end;
return grp;
end;
- second one - scene01.lua - a director scene
module(..., package.seeall);
function new()
local SaA = require("showandanim");
local tmr;
local grpScene01 = display.newGroup();
local grpShowAndAnim = SaA.showAndAnim(
display.contentWidth / 2, display.contentHeight / 2);
grpScene01:insert(grpShowAndAnim);
grpShowAndAnim:fadeIn();
trm = timer.performWithDelay(5000, function() director::changeScene("scene02"); end, 1);
function unloadMe()
if (trm) then timer.cancel(trm); trm = nil; end;
end;
return grpScene01;
end;
As I could see, when the director loads the scene02, it free the grpScene01 and its childrens, in this example grpShowAndAnim.
My question is: what happens to img and twn (in showandanim.lua) and SaA (in scene01.lua)? I have to deallocate them?
I’m really confused about this scenario. Please, someone could help-me?
[import]uid: 50425 topic_id: 9698 reply_id: 309698[/import]