How to switch levels?

Ok, so I’ve been reading up on all kinds of stuff for creating a game for Corona. And I’ve been watching tutorials on creating levels, and once you place all the objects on the level you wish, you copy the code. But say, I have my character walk through a door, and I want it to go to the next level?

How would I go about switching from Level 1 (totally different scenery), to level 2? And mind you, I’ve taken the time all day today to research, investigate, look at tutorials, videos, written tutorials, and downloadable .pdf tutorials here, and other sites, and still haven’t gotten any answers.

If you could put me in the right direction, that’d be awesome! Thanks guys (and gals… I just say guys always). [import]uid: 19768 topic_id: 5184 reply_id: 305184[/import]

Hi EvilSniperXV

Sounds like you need to switch from reading to doing :wink:
Try out some of the wonderful user-contributed game frameworks in the Code Exchange: http://developer.anscamobile.com/category/type/game-logic
[import]uid: 6787 topic_id: 5184 reply_id: 17198[/import]

Haha I will get right on that once I get Corona and a Mac. Thanks for answering my question so quickly.

However, I have two more questions. I’ve heard that before you decide to publish an application that you make through corona, you have to buy the standard edition license or what not.

Is this true? And if it is, why do you spam that it is a free software to download and use?

Thanks :slight_smile: [import]uid: 19768 topic_id: 5184 reply_id: 17201[/import]

It is free to download, run the simulator and install on your own device. You just can’t sell it on the App Store. [import]uid: 6787 topic_id: 5184 reply_id: 17210[/import]

Try out some of the wonderful user-contributed game frameworks in the Code Exchange:

That reminds me, I’ve been meaning to put the sample framework I wrote onto Code Exchange but I still haven’t gotten around to it:

http://developer.anscamobile.com/forum/2010/12/31/object-oriented-sample-game-framework-corona [import]uid: 12108 topic_id: 5184 reply_id: 17248[/import]

Oh wow, I read your post and your thing makes perfect sense. Can’t download it to read it ty’ll I get the mac, but I understand what you mean. All the files are .lua files, and yet they link back to the main.lua. The main is like the menu, and each level has it’s own "how to play, position, physics, and image functions! It all makes sense. And that way, you link it back to main.lua. From there say I could scroll through the levels and select, which would re-direct the app to the file of that certain level, and the code in that level would know what to do. That’s a great idea! Thanks Jhocking! [import]uid: 19768 topic_id: 5184 reply_id: 17369[/import]

That’s a pretty good summation of how it works, although you missed a very key concept about sharing code. The levels are each different .lua files, but they each share code from a master level.lua (the programming term for this is “inheritance.”)
Most levels do the same thing and only differ in where stuff is placed, so copying the same code over and over would be wasteful. Each level has it’s own code for laying out all the graphics and enemies and what not, but the code for how the player controls the game and how the enemies behave doesn’t change each level; that unchanging code can be written just once in one place and then shared with all the other modules that link to it.

Incidentally, a lot of people use the Director class that’s linked in Resources. Conceptually it’s very similar to what I wrote, but different in the details of how it’s implemented. [import]uid: 12108 topic_id: 5184 reply_id: 17408[/import]

Yea I understand. Personally I tried watching all those videos from the creator of Director’s Class and all that stuff, and was confused. Yours is way more basic. So how would I point to the “gameplay functionality” of each level on the main file? Do I just put like a “redirect.main.lua” code or something like that or what? Cause if it’s that simple, man it’s gonna be easy for multiple level formations, just hard for changing up the coding on how it operates. [import]uid: 19768 topic_id: 5184 reply_id: 17418[/import]