Switching Levels

Hello! Sorry for the amateur question, but we are trying to figure out how to switch levels in our game. In the first level, there are three stars to catch, and we have successfully created a variable and text to track how many stars have been caught. We cannot, however, figure out how to change the scene once all three stars have been caught. Here is what we tried:

function nextLevel( event )
if starsCaught == “3” then
director:changeScene( “loadlevel2” )
end
end

Runtime:addEventListener( “enterFrame”, nextLevel )

This doesn’t seem to do anything… What should we do? Any help would be greatly appreciated!

Thanks a lot!

MP Games Inc. [import]uid: 37588 topic_id: 6813 reply_id: 306813[/import]

If your variable to count the stars caught is an integer and not a string that isn’t going to work.

Try this :

function nextLevel( event )
if starsCaught == 3 then
director:changeScene( “loadlevel2” )
end
end

Runtime:addEventListener( “enterFrame”, nextLevel )
And of course, loadlevel2 has to have its own .lua file ie : loadlevel2.lua [import]uid: 6981 topic_id: 6813 reply_id: 23904[/import]

Thanks so much! Finally got it working! [import]uid: 37588 topic_id: 6813 reply_id: 24105[/import]