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.

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

Thanks so much! Finally got it working!

views:1653 update:2011/10/13 9:25:17
corona forums © 2003-2011