Created
August 21, 2012 11:28
-
-
Save anonymous/3414734 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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