I asked this question at the bottom of Rob Miracle’s Tutorial: Building a level Selection Scene but I then I realized it would be more appropriate to ask the question in the forum.
The tutorial builds level select buttons using widgets (see code below). I would like to substitute the word “game” for “level1” or “level2” based on the widget button pressed. I’ve tried several things. My goal is if level button 1 is pressed it would go to level1.lua or level2.lua etc…
The article is located at: http://coronalabs.com/blog/2014/08/12/tutorial-building-a-level-selection-scene/
– Button handler to go to the selected level
local function handleLevelSelect( event )
if ( “ended” == event.phase ) then
– ‘event.target’ is the button and ‘.id’ is a number indicating which level to go to.
– The ‘game’ scene will use this setting to determine which level to load.
– This could be done via passed parameters as well.
myData.settings.currentLevel = event.target.id
– Purge the game scene so we have a fresh start
composer.removeScene( “game”, false )
– Go to the game scene
composer.gotoScene( “game”, { effect=“crossFade”, time=333 } ) end end
I’m new to coding so I apologize for my lack of knowledge.
Thanks,
Lori