Skip to content

Instantly share code, notes, and snippets.

Created August 21, 2012 11:28
Show Gist options
  • Save anonymous/3414734 to your computer and use it in GitHub Desktop.
Save anonymous/3414734 to your computer and use it in GitHub Desktop.
local scene = display.newGroup();
local target;
local groupBox = display.newGroup();
function init(data)
addGroups();
addBox();
target = data.target;
return scene;
end
function addGroups()
scene:insert(groupBox)
end
function addBox()
local box = display.newRect(groupBox, 0,0,display.contentWidth, display.contentHeight);
box:setFillColor(0,0,255);
box.alpha = 0.5;
box:addEventListener("tap", changeSceneEvent)
end
function changeSceneEvent(event)
print(target);
changeScene(target, {target='green'})
end
return init;
DISPLAY = display.newGroup();
function changeScene(sceneFile, data)
local mainScene = require(sceneFile); -- Returns init
for i=1, DISPLAY.numChildren do
for p=1, DISPLAY[i].numChildren do
DISPLAY[i][p]:removeSelf();
end
DISPLAY[i]:removeSelf();
end
DISPLAY = display.newGroup();
local newScene = mainScene(data); -- Returns scene
print(newScene);
DISPLAY:insert( newScene );
end
changeScene('red', {target = "green"});
local scene = display.newGroup();
local target;
local groupBox = display.newGroup();
function init(data)
addGroups();
addBox();
target = data.target;
return scene;
end
function addGroups()
scene:insert(groupBox)
end
function addBox()
local box = display.newRect(groupBox, 0,0,display.contentWidth, display.contentHeight);
box:setFillColor(255,0,0);
box.alpha = 0.5;
box:addEventListener("tap", changeSceneEvent)
end
function changeSceneEvent(event)
print(target);
changeScene(target, {target='red'})
end
return init;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment