How do i access group object of external class from main.lua?
I have googling around but can’t find much about corona display.group object…
Let’s say this is world.lua
[lua]
local world = {}
function world.new()
local worldGroup = display.newGroup()
local sky = display.newImageRect( “sky.png”, 480,360 )
sky:setReferencePoint( display.TopLeftReferencePoint )
sky.x = 0; sky.y = 0
worldGroup:insert(sky)
local ground = display.newImageRect( “ground.png”, 480,360 )
ground:setReferencePoint( display.TopLeftReferencePoint )
ground.x = 0; ground.y = 0
worldGroup:insert(ground)
return worldGroup
end
function world.move()
– I’m trying to scroll sky and ground from new() above. And this function will be called
– from main.lua
– How do i do this ?
end
return world
[/lua]
And this is main.lua
[lua]
local World = require “world”
local thisWorld = World.new()
Runtime:addEventListener( “enterFrame”, World.move)
[/lua]
My idea is calling World.move() to scroll thisWorld in main.lua.
Or i have wrong concept and need to alter those 2 files above?
Feel free to correct me. Thanks in advance…
