attempt to call method 'addEventListener' (a nil value)

Hi guys. I really get stuck in restarting my game. After each gameover user go to restart scene and touch the screen to play again. The first restart touch work but for the second time there pop a runtime Error :attempt to call method ‘addEventListener’ (a nil value)

Here is my restart.lua Code:

-- requires local storyboard = require( "storyboard" ) local scene = storyboard.newScene() -- background function scene:createScene(event) local screenGroup = self.view image\_variable\_name = display.newImageRect("start.png", display.contentWidth, display.contentHeight) --then you have to center it: image\_variable\_name.x = display.contentWidth / 2 image\_variable\_name.y = display.contentHeight / 2 screenGroup:insert(image\_variable\_name) end function start(event) print("زد رو ری استارت") if event.phase == "began" then storyboard.gotoScene("game","fade","100") print("از ری استارت به گیم") end end function scene:enterScene(event) storyboard.purgeScene("game") image\_variable\_name:addEventListener("touch",start) print("وارد ری استارت شد") end function scene:exitScene(event) image\_variable\_name:removeEventListener("touch",start) print("خارج شد از ری استارت") end function scene:destroyScene(event) end scene:addEventListener("createScene", scene) scene:addEventListener("enterScene", scene) scene:addEventListener("exitScene", scene) scene:addEventListener("destroyScene", scene) return scene

Is “storyboard” still available? Now that’s something I didn’t know about. You should definitely switch to “composer” and download one of the latest Corona builds. After doing that, can you upload a sample project so we can see the problem clearly?

Also, you should post those questions to “Newbie Questions” part of the forum where you can get answers more quickly.

Storyboard has been deprecated and removed from the Corona SDK core. However, many people have older apps that still use Storyboard. There are quite a few people who still use Storyboard and we’ve open-sourced it on our GitHub:  https://github.com/coronalabs/framework-storyboard-legacy

Just download the storyboard.lua file and drop it in the folder with your main.lua.

As far as the issue above, I can’t confirm this, but you’re using global variables and if you’re using the same variables in the other scene they could be stomping on each other.

Also you should do a removeScene instead of purgeScene to make sure the scene is completely un-required.

Is there more to the error message? In the console log there should be more to the message.  Also what version of Corona SDK are you using?

Rob

Thanks for your answer, the story board is available. I download it and put it in my main project path.

Thank you Rob. I’ve just follow a tutorial in youtube. I am noobie. The tutorial used storyboard. I know that is legacy but do you know any resource which create a game from scratch for beginners like me and also it uses latest corona lab SDK components like composer?

Keep in mind that even though we provide storyboard.lua, it’s no longer supported. If you find a bug, we won’t be fixing it. Composer is the supported platform.

That said, as far a resources using Composer, consider the following:

Getting Started guide: https://docs.coronalabs.com/guide/programming/index.html

Sample Game Template: https://github.com/coronalabs/sample-game-project

Corona Cannon: A complete “Angry Birds” type game.: https://github.com/coronalabs-samples/CoronaCannon

Composer Guide: https://docs.coronalabs.com/guide/system/composer/index.html

Rob

Thank you very much

Is “storyboard” still available? Now that’s something I didn’t know about. You should definitely switch to “composer” and download one of the latest Corona builds. After doing that, can you upload a sample project so we can see the problem clearly?

Also, you should post those questions to “Newbie Questions” part of the forum where you can get answers more quickly.

Storyboard has been deprecated and removed from the Corona SDK core. However, many people have older apps that still use Storyboard. There are quite a few people who still use Storyboard and we’ve open-sourced it on our GitHub:  https://github.com/coronalabs/framework-storyboard-legacy

Just download the storyboard.lua file and drop it in the folder with your main.lua.

As far as the issue above, I can’t confirm this, but you’re using global variables and if you’re using the same variables in the other scene they could be stomping on each other.

Also you should do a removeScene instead of purgeScene to make sure the scene is completely un-required.

Is there more to the error message? In the console log there should be more to the message.  Also what version of Corona SDK are you using?

Rob

Thanks for your answer, the story board is available. I download it and put it in my main project path.

Thank you Rob. I’ve just follow a tutorial in youtube. I am noobie. The tutorial used storyboard. I know that is legacy but do you know any resource which create a game from scratch for beginners like me and also it uses latest corona lab SDK components like composer?

Keep in mind that even though we provide storyboard.lua, it’s no longer supported. If you find a bug, we won’t be fixing it. Composer is the supported platform.

That said, as far a resources using Composer, consider the following:

Getting Started guide: https://docs.coronalabs.com/guide/programming/index.html

Sample Game Template: https://github.com/coronalabs/sample-game-project

Corona Cannon: A complete “Angry Birds” type game.: https://github.com/coronalabs-samples/CoronaCannon

Composer Guide: https://docs.coronalabs.com/guide/system/composer/index.html

Rob

Thank you very much