I have 2 files
– main.lua
–extraStuff.lua
Normally I insert an object into a group.
when I go to another scene (in storyboard) the object is gone.
line1 = display.newRect( 0, 0, 40, 5) group:insert(line1) -- Right Here line1.x = centerX line1.y = centerY
this in main.lua
now, let’s say I have many objects and lines…
so I put all of those inside a function
– function myNewFunction ( )
line1 = display.newRect( 0, 0, 40, 5)
group:insert(line1) – In this file extraStuff.lua the “group” it doesn’t exist
line1.x = centerX
line1.y = centerY
end
and I have this new function placed in another file.lua – let’s say extraStuff.lua
now, in my createScene of my app – in main.lua – I have created a group
– local group = self.view
if I want to use all of the stuff I have in myNewFunction
I just “require” the .lua file (extraStuff.lua) in main.lua
–local extraStuff = require( “extraStuff” ) – so main.lua knows about it
and in my createScene, in main.lua
instead of typing all the lines and images and code of myNewFunction
I just call the function
– myNewFunction ( )
and PROBLEM –
is telling me that it can not find the “group”
because the “group” is created in main.lua, not in extraStuff.lua
and if I do it like this
function myNewFunction ( ) line1 = display.newRect( 0, 0, 40, 5) line1.x = centerX line1.y = centerY end
it works, but they are not inserted into a group
so how do I get ride of all the images in main.lua
I hope you can understand it, I try my best to explain the problem
thanks for all your help