Created
July 26, 2015 04:53
-
-
Save ggcrunchy/e38a57b80886fb1ed63b to your computer and use it in GitHub Desktop.
Demonstrates an issue with removeSelf as a validity test
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 widget = require("widget") -- Not used in this Gist, but seems to be necessary | |
local composer = require("composer") | |
composer.gotoScene("test_scene") |
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 composer = require("composer") | |
local Scene = composer.newScene() | |
-- | |
function Scene:create (event) | |
end | |
Scene:addEventListener("create") | |
-- | |
function Scene:show (event) | |
if event.phase == "did" then | |
self.group = display.newGroup() | |
self.view:insert(self.group) | |
timer.performWithDelay(30, function(event) | |
if self.group.removeSelf == nil then | |
print("GONE!") | |
timer.cancel(event.source) | |
return | |
end | |
for i = 1, self.group.numChildren do | |
-- | |
end | |
end, 0) | |
timer.performWithDelay(2000, function() | |
composer.gotoScene("test_scene2") | |
end) | |
end | |
end | |
Scene:addEventListener("show") | |
-- | |
function Scene:hide (event) | |
if event.phase == "did" then | |
self.group:removeSelf() | |
end | |
end | |
Scene:addEventListener("hide") | |
return Scene |
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 composer = require("composer") | |
local Scene = composer.newScene() | |
-- | |
function Scene:create (event) | |
end | |
Scene:addEventListener("create") | |
-- | |
function Scene:show (event) | |
if event.phase == "did" then | |
end | |
end | |
Scene:addEventListener("show") | |
-- | |
function Scene:hide (event) | |
if event.phase == "did" then | |
end | |
end | |
Scene:addEventListener("hide") | |
return Scene |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment