add event listener error

hi i need help with this

----------------------------------------------------------------------------------------- -- -- menu.lua -- ----------------------------------------------------------------------------------------- local composer = require( "composer" ) local scene = composer.newScene() local scene = composer.newScene() local inMobi = require( "plugin.inMobi" ) local musicTrack -------------------------------------------- -- forward declarations and other locals local function gotoGame() composer.gotoScene( "game", { time=700, effect="crossFade" } ) end local function gotoHighScores() composer.gotoScene( "highscores", { time=700, effect="crossFade" } ) end local function gotoHelp() composer.gotoScene( "help", {time=714, effect="crossFade" } ) end function scene:create( event ) local sceneGroup = self.view -- Called when the scene's view does not exist. -- -- INSERT code here to initialize the scene -- e.g. add display objects to 'sceneGroup', add touch listeners, etc. -- display a background image local background = display.newImageRect( sceneGroup, "scene/menu/img/background.png", display.actualContentWidth, display.actualContentHeight ) background.x = display.contentCenterX background.y = display.contentCenterY -- create/position logo/title image on upper-half of the screen local titleLogo = display.newImageRect( sceneGroup, "scene/menu/img/logo.png", 564, 318 ) titleLogo.x = display.contentCenterX titleLogo.y = 100 --play button local playButton = display.newImageRect( sceneGroup, "scene/menu/img/playbtn.png", 187, 82 ) playButton.x = display.contentCenterX playButton.y = 590 --highscores button local highScoresButton = display.newImageRect( sceneGroup, "scene/menu/img/highscr.png", 389, 147 ) highScoresButton.x = display.contentCenterX highScoresButton.y = 690 --helpButton local helpButton = display.newImageRect( sceneGroup, "scene/menu/img/helpbtn.png", 448, 259 ) helpButton.x = display.contentCenterX helpButton.y = 810 playButton:addEventListener( "tap", composer.gotoScene( "scene.game", { params = {} } ) ) highScoresButton:addEventListener( "tap", composer.gotoScene( "scene.highScores", { params = {} } ) ) helpButton:addEventListener( "tap", composer.gotoScene( "scene.help", { params = {} } ) ) musicTrack = audio.loadStream( "scene/menu/audio/bg.mp3" ) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is still off screen (but is about to come on screen) elseif ( phase == "did" ) then -- Code here runs when the scene is entirely on screen -- Start the music! audio.play( musicTrack, { channel=1, loops=-1 } ) end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then -- Code here runs when the scene is on screen (but is about to go off screen) elseif ( phase == "did" ) then -- Code here runs immediately after the scene goes entirely off screen -- Stop the music! audio.stop( 1 ) end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view -- Dispose audio! audio.dispose( musicTrack ) end --------------------------------------------------------------------------------- -- Listener setup scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) ----------------------------------------------------------------------------------------- return scene

could anyone please tell me where i’m wrong here this is my menu lua file

Please read https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/ and ask your question again :smiley:

XeduR@Spyric is right.  You should probably take a look at that post.

I say this because it it a little unclear what you’re asking for here.  It probably seems obvious to you, but it isn’t to us.  We want to help, but we need to know what you’re doing and seeing.

A great summary to put first in your post is: 

  • What you did,
  • Why you did it,
  • What your saw, and
  • What you expected to see.

It also helps to tell us what you tried in order to debug the problem.

Once we know this we can help you a lot more easily.

Thanks!

PS - Thanks for posting code, but I’ll give you a tip.  I’m suuuuuuper lazy.  I like it best when folks provide a link to a downloadable project that demonstrates the problem.  If you don’t make me do any coding to replicate your problem I’m way more likely to help.  GitHub and Dropbox are two great places to put the zip file containing your problem demo.

I’m sure I’m not alone in this.  In this case, it is a pain in the neck to take a pasted scene file and then have to

  1. Write the rest of the code needed for a project. main.lua, build.settings, config.lua, …

  2. Write code to show the scene.

  3. Paste the scene into its own file.

  4. Provide all the missing assets (images, etc.)

  5. Then finally try to run it and see ‘some unspecified error’.

Sigh… better to get a fully runnable project in a downloadable zip.

To prove I’m not a mean guy, you can always use my starter project as a basis when creating demos of problem.

  1. Download this and unzip it: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/askEdStarter.zip

  2. Add the code and assets you need to replicate your issue.

  3. Rename the folder.

  4. Zip it up and put it on GitHub, DropBox, or another reputable site.

  5. Share a link here.

  6. Don’t forget to tell us what is going on (that list I posted above).

PS - BTW, these links might be useful to you later:

https://github.com/roaminggamer/RG_FreeStuff - Entire repository of stuff I’ve given to the community for free (including AskEd folder with 6 years of projects that go with forums answers I’ve given. ~500 answer projects.)

https://github.com/roaminggamer/CoronaGeek - All the content I produced for the Corona Geek show (kind old now) including many complete games under ~/Hangouts/ICanMakeThat/

https://forums.coronalabs.com/topic/74704-template-portfolio-release/ - Post about 25+ templates I released for free.

Sheesh. No offense but, I really wonder what the expectation is of people like this.

It’s the equivalent of dumping a stack of papers of a stranger’s desk and saying “I need help. Fix this for me for free in your own free time.”

Please read https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/ and ask your question again :smiley:

XeduR@Spyric is right.  You should probably take a look at that post.

I say this because it it a little unclear what you’re asking for here.  It probably seems obvious to you, but it isn’t to us.  We want to help, but we need to know what you’re doing and seeing.

A great summary to put first in your post is: 

  • What you did,
  • Why you did it,
  • What your saw, and
  • What you expected to see.

It also helps to tell us what you tried in order to debug the problem.

Once we know this we can help you a lot more easily.

Thanks!

PS - Thanks for posting code, but I’ll give you a tip.  I’m suuuuuuper lazy.  I like it best when folks provide a link to a downloadable project that demonstrates the problem.  If you don’t make me do any coding to replicate your problem I’m way more likely to help.  GitHub and Dropbox are two great places to put the zip file containing your problem demo.

I’m sure I’m not alone in this.  In this case, it is a pain in the neck to take a pasted scene file and then have to

  1. Write the rest of the code needed for a project. main.lua, build.settings, config.lua, …

  2. Write code to show the scene.

  3. Paste the scene into its own file.

  4. Provide all the missing assets (images, etc.)

  5. Then finally try to run it and see ‘some unspecified error’.

Sigh… better to get a fully runnable project in a downloadable zip.

To prove I’m not a mean guy, you can always use my starter project as a basis when creating demos of problem.

  1. Download this and unzip it: https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/askEdStarter.zip

  2. Add the code and assets you need to replicate your issue.

  3. Rename the folder.

  4. Zip it up and put it on GitHub, DropBox, or another reputable site.

  5. Share a link here.

  6. Don’t forget to tell us what is going on (that list I posted above).

PS - BTW, these links might be useful to you later:

https://github.com/roaminggamer/RG_FreeStuff - Entire repository of stuff I’ve given to the community for free (including AskEd folder with 6 years of projects that go with forums answers I’ve given. ~500 answer projects.)

https://github.com/roaminggamer/CoronaGeek - All the content I produced for the Corona Geek show (kind old now) including many complete games under ~/Hangouts/ICanMakeThat/

https://forums.coronalabs.com/topic/74704-template-portfolio-release/ - Post about 25+ templates I released for free.

Sheesh. No offense but, I really wonder what the expectation is of people like this.

It’s the equivalent of dumping a stack of papers of a stranger’s desk and saying “I need help. Fix this for me for free in your own free time.”