As some of you may know I am doing the switch scene on collision in my app .I’m am nearly there with the help of a few people . Now I just have one error blocking my way .I will show you the error and my code .
Error:
Windows simulator build date: May 27 2015 @ 18:15:50
Copyright © 2009-2015 C o r o n a L a b s I n c .
Version: 3.0.0
Build: 2015.2646
Platform: SM-G900S / x64 / 6.2 / Intel® HD Graphics / 4.0.0 - Build 10.18.10.3
408 / 2015.2646
Loading project from: c:\users\true\documents\corona projects\test bench
Project sandbox folder: C:\Users\True\AppData\Roaming\Corona Labs\Corona Simulat
or\Sandbox\test bench-ED6DFA467C72057C41608B6099A18169\Documents
create initialized? table: 05DBAC98
Runtime error
bad argument #1 to ‘find’ (string expected, got table)
stack traceback:
[C]: in function ‘error’
?: in function ‘gotoScene’
c:\users\true\documents\corona projects\test bench\main.lua:34: in funct
ion ‘_listener’
?: in function <?:141>
?: in function <?:221>
Main.lua:
----------------------------------------------------------------------------------------- -- -- main.lua -- ----------------------------------------------------------------------------------------- local composer = require( "composer" ) local physics = require( "physics" ) physics.start() physics.setGravity(0, 15) -- display ground image local ground = display.newImageRect( "ground.png", 500, 100 ) ground.x = 145; ground.y = 480 ground.myName = "ground" ground.isGround = true physics.addBody( ground, "static" , { friction=0.5, bounce=0.1 } ) local crate = display.newImageRect( "crate.png", 90, 90 ) print("create initialized? ", crate ) crate.x = 60; crate.y = 20 crate.rotation = 0 crate.myName = "crate" crate.isCrate = true physics.addBody( crate, "dynamic" , { friction=0.5, bounce=0.3 } ) local function onCollision( self, event ) local other = event.other if( event.phase == "began" and self.isCrate and other.isGround ) then timer.performWithDelay( 30, function() composer.gotoScene { "restart.lua", "fade", 500 }; end) self:removeEventListener( "collision" ) end return true end crate.collision = onCollision crate:addEventListener( "collision" )
restart.lua:
local composer = require( "composer" ) local scene = composer.newScene() function scene:create( event ) local sceneGroup = self.view end -- display ground image local ground = display.newImageRect( "ground.png", 500, 100 ) ground.x = 145; ground.y = 480 -- display logo image local logo = display.newImageRect( "logo.png", 300, 200 ) logo.x = 160 logo.y = 20 group:insert(logo) group:insert(ground) scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene )
What is my error what corrections do I need .
Thank you.
