Question about "composer"

Hello,
I do not understand the Corona-docs about the composer.
I’m creating a quiz APP for my friends to pratice, but, in the part to click on the “next” to jump to “main.lua” to dom001.lua" and select a option on “dom001.lua” to go to “dom002.lua” I’m stuck.
I have a brain trouble who learn on a pratice example and the docs have only abstract examples.
Unfortunately I don’t find videos who have actual examples, just old and obsolete examples.

Sorry my English, this is not my native language.

Hola amigo!
Would be better if you showed what code you’re using.
Without seeing your code, my first guess is that you’re passing the file name as “dom001.lua” in the composer.gotoScene() when it should be “dom001” without the .lua file extension.

1 Like

Have you tried looking at samples? When you launch the simulator, you’ll find a “Samples” link below. You can find a Composer sample there.

Anyway, here is a sample project I put together for you. Hopefully, this one is a bit better for you to understand.

quiz.zip (1.9 KB)

1 Like

I censored 'cause the original have some bad words
:stuck_out_tongue:

I can’t upload.
I’ll put the code here and edit to use “circles” instead the jpg files.

"""“MAIN.LUA”"""
local linha1 = display.newText(“Teste Dom”, display.contentCenterX, 120, native.systemFont, 150)
local buttonNext = display.newCircle(0, 0, 70)
buttonNext:setFillColor(1, 0, 0)
buttonNext.x = display.contentCenterX
buttonNext.y = display.contentHeight -85

"""“DOM001.LUA”"""

local txt = display.newText(“bla bla bla bla”,
display.contentCenterX, 300, native.systemFont, 120)

local circle1 = display.newCircle(0, 0, 30)
circle1:setFillColor(1, 0, 0)
circle1.x = display.contentCenterX -120
circle1.y = display.contentHeight -50

local circle2 = display.newCircle(0, 0, 30)
circle2:setFillColor(0, 1, 0)
circle2.x = display.contentCenterX -40
circle2.y = display.contentHeight -50

local circle3 = display.newCircle(0, 0, 30)
circle3:setFillColor(0, 0, 1)
circle3.x = display.contentCenterX +40
circle3.y = display.contentHeight -50

local circle4 = display.newCircle(0, 0, 30)
circle4:setFillColor(0, 200/255, 200/255)
circle4.x = display.contentCenterX +120
circle4.y = display.contentHeight -50

local function click1()
display.remove(txt2)
display.remove(txt3)
display.remove(txt4)
txt1 = display.newText(“bla bla 1”, display.contentCenterX, 500, native.systemFont, 40)
end
circle1:addEventListener(“tap”, click1)
local function click2()
display.remove(txt1)
display.remove(txt3)
display.remove(txt4)

txt2 = display.newText(“bla bla 2”, display.contentCenterX, 500, native.systemFont, 40)
end
circle2:addEventListener(“tap”, click2)

local function click3()
display.remove(txt1)
display.remove(txt2)
display.remove(txt4)
txt3 = display.newText(“bla bla 3”, display.contentCenterX, 500, native.systemFont, 40)
end
circle3:addEventListener(“tap”, click3)

local function click4()
display.remove(txt1)
display.remove(txt3)
display.remove(txt2)
txt4 = display.newText(“bla bla 4”, display.contentCenterX, 500, native.systemFont, 40)
end
circle4:addEventListener(“tap”, click4)


PS: I don’t know what happend, I have to re edit the size and position of everything, the design looks good yesterday

Oh…
I dint notice that.
I’ll see you code on the morning (is after 0:00 now, only after this hour I can navigate into the web).
Tkx

I was expecting to see the code used to transition from one scene to the other. :slightly_smiling_face:

You should be good if you follow bgmadclown’s sample project.

EDIT:
One thing to note as you’ll see in the sample code, use main.lua only to setup your project (if anything is needed) and use it just to load the first composer scene. You’ll then transition from one scene to another but never back to main.lua.

1 Like

By just opening the Solar2D Simulator and choosing “New Project”, you can choose out of several project templates that use Composer in different ways.

1 Like

Yeah, I’ll use the bgmadclown’s sample, I just put my code to not let you without answer.
Tkx.
:slight_smile:

Edit:
I’ll do on home and ask if I learn to do.
I’m in a client house doing a maintenance on his PC (he have wifi).