Hi,
I have a main game scene and multiple modules that make up the scene. If I want to create a new button widget in one of the modules, how do I insert it into the game scene? Right now I have game.lua:
local someModule = require("someModule"); ... unction scene:create(event) local sceneGroup = self.view; -- Insert button object from someModule sceneGroup:insert(someModule.someButton); end ...
someModule.lua:
local composer = require("composer"); -- Load scene local widget = require("widget"); -- Used to make buttons local M = {} local function onDoSomething(event) if (event.phase == "began") then end if (event.phase == "ended") then end end M.someButton = widget.newButton({ ... }) return M
Am I doing it right? Is there a better/right way to add a button into a scene from a module?
Thanks!