what contains level ?

Hi, i’m trying to understand the composer but there is a thing that i dont understand.

In my case i have a scene with rules on a table (actually my main.lua).
The table (gridGame) is on separated files (level 01, level 02, level03).

The rules is on a variable that i name Gridgame . It could be level01 or level05 because each level is a gridGame.

How do you do to affect the rules to the correct level ?
Level is just the description of the level or level contain the description and the rules ?

What it help me is just a short example of a basic game with the structure of each files with the composer…but it´s hard to find…

nobody ?

The composer example in corona’s sample code itself answers a lot of your questions.

Also, there are tons of tutorials available online. You have heard of google i assume. You could answer all your questions by doing some googling, as everything you are asking has been answered time and time again…

Corona’s blog alone answers most of the questions you ask here, their composer and modules tutorials are what you should be looking at.

after spending 2-3 hours searching on this topic … I can not tell you that google does not answer my question 

http://lmgtfy.com/?q=corona+composer+level+grid+template

every time there is not the equivalent of what I want. 

all scenes include their board rules, there is not a special file that contains the rules and apply them on each level.

I’m building a game right now that has a single scene:  game.lua that plays the game.  I have all of my level specific data in a file called leveldata.lua.  Here is an example of my leveldata.lua:

local level = {} level[1] = {} level[1].name = "Day" level[1].wallHealth = 10 level[1].reactorHealth = 10 level[1].additionalSpeed = 0 level[1].maximumSpawnSpeed = 1600 level[1].minimumSpawnSpeed = 1000 level[1].maxCreeps = 10 level[1].turretUpgradeAmount = 10 level[1].maxTurretType = 4 level[1].initialEnergy = 10 level[1].background = "images/level1background.png" level[1].spawnPattern = { 1, 1, 1, 0, 0, 0, 2, 2, 2, 2, 0, 0, 3, 3, 3, 3, 3 } level[1].waves = 1   level[2] = {} level[2].name = "Night" level[2].wallHealth = 10 level[2].reactorHealth = 10 ...

In my game.lua I do a:

local levelData = require( "leveldata" )

I also have a variable I keep in my global data table:

local myData = require( "mydata" )

Then to reference my level data as needed, for instance in my scene:create() function:

      local background = display.newImageRect( levelData[myData.currentLevel].background, 570, 360 )       sceneGroup:insert( background )

Thanks a lot Rob it helps me a lot :) 

Now i understand clearlier the process.

I didn’t think putting all my levels only in a file. it’s really easier.

have a nice evening ;)  

I was not talking about that. Your questions boiled down to: “how do i use external modules” and “how to use external modules with composer”. Those two questions have been covered extensively by Corona.

Your specific need is only a slight extension on the two aforementioned topics, that of which tutorials exist in droves. If you read those tutorials then you would have already had your answer.

Also you accepted Rob’s answer, but people had already given the same advice in this thread, but you chose to ignore it.

Also another part of the problem is the effort that goes into explaining your problem. Most of your posts are incoherent and extremely hard to decipher what you are asking, whilst others are not (like your reply to me) which would tell me that you want us to do all the work for you.

If English is not your primary language that is fine, but it appears as though you know enough English to get by, when you want to put the effort in to explain yourself.

Hi Espace3d,

While I like to help out, I do agree with Euphoria that a lot of the answers you needed where out there. The trick, especially at first, is not to look for solutions that fit your problem for the full hundred percent: while you’re looking at the thousands of forum posts you won’t find complete solutions, but you will learn a lot of things that you will probably run into later on, so you’re gaining a lot of knowledge without realising it.

Hello both,
 

You know it is sometimes difficult for a beginner to grasp the multitude of information and sometimes we are a bit lost …

In doing further research, I found a great site for all beginners like me and just about everything is very well described. If it helps.

it must be inside the corona site

http://goodrecommendations.net/2014/3/26/corona-sdk-resources.aspx

Trust me - I was exactly the same way!!! It’s perfectly normal. But I wanted to let you know that the stuff you pick along the way, while not immediately finding instant solutions, will help you out later along the way. The more you learn about Corona and Lua, the better you’ll be able to find the right words for your search terms. At a certain point you can find just about anything you want to learn, and things become a lot more fun!

Keep it up!

t

One of the things I think is very important for people learning to program is to take the time and work up from small things until you understand how things work.  Most programming classes at the college level take around 15 weeks to complete and the students learn one or two concepts a week.  By the end of the class, they can write a more complex program.  But depending on the complexity of what you’re trying to build with Corona (and it sounds like you’re trying to build something with some complexity), students in college may go through a dozen of these programming classes over a couple of years to build up the knowledge needed to put a complex concept together.

This is equally important when teaching yourself.  You won’t find a magic complete answer.  You can find similar, but at the end, you have to apply your gained knowledge to adapt something close to get it to what your end vision is.  Programming isn’t something that can be handed to you, change a couple of things and go.  Knowing how you got there is just as important.

Rob

Hello Rob, 

Also thank you for the advice. I really learned a lot lately even though my questions may seem stupid. 

In fact I only programmed functions that I would never be believed capable of achieving. In fact it is very simple sometimes rereading my code, I think how I planned it … 

My game is now quite playable on one level, I thought 95% of its progress but the level design, the online, score halved, the splash screen … I am 50%! it’s exciting and depressing at the same time. 

It is clear that by simplifying the max it allows us to understand these mistakes and move forward. the rub is when entering a new material, it is a bit helpless. 

Anyway thank you all for your valuable advice.

@espace: glad to hear it. I wasn’t trying to personally attack you, just trying to show you the different ways in going about finding a solution.

Best of luck with your game :slight_smile:

Just my 2 cents, but I have to agree with espace3d that there’s really nothing out there besides the core docs on how to actually USE composer.  I’m working on an app and I’m getting it working, but almost everything I have is in the “scene(create)” area.  I’m not sure how to actually use any of the others at the moment.  Most of the advice I’ve received is “go look at the docs and there ya go,” “go learn the storyboard tutorials and then see #1”, or “go look at the sample in the simulator,” which for someone coming in fairly new with all this, really doesn’t help much.  I’m going to post something to the Corona Geek section in just a bit, but it’d be incredibly, tremendously helpful if there was a video or something that would actually go through a rundown on how to USE composer (you can find videos if you google for that, but they’re for the WIZIWIG software called composer).

That said, euphoriacorona is right that there’s TONS of info online on how to use modules.  Just a bit of googling is your friend sometimes.

hi,

To help the beginners like me i post the response to my initial question. In this short example i use a external module (level.lua) to show different background (red and green that interact with a character (circle) ) and i use the composer to switch to a scene that require the external module.

I have found the solution by two way on github trough an  example with the composer

https://github.com/GameAnalytics/GA-Corona-SDK-examples/tree/master/SampleCode/Composer

and trough the corona simulator wich allow to create at the beginning a multiscene example (it’s was so simple)

--main lua local composer = require( "composer" ) local levelFunctions = require( "level" ) composer.gotoScene( "scene1" )

--level.lua local levelFunctions = {}; levelFunctions[1] = function() background = display.newRect( 0, 0, 320, 480 ) background:setFillColor( 1, 0, 0 ) background.x=160 background.y=240 return background end levelFunctions[2] = function() background = display.newRect( 0, 0, 320, 480 ) background:setFillColor( 0, 1, 0 ) background.x=160 background.y=240 return background end return levelFunctions

--scene1.lua local sceneName = essai local composer = require( "composer" ) local levelFunctions = require( "level" ) local scene = composer.newScene( sceneName ) function scene:create( event )     local sceneGroup = self.view levelFunctions[1]() --red background local function listener( event ) display.remove( background ) end timer.performWithDelay( 1000, listener ) levelFunctions[2]() --green background local character =  display.newCircle( 100, 100, 30 ) background.touch = function( event )         if event.phase == "began" then transition.to( character, {time=10, x=event.x, y=event.y} )         end end Runtime:addEventListener( "touch", background.touch) end --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) return scene