External modules with event listeners and scene change

Hi guys

I’m trying to make an app in witch the return and home button are loaded via an external module.
But the problem is that when i change scenes the images stay and when im trying to insert in the module a
“storyboard.gotoScene” it gives me an error :confused:

This module thing its a bit complicated :s

Already solved it

I called in the external module storyboard. for e.g.
 

module(…, package.seeall)

local storyboard = require( “storyboard” )

and in the function inside the module i called the “storyboard.gotoScene()”

To erase the images I added the variables that show the image into the self.view

  1. You should be inserting images (and other displayObjects) into your storyboard scene’s view.

    function scene:createScene(event) local group = self.view local img = display.newRect(0,0,128,128) – or anything else from display.* group:insert(img) end 

2, If you call storyboard from within the module, that module must have exposure to storyboard.

-- backbutton.lua local storyboard = require("storyboard") local function myButton() storyboard.gotoScene("elsewhere") end -- Lua files are only loaded into memory once, so you can require them in as many places as you want. 
  1. module(…, package.seeall) method is deprecated and not sure why you want to use it anyway. The best/safe method is to just include in files as you need them.

    – backbutton.lua local function makeBackButton() – code end return makeBackbutton – yes, you can return a function! – myScene.lua local button_back = require(“backbutton”) local button_home = require(“homebutton”) local myBackButton = button_back() 

@richard9 

I didnt know that it was possible to call somethin external without module(…, package.seeall) 
Thanks for the help  :D 

Already solved it

I called in the external module storyboard. for e.g.
 

module(…, package.seeall)

local storyboard = require( “storyboard” )

and in the function inside the module i called the “storyboard.gotoScene()”

To erase the images I added the variables that show the image into the self.view

  1. You should be inserting images (and other displayObjects) into your storyboard scene’s view.

    function scene:createScene(event) local group = self.view local img = display.newRect(0,0,128,128) – or anything else from display.* group:insert(img) end 

2, If you call storyboard from within the module, that module must have exposure to storyboard.

-- backbutton.lua local storyboard = require("storyboard") local function myButton() storyboard.gotoScene("elsewhere") end -- Lua files are only loaded into memory once, so you can require them in as many places as you want. 
  1. module(…, package.seeall) method is deprecated and not sure why you want to use it anyway. The best/safe method is to just include in files as you need them.

    – backbutton.lua local function makeBackButton() – code end return makeBackbutton – yes, you can return a function! – myScene.lua local button_back = require(“backbutton”) local button_home = require(“homebutton”) local myBackButton = button_back() 

@richard9 

I didnt know that it was possible to call somethin external without module(…, package.seeall) 
Thanks for the help  :D