New Scene

I am trying to click a rectangle and have it go to a new scene, when I click I get the error main.lua:22: attempt to index global ‘composer’ (a nil value) stack traceback: main.lua:22: in function <main.lua:21>?: in function <?:221>

my code is: local function tappedRect(event)

composer.gotoScene(“levels”)

end

local playrect = display.newRect(320,400,400,100)

playrect:setFillColor(255,255,0)

playrect.strokeWidth = 8

local playtext = display.newText(“PLAY!”,320,400, “Consolas”, 95)

playtext:setFillColor(0,0,0)

local instructionsrect = display.newRect(320,800,400,100)

instructionsrect:setFillColor(255,255,0)

instructionsrect.strokeWidth = 8

local howtoplaytext = display.newText(“HOW TO PLAY”,320,800, “Consolas”, 60)

howtoplaytext:setFillColor(0,0,0)

playrect:addEventListener (“tap”, tappedRect)

if anybody knows what i could do with my code to make it go to a new scene that would be very helpful thanks!!

do you have this at the top of your file?

local composer = require "composer"

yes

is there anything else that you could suggest?

Without seeing all your all the code, have you setup the composer  create, show, hide and destroy events.

http://docs.coronalabs.com/api/library/composer/index.html

Also I notice you are missing the options parameter —  composer.gotoScene( sceneName [, options] )

that is probably the problem. If im trying to do the new scene what do i put in the options?

i put in fade as the option and I got the error:

?:0: attmpt to concatenate clobal  ‘sceneName’ (a nil value) stack traceback:

?: in function ‘gotoScene’

main.lua:24: in function <main.lua:23>

?: in function <:221>

Its all here http://docs.coronalabs.com/api/library/composer/gotoScene.html

I followed that and am still getting the same error. Is there anything else you coudl suggest… thanks for the help!

is the scene levels setup correctly as above.

It think I set it up right… could you take a look at my code i put all of it:

local composer = require( “composer” )

local scene = composer.newScene()

display.setStatusBar( display.HiddenStatusBar )

local background = display.newRect(450,600,900,4825)

local alvaball = display.newText(“ALVABALL”, 325, 100, “Consolas”, 140)

alvaball:setFillColor(0,0,0)

local lineone = display.newRect(400,200,900,100)

lineone:setFillColor(0,0,0)

local linetwo = display.newRect(400,400,900,100)

linetwo:setFillColor(0,0,0)

local linethree = display.newRect(400,600,900,100)

linethree:setFillColor(0,0,0)

local linefour = display.newRect(400,800,900,100)

linefour:setFillColor(0,0,0)

local linefive = display.newRect(400,1000,900,100)

linefive:setFillColor(0,0,0)

local playrect = display.newRect(320,400,400,100)

playrect:setFillColor(255,255,0)

playrect.strokeWidth = 8

local function touchedRect(event)

end

function scene:create( event )

    local sceneGroup = self.view

local newimage = display.newImage(“thing.jpeg”)

end

local playtext = display.newText(“PLAY!”,320,400, “Consolas”, 95)

playtext:setFillColor(0,0,0)

local instructionsrect = display.newRect(320,800,400,100)

instructionsrect:setFillColor(255,255,0)

instructionsrect.strokeWidth = 8

local howtoplaytext = display.newText(“HOW TO PLAY”,320,800, “Consolas”, 60)

howtoplaytext:setFillColor(0,0,0)

touchedRect:addEventListener(“tap”, fade)

Hi

you need to a return scene end of file.

also the fade options goes on your gotoScene

[lua]

local composer = require( “composer” )

local scene = composer.newScene()

display.setStatusBar( display.HiddenStatusBar )

local background = display.newRect(450,600,900,4825)

local alvaball = display.newText(“ALVABALL”, 325, 100, “Consolas”, 140)

alvaball:setFillColor(0,0,0)

local lineone = display.newRect(400,200,900,100)

lineone:setFillColor(0,0,0)

local linetwo = display.newRect(400,400,900,100)

linetwo:setFillColor(0,0,0)

local linethree = display.newRect(400,600,900,100)

linethree:setFillColor(0,0,0)

local linefour = display.newRect(400,800,900,100)

linefour:setFillColor(0,0,0)

local linefive = display.newRect(400,1000,900,100)

linefive:setFillColor(0,0,0)

local playrect = display.newRect(320,400,400,100)

playrect:setFillColor(255,255,0)

playrect.strokeWidth = 8

function scene:create( event )

    local sceneGroup = self.view

local newimage = display.newImage(“icon.png”)

 local playtext = display.newText(“PLAY!”,320,400, “Consolas”, 95)

playtext:setFillColor(0,0,0)

local instructionsrect = display.newRect(320,800,400,100)

instructionsrect:setFillColor(255,255,0)

instructionsrect.strokeWidth = 8

local howtoplaytext = display.newText(“HOW TO PLAY”,320,800, “Consolas”, 60)

howtoplaytext:setFillColor(0,0,0)

touchedRect:addEventListener(“tap”, touchedRect)

local function touchedRect(event)

composer.gotoScene(“levels”, “fade”)

end

end

 return scene

[/lua]

wait no it doesnt when I put this in it comes up with the black lines and one yellow square that doesnt click

do you have this at the top of your file?

local composer = require "composer"

yes

is there anything else that you could suggest?

Without seeing all your all the code, have you setup the composer  create, show, hide and destroy events.

http://docs.coronalabs.com/api/library/composer/index.html

Also I notice you are missing the options parameter —  composer.gotoScene( sceneName [, options] )

that is probably the problem. If im trying to do the new scene what do i put in the options?

i put in fade as the option and I got the error:

?:0: attmpt to concatenate clobal  ‘sceneName’ (a nil value) stack traceback:

?: in function ‘gotoScene’

main.lua:24: in function <main.lua:23>

?: in function <:221>

Its all here http://docs.coronalabs.com/api/library/composer/gotoScene.html