how to switch levels with buttons

how can i switch levels using buttons example like when i click on button 5 the level 5 map will load up [import]uid: 108692 topic_id: 18673 reply_id: 318673[/import]

del [import]uid: 16142 topic_id: 18673 reply_id: 71726[/import]

You will probably want to look into Director to make a level selection screen and then ui.lua for your buttons.

This will help too - http://justaddli.me/tutorial.php?t=0&id=19 - and the viewer app that is included in the Lime folder. [import]uid: 5833 topic_id: 18673 reply_id: 71730[/import]

Also, as a subscriber you’ll have access to our Storyboard API that helps with managing and transitioning between scenes.

There’s also a ‘Storyboard’ sample included in the Daily Build download that demonstrates how to switch scenes through a touch event (would be the same as doing it with a button).

More info here:
http://blog.anscamobile.com/2011/11/introducing-the-storyboard-api/ [import]uid: 52430 topic_id: 18673 reply_id: 71796[/import]

I Would definitely recommend you Director Class over the new Storyboard API to change levels is very simple, with Director once you learn to use it and you can even change levels using Touch or Tap event not needing ui.lua but if you know how to use ui.lua take that route is more efficient.

Here is a mockup explanation of how I do it using Director Class:
LevelSelect.lua - Layout your levels in images / numbers / whatever you want base on your game then create a function to take you to the level.lua file and give your image an event listener. If you are confused Here is a quick sample.

Create a level1.lua (Thats your first level)
Create a LevelSelect.lua (all your levels go here for you to select)
In LevelSelect.lua once you created the images you will use to take you to your level write this down:
Note:If you never used Director look into it is fairly easy and this will make much more sense and you can play with the code to create more effects when changing scenes. This is just a quick simple way! Dont get me wrong the new Storyboard API its ok but its fairly new and anythings thats new doesnt always work well :wink:
[lua]local function GoToLevel1(event)
if(event.phase == “ended”)then
director:changeScene(“level1”, “none”)
end
end

ImageLevel:addEventListener(“touch”, GoToLevel1) [import]uid: 30314 topic_id: 18673 reply_id: 71829[/import]