I have 2 scenes, gameScene and endingOverlay. In my endingOverlay, I want to call a newGame() function from gameScene. How do I do that?
I tried this in endingOverlay, but it doesn’t work
local newGameF = require("gameScene") newGameF.newGame()
I have 2 scenes, gameScene and endingOverlay. In my endingOverlay, I want to call a newGame() function from gameScene. How do I do that?
I tried this in endingOverlay, but it doesn’t work
local newGameF = require("gameScene") newGameF.newGame()
Try
endingOverlay.lua ... composer.hideOverlay ("fade", 200) ... function scene:hide(event) local parent = event.parent local phase = event.phase if phase == "will" then parent:newGame() -- or use composer.getScene("gameScene"):newGame() if gameScene scene is not your previous scene end end ... gameScene.lua ... local scene = composer.newScene() ... function scene:newGame() ... end ...
Alright that seems to work. I think there’s something wrong in my newGame() code, it returns attempt to index field a nil value. But that’s a different story. Thanks
Try
endingOverlay.lua ... composer.hideOverlay ("fade", 200) ... function scene:hide(event) local parent = event.parent local phase = event.phase if phase == "will" then parent:newGame() -- or use composer.getScene("gameScene"):newGame() if gameScene scene is not your previous scene end end ... gameScene.lua ... local scene = composer.newScene() ... function scene:newGame() ... end ...
Alright that seems to work. I think there’s something wrong in my newGame() code, it returns attempt to index field a nil value. But that’s a different story. Thanks