Is your question “how can i go to a specific lua file via a level selector” ?
There are countless ways of doing this, however I will provide an example using the director class :
[code]
function new()
local localGroup = display.newGroup()
local function goToLevel(event)
local target = event.target
director:changeScene(target.scene, “fade”)
localGroup:removeSelf()
localGroup = nil
return true
end
local levels = {}
–Add two level images to the level table
levels[1] = display.newImage(“level1.png”)
levels[1].scene = “level1” --Assign the level button a level name (with the .lua ommitted)
localGroup:insert(levels[1])
levels[2] = display.newImage(“level2.png”)
levels[2].scene = “level2” --Assign the level button a level name (with the .lua ommitted)
localGroup:insert(levels[2])
–Add event listeners for all level buttons
for i = 1, #levels do
levels[i]:addEventListener(“touch”, goToLevel)
end
return localGroup
end
[/code] [import]uid: 84637 topic_id: 14205 reply_id: 52359[/import]