Game does not work since if applied storyboard to my script

Hello guys,

I am pretty new to corona sdk and development in general, but I managed to get a quick demo of my game idea quickly - I was and I still am surprised about this fact :wink:

Since I want a game with at least a starting screen, a game screen and a game ended scene, I needed to take a look at storyboards and scenes. I found the very useful template for storyboards and scenes in the forum and took this template as a starting point to copy all my working code from one single lua file to a game scene lua file as a storyboard.

As I thought I placed all my code in the right positions and the game does still work BUT what is not working anymore is the collision detection and I can not figure out why this is like that.

So I thought I post my problem to the forum and hopefully some of you guys could help me out on that.

Attached you find my code and I would be very greatful if you could take a look at it and give me a hint and/or an helping hand.

Thanks so much and best regards,

Johannes

local storyboard = require ("storyboard"); local scene = storyboard.newScene(); -- GENERAL display.setStatusBar( display.HiddenStatusBar ) -- PHYSICS local physics = require( "physics" ); physics.start( ); physics.setGravity( 0, 10 ); ---------------------------------------------------------------------------------- -- -- NOTE: -- -- Code outside of listener functions (below) will only be executed once, -- unless storyboard.removeScene() is called. -- --------------------------------------------------------------------------------- -- local forward references should go here -- --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view -- GFX ASSETS local sky = display.newImage( "bkg\_clouds.png" ); sky.x = 240; sky.y = 160; group:insert( sky ); local ground = display.newImage( "ground.png" ); ground.x = 260; ground.y = 300; physics.addBody( ground, "static", {friction=0.5, bounce=0.3 } ); -- Walls need names too ground.name = "ground" group:insert( ground ); local plateau = display.newImage( "plateau.png" ); plateau.x = 260; plateau.y = 150; physics.addBody( plateau, "static", {friction=0.5, bounce=0.3 } ); plateau.name = "plateau" group:insert( plateau ); -- TAXI local taxi = display.newImage( "taxi.png" ); taxi.x = 180; taxi.y = -50; taxi.rotation = 0; physics.addBody( taxi, "dynamic", {density=3.0, friction=0.5, bounce=0.3 } ); taxi.isFixedRotation = true; -- Give each box a name to identify it in collisions taxi.name = "taxi" group:insert( taxi ); taxi.collision = taxiCollision; local state = taxi.isFixedRotation; -- CREATE USER CONTROLS local control\_left = display.newRect( 0, 0, 50, 50 ) control\_left.x = 25 control\_left.y = 295 group:insert( control\_left ); local control\_right = display.newRect( 0, 0, 50, 50 ) control\_right.x = 455 control\_right.y = 295 group:insert( control\_right); ----------------------------------------------------------------------------- -- CREATE display objects and add them to 'group' here. -- Example use-case: Restore 'group' from previously saved state. ----------------------------------------------------------------------------- -- Function to move taxi left local function thrust\_left( event ) local target = taxi local phase = event.phase if phase == "began" then -- Tapped push the object up target:applyForce( 150, -500, event.x, event.y ) end end -- Function to move taxi right local function thrust\_right( event ) local target = taxi local phase = event.phase if phase == "began" then -- Tapped push the object up target:applyForce( -150, -500, event.x, event.y ) end end --Taxi colission functions local function taxiCollision(self, event) if event.phase == "began" then if event.target.name == "taxi" and event.other.name == "plateau" then print("supi") else print("fojhhkjho") end end end taxi:addEventListener( "collision", taxi ) control\_left:addEventListener( "touch", thrust\_left ) control\_right:addEventListener( "touch", thrust\_right ) end -- Called BEFORE scene has moved onscreen: function scene:willEnterScene( event ) local group = self.view ----------------------------------------------------------------------------- -- This event requires build 2012.782 or later. ----------------------------------------------------------------------------- end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. start timers, load audio, start listeners, etc.) ----------------------------------------------------------------------------- end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.) ----------------------------------------------------------------------------- end -- Called AFTER scene has finished moving offscreen: function scene:didExitScene( event ) local group = self.view ----------------------------------------------------------------------------- -- This event requires build 2012.782 or later. ----------------------------------------------------------------------------- end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view ----------------------------------------------------------------------------- -- INSERT code here (e.g. remove listeners, widgets, save state, etc.) ----------------------------------------------------------------------------- end -- Called if/when overlay scene is displayed via storyboard.showOverlay() function scene:overlayBegan( event ) local group = self.view local overlay\_name = event.sceneName -- name of the overlay scene ----------------------------------------------------------------------------- -- This event requires build 2012.797 or later. ----------------------------------------------------------------------------- end -- Called if/when overlay scene is hidden/removed via storyboard.hideOverlay() function scene:overlayEnded( event ) local group = self.view local overlay\_name = event.sceneName -- name of the overlay scene ----------------------------------------------------------------------------- -- This event requires build 2012.797 or later. ----------------------------------------------------------------------------- end --------------------------------------------------------------------------------- -- END OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- "createScene" event is dispatched if scene's view does not exist scene:addEventListener( "createScene", scene ) -- "willEnterScene" event is dispatched before scene transition begins scene:addEventListener( "willEnterScene", scene ) -- "enterScene" event is dispatched whenever scene transition has finished scene:addEventListener( "enterScene", scene ) -- "exitScene" event is dispatched before next scene's transition begins scene:addEventListener( "exitScene", scene ) -- "didExitScene" event is dispatched after scene has finished transitioning out scene:addEventListener( "didExitScene", scene ) -- "destroyScene" event is dispatched before view is unloaded, which can be -- automatically unloaded in low memory situations, or explicitly via a call to -- storyboard.purgeScene() or storyboard.removeScene(). scene:addEventListener( "destroyScene", scene ) -- "overlayBegan" event is dispatched when an overlay scene is shown scene:addEventListener( "overlayBegan", scene ) -- "overlayEnded" event is dispatched when an overlay scene is hidden/removed scene:addEventListener( "overlayEnded", scene ) --------------------------------------------------------------------------------- return scene