Bullet and Composer Scene

I have a scene with a level. When I click on the screen I shoot dice.

How to process a cube that would prescribe it to the group scene?

My cube is not part of the scene, and he did not defecating at the function “delete a scene”.

It is necessary that the cube would be added to the group scene every time you touch the screen, but how to do it? We describe a variable as a function of the cube “bullet_touch”

local physics = require "physics" physics.setDrawMode( "hybrid" ) physics.start( ) local widget = require "widget" local composer = require "composer" local scene = composer.newScene() local function touch\_bullet (event) -- ПУЛЯ if ( event.phase == "began" ) then local s = display.newImage( "s.png", 400, 400 ) s.isBullet = true physics.addBody( s, "dinamic", {density = 0.4, friction = 6} ) z = 480 - event.y s:setLinearVelocity( -200, -z\*1.5 ) end return true end -- create() function scene:create( event ) local sceneGroup = self.view local pol = display.newImage( "pol.png", 160, 480 ) physics.addBody( pol, "static" ) sceneGroup:insert(pol) -- sceneGroup:insert(s) --THIS DOES NOT WORK! ERROR! Runtime:addEventListener( "touch", touch\_bullet ) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

_GdXaWnivpI.jpg

– sceneGroup:insert(s) --THIS DOES NOT WORK! ERROR!

This is most certainly going to give you an error. “s” doesn’t exist when that code runs and it won’t. Spawned items happen during the scene not at create time. You have to insert the object after you create it.

Try this:

local function touch\_bullet (event) -- ПУЛЯ local sceneGroup = scene.view -- not self.view, but scene.view if ( event.phase == "began" ) then local s = display.newImage( "s.png", 400, 400 ) sceneGroup:insert( s ) s.isBullet = true physics.addBody( s, "dynamic", {density = 0.4, friction = 6} ) --\<-- you misspelled dynamic here z = 480 - event.y s:setLinearVelocity( -200, -z\*1.5 ) end return true end

In scene:create where you do:

local sceneGroup = self.view

self is really a pointer to “scene”. So it’s really:

local sceneGroup = scene.view

“self” only works in “object” functions, but “scene” is visible everywhere.

Rob

Okay. Then I have another problem!

Before that, I took a particular problem, but now I will take all the app!

There are 3 file - the main level, a restart.

I ordered as you said, only after I press the restart button again and click on the screen for a shot - an error occurs!

Of course, I delete the data of the scene, but the scene is reset group? or I do not understand …

-O9k5DZF-aE.jpg

I googled and tried to fix it and made another name for the group to function, for example, “global group” and added it through the “insert” to “create a scene”

but it does not help.

MAIN

local composer = require "composer" composer.gotoScene( "level" )

LEVEL

local physics = require "physics" physics.setDrawMode( "hybrid" ) physics.start( ) local widget = require "widget" local composer = require "composer" local scene = composer.newScene() function onEventListener( event ) -- РЕСТАРТ if ( event.phase == "began" ) then composer.gotoScene( "restart" ) composer.removeScene( "level" ) end return true end function touch\_bullet (event) local sceneGroup = scene.view if ( event.phase == "began" ) then local s = display.newImage( "s.png", 400, 400 ) sceneGroup:insert( s ) s.isBullet = true physics.addBody( s, "dynamic", {density = 0.4, friction = 6} ) z = 480 - event.y s:setLinearVelocity( -200, -z\*1.5 ) end return true end -- create() function scene:create( event ) local sceneGroup = self.view local restart = display.newImage( "restart.png", 250, 0 ) sceneGroup:insert(restart) local pol = display.newImage( "pol.png", 160, 480 ) physics.addBody( pol, "static" ) sceneGroup:insert(pol) local p1 = display.newImage( "p.png" , 160, 426 ) physics.addBody( p1, "dinamic", { friction = 0.3, density = 0.01 } ) sceneGroup:insert(p1) local p2 = display.newImage( "p.png", 120, 426 ) physics.addBody( p2, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p2) local p3 = display.newImage( "p.png", 200, 426 ) physics.addBody( p3, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p3) local p4 = display.newImage( "p.png", 160, 380 ) p4.rotation = 90 physics.addBody( p4, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p4) local p5 = display.newImage( "p.png", 140, 330) physics.addBody( p5, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p5) local p6 = display.newImage( "p.png", 180, 330) physics.addBody( p6, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p6) local p7 = display.newImage( "p.png", 160, 285) physics.addBody( p7, "dinamic", { friction = 0.3, density = 0.01} ) p7.rotation = 90 sceneGroup:insert(p7) Runtime:addEventListener( "touch", touch\_bullet ) -- СОБЫТИЕ ПУЛИ restart:addEventListener( "touch", onEventListener ) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

RESTART

local composer = require( "composer" ) local scene = composer.newScene() local composer = require( "composer" ) local scene = composer.newScene() -- create() function scene:create( event ) local sceneGroup = self.view end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then composer.removeScene("restart") composer.gotoScene( "level", "fade" ) end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

 I did. but I get another error. See entry above!

Can you copy/paste the full error message from the console log? There should be a full stack trace of what’s happening and perhaps several lines before the error?

Paste that in here.

17:27:51.223  

17:27:51.223  Windows simulator build date: Feb 18 2016 @ 02:28:53

17:27:51.223  

17:27:56.975  

17:27:56.975  Copyright © 2009-2016  C o r o n a   L a b s   I n c .

17:27:56.975   Version: 3.0.0

17:27:56.975   Build: 2016.2830

17:27:56.975  Platform: GT-I9300 / x64 / 6.1 / GeForce GTX 980/PCIe/SSE2 / 4.5.0 NVIDIA 361.43 / 2016.2830 / ru_RU | RU | ru_RU | ru

17:27:56.975  Loading project from:   E:\Program Files (x86)\Corona Projects\test1

17:27:56.975  Project sandbox folder: C:\Users\15ОКТ\AppData\Local\Corona Labs\Corona Simulator\Sandbox\test1-8A3A81B782C816A1585DD9829CF7AA5F\Documents

17:28:02.875  ERROR: Runtime error

17:28:02.875  E:\Program Files (x86)\Corona Projects\test1\level.lua:27: attempt to index local ‘sceneGroup’ (a nil value)

17:28:02.875  stack traceback:

17:28:02.875   E:\Program Files (x86)\Corona Projects\test1\level.lua:27: in function <E:\Program Files (x86)\Corona Projects\test1\level.lua:23>

17:28:02.875   ?: in function <?:205>

I just took your level.lua and main.lua and it’s running as expected. I had to remove everything from scene:create() except for the touch listener on the screen since I didn’t have any of those images and they seemed irrelevant to your problem. The other change I made was:

local s = display.newRect( 400, 400, 10, 10 )

I didn’t have your s.png so I made it a rectangle. If I try it with your exact code, I get a different error.

Jul 13 10:40:42.953 Project sandbox folder: ~/Library/Application Support/Corona Simulator/tmp-292D2A5488D376935C88DB31A32368A3 Jul 13 10:40:42.974 Platform: iPhone / x86\_64 / 10.11.5 / Intel HD Graphics 4000 OpenGL Engine / 2.1 INTEL-10.14.66 / 2016.2906 / en | US | en\_US | en Jul 13 10:40:45.839 WARNING: /Users/rmiracle/tmp/level.lua:26: Failed to find image 's.png' Jul 13 10:40:45.840 WARNING: /Users/rmiracle/tmp/level.lua:26: file 's.png' does not contain a valid image Jul 13 10:40:45.840 Jul 13 10:40:45.870 ERROR: Runtime error &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /Users/rmiracle/tmp/level.lua:27: ERROR: table expected. If this is a function call, you might have used '.' instead of ':' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stack traceback: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;[C]: in function 'insert' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/Users/rmiracle/tmp/level.lua:27: in function \</Users/rmiracle/tmp/level.lua:23\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;?: in function \<?:169\>

By the way, in your scene:create() you still need to change all the “dinamic” values to “dynamic”.  I’ll try running this on Windows to see if there is something different there. What would be helpful is if you could zip up your whole project so I have your config.lua, build settings and all of your assets.

Finally, we have a new public build version of Corona SDK (2016.2906). You should update to that version. It won’t fix this problem but if we find a bug, you’re going to need to be using that version before we can look at it.

Rob

My entire project can be downloaded here: http://dropmefiles.com/bMYxC

Thank you for helping and spending time! I have a week trying to fix this! Does not work. Updated today!

If I replace “local s = display.newImage( “s.png”, 400, 400 )” for “local s = display.newRect( 400, 400, 10, 10 )”    I get the same error (

Okay I tracked it down. The problem is making the Runtime a button. Instead, do this:

&nbsp;&nbsp;&nbsp; local fireBullet = display.newRect(display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight) &nbsp;&nbsp; &nbsp;sceneGroup:insert( fireBullet ) &nbsp;&nbsp; &nbsp;fireBullet.isVisible = false &nbsp;&nbsp; &nbsp;fireBullet.isHitTestable = true &nbsp;&nbsp;&nbsp; fireBullet:addEventListener( "touch", touch\_bullet ) -- СОБЫТИЕ ПУЛИ

in your scene:create() function. The Runtime is a global object. It is not scene managed. So when you came back from reset.lua, the previous touch handler was there and that copy of the function didn’t know about “scene” any longer.

Rob

Thank you very much! The mistake was when I was in that I click on the screen and it was necessary for a particular object, picture, or something else.

Thank you very much! I’m sorry I took you so long! You’re a very good man! How can I thank you?

Leave your code here for other people with a similar problem!

MAIN

local composer = require "composer" composer.gotoScene( "level" )

LEVEL

local physics = require "physics" physics.setDrawMode( "hybrid" ) physics.start( ) local widget = require "widget" local composer = require "composer" local scene = composer.newScene() function onEventListener( event ) -- РЕСТАРТ if ( event.phase == "began" ) then composer.gotoScene( "restart" ) composer.removeScene( "level" ) end return true end function touch\_bullet (event) -- ПУЛЯ local sceneGroup = scene.view if ( event.phase == "began" ) then --local s = display.newImage( "s.png", 400, 400 ) local s = display.newRect( 400, 400, 10, 10 ) sceneGroup:insert( s ) s.isBullet = true physics.addBody( s, "dynamic", {density = 0.4, friction = 6} ) s:setLinearVelocity( -200, -z\*1.5 ) end return true end -- create() function scene:create( event ) local sceneGroup = self.view local pol = display.newImage( "pol.png", 160, 480 ) physics.addBody( pol, "static" ) sceneGroup:insert(pol) local p1 = display.newImage( "p.png" , 160, 426 ) physics.addBody( p1, "dynamic", { friction = 0.3, density = 0.01 } ) sceneGroup:insert(p1) local p2 = display.newImage( "p.png", 120, 426 ) physics.addBody( p2, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p2) local p3 = display.newImage( "p.png", 200, 426 ) physics.addBody( p3, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p3) local p4 = display.newImage( "p.png", 160, 380 ) p4.rotation = 90 physics.addBody( p4, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p4) local p5 = display.newImage( "p.png", 140, 330) physics.addBody( p5, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p5) local p6 = display.newImage( "p.png", 180, 330) physics.addBody( p6, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p6) local p7 = display.newImage( "p.png", 160, 285) physics.addBody( p7, "dynamic", { friction = 0.3, density = 0.01} ) p7.rotation = 90 sceneGroup:insert(p7) local fireBullet = display.newRect(display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight) sceneGroup:insert( fireBullet ) fireBullet.isVisible = false fireBullet.isHitTestable = true local restart = display.newImage( "restart.png", 250, 0 ) sceneGroup:insert(restart) fireBullet:addEventListener( "touch", touch\_bullet ) -- СОБЫТИЕ ПУЛИ restart:addEventListener( "touch", onEventListener ) 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 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 end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

RESTART

local composer = require( "composer" ) local scene = composer.newScene() local composer = require( "composer" ) local scene = composer.newScene() -- create() function scene:create( event ) local sceneGroup = self.view end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then composer.removeScene("restart") composer.gotoScene( "level", "fade" ) end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

– sceneGroup:insert(s) --THIS DOES NOT WORK! ERROR!

This is most certainly going to give you an error. “s” doesn’t exist when that code runs and it won’t. Spawned items happen during the scene not at create time. You have to insert the object after you create it.

Try this:

local function touch\_bullet (event) -- ПУЛЯ local sceneGroup = scene.view -- not self.view, but scene.view if ( event.phase == "began" ) then local s = display.newImage( "s.png", 400, 400 ) sceneGroup:insert( s ) s.isBullet = true physics.addBody( s, "dynamic", {density = 0.4, friction = 6} ) --\<-- you misspelled dynamic here z = 480 - event.y s:setLinearVelocity( -200, -z\*1.5 ) end return true end

In scene:create where you do:

local sceneGroup = self.view

self is really a pointer to “scene”. So it’s really:

local sceneGroup = scene.view

“self” only works in “object” functions, but “scene” is visible everywhere.

Rob

Okay. Then I have another problem!

Before that, I took a particular problem, but now I will take all the app!

There are 3 file - the main level, a restart.

I ordered as you said, only after I press the restart button again and click on the screen for a shot - an error occurs!

Of course, I delete the data of the scene, but the scene is reset group? or I do not understand …

-O9k5DZF-aE.jpg

I googled and tried to fix it and made another name for the group to function, for example, “global group” and added it through the “insert” to “create a scene”

but it does not help.

MAIN

local composer = require "composer" composer.gotoScene( "level" )

LEVEL

local physics = require "physics" physics.setDrawMode( "hybrid" ) physics.start( ) local widget = require "widget" local composer = require "composer" local scene = composer.newScene() function onEventListener( event ) -- РЕСТАРТ if ( event.phase == "began" ) then composer.gotoScene( "restart" ) composer.removeScene( "level" ) end return true end function touch\_bullet (event) local sceneGroup = scene.view if ( event.phase == "began" ) then local s = display.newImage( "s.png", 400, 400 ) sceneGroup:insert( s ) s.isBullet = true physics.addBody( s, "dynamic", {density = 0.4, friction = 6} ) z = 480 - event.y s:setLinearVelocity( -200, -z\*1.5 ) end return true end -- create() function scene:create( event ) local sceneGroup = self.view local restart = display.newImage( "restart.png", 250, 0 ) sceneGroup:insert(restart) local pol = display.newImage( "pol.png", 160, 480 ) physics.addBody( pol, "static" ) sceneGroup:insert(pol) local p1 = display.newImage( "p.png" , 160, 426 ) physics.addBody( p1, "dinamic", { friction = 0.3, density = 0.01 } ) sceneGroup:insert(p1) local p2 = display.newImage( "p.png", 120, 426 ) physics.addBody( p2, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p2) local p3 = display.newImage( "p.png", 200, 426 ) physics.addBody( p3, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p3) local p4 = display.newImage( "p.png", 160, 380 ) p4.rotation = 90 physics.addBody( p4, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p4) local p5 = display.newImage( "p.png", 140, 330) physics.addBody( p5, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p5) local p6 = display.newImage( "p.png", 180, 330) physics.addBody( p6, "dinamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p6) local p7 = display.newImage( "p.png", 160, 285) physics.addBody( p7, "dinamic", { friction = 0.3, density = 0.01} ) p7.rotation = 90 sceneGroup:insert(p7) Runtime:addEventListener( "touch", touch\_bullet ) -- СОБЫТИЕ ПУЛИ restart:addEventListener( "touch", onEventListener ) end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

RESTART

local composer = require( "composer" ) local scene = composer.newScene() local composer = require( "composer" ) local scene = composer.newScene() -- create() function scene:create( event ) local sceneGroup = self.view end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then composer.removeScene("restart") composer.gotoScene( "level", "fade" ) end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

 I did. but I get another error. See entry above!

Can you copy/paste the full error message from the console log? There should be a full stack trace of what’s happening and perhaps several lines before the error?

Paste that in here.

17:27:51.223  

17:27:51.223  Windows simulator build date: Feb 18 2016 @ 02:28:53

17:27:51.223  

17:27:56.975  

17:27:56.975  Copyright © 2009-2016  C o r o n a   L a b s   I n c .

17:27:56.975   Version: 3.0.0

17:27:56.975   Build: 2016.2830

17:27:56.975  Platform: GT-I9300 / x64 / 6.1 / GeForce GTX 980/PCIe/SSE2 / 4.5.0 NVIDIA 361.43 / 2016.2830 / ru_RU | RU | ru_RU | ru

17:27:56.975  Loading project from:   E:\Program Files (x86)\Corona Projects\test1

17:27:56.975  Project sandbox folder: C:\Users\15ОКТ\AppData\Local\Corona Labs\Corona Simulator\Sandbox\test1-8A3A81B782C816A1585DD9829CF7AA5F\Documents

17:28:02.875  ERROR: Runtime error

17:28:02.875  E:\Program Files (x86)\Corona Projects\test1\level.lua:27: attempt to index local ‘sceneGroup’ (a nil value)

17:28:02.875  stack traceback:

17:28:02.875   E:\Program Files (x86)\Corona Projects\test1\level.lua:27: in function <E:\Program Files (x86)\Corona Projects\test1\level.lua:23>

17:28:02.875   ?: in function <?:205>

I just took your level.lua and main.lua and it’s running as expected. I had to remove everything from scene:create() except for the touch listener on the screen since I didn’t have any of those images and they seemed irrelevant to your problem. The other change I made was:

local s = display.newRect( 400, 400, 10, 10 )

I didn’t have your s.png so I made it a rectangle. If I try it with your exact code, I get a different error.

Jul 13 10:40:42.953 Project sandbox folder: ~/Library/Application Support/Corona Simulator/tmp-292D2A5488D376935C88DB31A32368A3 Jul 13 10:40:42.974 Platform: iPhone / x86\_64 / 10.11.5 / Intel HD Graphics 4000 OpenGL Engine / 2.1 INTEL-10.14.66 / 2016.2906 / en | US | en\_US | en Jul 13 10:40:45.839 WARNING: /Users/rmiracle/tmp/level.lua:26: Failed to find image 's.png' Jul 13 10:40:45.840 WARNING: /Users/rmiracle/tmp/level.lua:26: file 's.png' does not contain a valid image Jul 13 10:40:45.840 Jul 13 10:40:45.870 ERROR: Runtime error &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /Users/rmiracle/tmp/level.lua:27: ERROR: table expected. If this is a function call, you might have used '.' instead of ':' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; stack traceback: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;[C]: in function 'insert' &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;/Users/rmiracle/tmp/level.lua:27: in function \</Users/rmiracle/tmp/level.lua:23\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;?: in function \<?:169\>

By the way, in your scene:create() you still need to change all the “dinamic” values to “dynamic”.  I’ll try running this on Windows to see if there is something different there. What would be helpful is if you could zip up your whole project so I have your config.lua, build settings and all of your assets.

Finally, we have a new public build version of Corona SDK (2016.2906). You should update to that version. It won’t fix this problem but if we find a bug, you’re going to need to be using that version before we can look at it.

Rob

My entire project can be downloaded here: http://dropmefiles.com/bMYxC

Thank you for helping and spending time! I have a week trying to fix this! Does not work. Updated today!

If I replace “local s = display.newImage( “s.png”, 400, 400 )” for “local s = display.newRect( 400, 400, 10, 10 )”    I get the same error (

Okay I tracked it down. The problem is making the Runtime a button. Instead, do this:

&nbsp;&nbsp;&nbsp; local fireBullet = display.newRect(display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight) &nbsp;&nbsp; &nbsp;sceneGroup:insert( fireBullet ) &nbsp;&nbsp; &nbsp;fireBullet.isVisible = false &nbsp;&nbsp; &nbsp;fireBullet.isHitTestable = true &nbsp;&nbsp;&nbsp; fireBullet:addEventListener( "touch", touch\_bullet ) -- СОБЫТИЕ ПУЛИ

in your scene:create() function. The Runtime is a global object. It is not scene managed. So when you came back from reset.lua, the previous touch handler was there and that copy of the function didn’t know about “scene” any longer.

Rob

Thank you very much! The mistake was when I was in that I click on the screen and it was necessary for a particular object, picture, or something else.

Thank you very much! I’m sorry I took you so long! You’re a very good man! How can I thank you?

Leave your code here for other people with a similar problem!

MAIN

local composer = require "composer" composer.gotoScene( "level" )

LEVEL

local physics = require "physics" physics.setDrawMode( "hybrid" ) physics.start( ) local widget = require "widget" local composer = require "composer" local scene = composer.newScene() function onEventListener( event ) -- РЕСТАРТ if ( event.phase == "began" ) then composer.gotoScene( "restart" ) composer.removeScene( "level" ) end return true end function touch\_bullet (event) -- ПУЛЯ local sceneGroup = scene.view if ( event.phase == "began" ) then --local s = display.newImage( "s.png", 400, 400 ) local s = display.newRect( 400, 400, 10, 10 ) sceneGroup:insert( s ) s.isBullet = true physics.addBody( s, "dynamic", {density = 0.4, friction = 6} ) s:setLinearVelocity( -200, -z\*1.5 ) end return true end -- create() function scene:create( event ) local sceneGroup = self.view local pol = display.newImage( "pol.png", 160, 480 ) physics.addBody( pol, "static" ) sceneGroup:insert(pol) local p1 = display.newImage( "p.png" , 160, 426 ) physics.addBody( p1, "dynamic", { friction = 0.3, density = 0.01 } ) sceneGroup:insert(p1) local p2 = display.newImage( "p.png", 120, 426 ) physics.addBody( p2, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p2) local p3 = display.newImage( "p.png", 200, 426 ) physics.addBody( p3, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p3) local p4 = display.newImage( "p.png", 160, 380 ) p4.rotation = 90 physics.addBody( p4, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p4) local p5 = display.newImage( "p.png", 140, 330) physics.addBody( p5, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p5) local p6 = display.newImage( "p.png", 180, 330) physics.addBody( p6, "dynamic", { friction = 0.3, density = 0.01} ) sceneGroup:insert(p6) local p7 = display.newImage( "p.png", 160, 285) physics.addBody( p7, "dynamic", { friction = 0.3, density = 0.01} ) p7.rotation = 90 sceneGroup:insert(p7) local fireBullet = display.newRect(display.contentCenterX, display.contentCenterY, display.actualContentWidth, display.actualContentHeight) sceneGroup:insert( fireBullet ) fireBullet.isVisible = false fireBullet.isHitTestable = true local restart = display.newImage( "restart.png", 250, 0 ) sceneGroup:insert(restart) fireBullet:addEventListener( "touch", touch\_bullet ) -- СОБЫТИЕ ПУЛИ restart:addEventListener( "touch", onEventListener ) 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 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 end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view -- Code here runs prior to the removal of scene's view end -- ----------------------------------------------------------------------------------- -- Scene event function listeners -- ----------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) -- ----------------------------------------------------------------------------------- return scene

RESTART

local composer = require( "composer" ) local scene = composer.newScene() local composer = require( "composer" ) local scene = composer.newScene() -- create() function scene:create( event ) local sceneGroup = self.view end -- show() function scene:show( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then composer.removeScene("restart") composer.gotoScene( "level", "fade" ) end end -- hide() function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if ( phase == "will" ) then elseif ( phase == "did" ) then end end -- destroy() function scene:destroy( event ) local sceneGroup = self.view end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene