Help needed to solve this proxy issue...

Hello everyone…

I am developing a flappy bird style game where the ship (I’ve used ship instead bird) can fire bullets in the direction of touch on the screen as well as it can be kept upward by tapping on a button in left corner. Until now everything is working nicely. The game flow is nice and is working. But when ship collides with bad objects the scene is changes and it goes to menu (as I want). But soon after it shows me this error. 

(the error is at line 391)

this is that line…

gameloopTimer = timer.performWithDelay(500,gameloop,0)

here’s code …

local composer = require( "composer" ) local scene = composer.newScene() local physics = require "physics" local gameLoopTimer -------------------------------------------- ------------------------------------------- local function destroyScene() composer.gotoScene( "menu", { time=800, effect="crossFade" }) composer.removeScene("level1") end local function endGame() timer.performWithDelay(200,function() destroyScene() end) end -------------------------------------------- ------------------------------------------- local score = 3 local score2 = 0 local scoreText local scoreText2 scoreText = display.newText("ballsleft:"..score,800,15,native.systemFontBold, 30) scoreText:setFillColor (1 ) scoreText2 = display.newText("score:"..score2,220,15,native.systemFontBold, 30) scoreText2:setFillColor (1 ) local function updateText() scoreText.text = "ballsleft: " .. score end local function updateText() scoreText.text = "score: " .. score2 end ---------------------------------------- --------------------------------------- local function onCollision( event ) if ( event.phase == "began" ) then local obj1 = event.object1 local obj2 = event.object2 if (obj1.surfaceType == "good" and obj2.surfaceType == "bad" ) then display.remove( obj1 ) elseif ( (obj1.surfaceType == "ship" ) and obj2.surfaceType == "good" ) then display.remove( obj2 ) score2 = score2 + 1 scoreText2.text = "score: " .. score2 score = score + 2 scoreText.text = "ballsleft: " .. score elseif ( (obj1.surfaceType == "ship" ) and (obj2.surfaceType == "bad" )) then display.remove( obj1 ) endGame() display.remove(scoreText) display.remove(scoreText2) end end end ---------------------------------------- --------------------------------------- local loop local loop1 local angleof local angleof1 local move = 5000 loop = 60 loop1 = 240 angleof = 180 angleof1 = 0 local function speedup() move = move - 300 end timer.performWithDelay(5000000,speedup,0) local function realgame() loop = math.random(120,180) loop1 = math.random(20,190) end local function realgame1() angleof = (math.random(50,180)) angleof1 = (math.random(50,180)) end local my = function() return realgame() end timer.performWithDelay(1000,my,1) local my1 = function() return realgame1() end timer.performWithDelay(1000000,my1,1) local n = math.random(140,230) ----------------------------------------- -------------------------------------------- local screenW, screenH, halfW = display.actualContentWidth, display.actualContentHeight, display.contentCenterX ------------------------------------------ ------------------------------------------ function scene:create( event ) math.randomseed(system.getTimer()) local sceneGroup = self.view physics.setDrawMode( "normal") end ------------------------------------------- -------------------------------------------- function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then elseif phase == "did" then physics.start() physics.setGravity(0, 12) ---------------------------- -- display rcect which are translated and having no influence of physics-- ---------------------------- local speed local rect1 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect1.x = math.random(40,480) rect1.y = math.random(40,300) rect1.alpha = .1 rect1.speed = 1 local rect2 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect2.x = math.random(40,480) rect2.y = math.random(40,300) rect2.alpha = .1 rect2.speed = 2 local rect3 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect3.x = math.random(40,480) rect3.y = math.random(40,300) rect3.alpha = .1 rect3.speed = 3 local rect4 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect4.x = math.random(40,480) rect4.y = math.random(40,300) rect4.alpha = .1 rect4.speed = 4 local rect5 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect5.x = math.random(40,480) rect5.y = math.random(40,300) rect5:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect5.alpha = .5 rect5.speed = 5 local rect6 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect6.x = math.random(40,480) rect6.y = math.random(40,300) rect6:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect6.alpha = .5 rect6.speed = 4 local rect7 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect7.x = math.random(40,480) rect7.y = math.random(40,300) rect7:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect7.alpha = .5 rect7.speed = 3 local rect8 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect8.x = math.random(40,480) rect8.y = math.random(40,300) rect8:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect8.alpha = .5 rect8.speed = 2 local rect9 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect9.x = math.random(40,480) rect9.y = math.random(40,300) rect9:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect9.alpha = .5 rect9.speed = 1 ------------------------------------ ----------------------------------- local function movebackground1 ( self, event) if self.x \< -80 then self.x = math.random(550,800) self.y = math.random(0,300) self.width = math.random(40,80) self.height = math.random(40,80) self:rotate(0,179) else self.x = self.x - self.speed end end rect1.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect1) rect2.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect2) rect3.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect3) rect4.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect4) ----------------------------------- ----------------------------------- local function movebackl ( self, event) if self.x \< -80 then self.x = math.random(550,800) self.y = math.random(0,300) self.width = math.random(10,20) self.height = math.random(10,20) self:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) else self.x = self.x - self.speed end end rect5.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect5) rect6.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect6) rect7.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect7) rect8.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect8) rect9.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect9) ------------------------------------- ------------------------------------ local backgroun = display.newImageRect( scene.view,"background.jpg",700,480) backgroun.x = display.contentCenterX backgroun.y = display.contentCenterY backgroun.alpha = .4 backgroun.fill.effect = "filter.blurGaussian" backgroun.fill.effect.horizontal.blurSize = 10 backgroun.fill.effect.horizontal.sigma = 70 backgroun.fill.effect.vertical.blurSize = 10 backgroun.fill.effect.vertical.sigma = 70 local platform = display.newImageRect(scene.view,"platform.png",900,50) platform.x = 240 platform.y = 330 local platformu = display.newImageRect(scene.view,"platformu.png",780,50) platformu.x = 240 platformu.y = -10 platformu:rotate(180) ------------------------------------ --display ship and its functions of firing bullet when tapped on anywhere on screen-- ----------------------------------- function angleOfPoint( pt ) local x, y = pt.x, pt.y local radian = math.atan2(y,x) local angle = radian\*180/math.pi if angle \< 0 then angle = 360 + angle end return angle end -------------------------------- function angleBetweenPoints( a, b ) local x, y = b.x - a.x, b.y - a.y return angleOfPoint( { x=x, y=y } ) end function rotateTo( point, degrees ) local x, y = point.x, point.y local theta = math.rad(degrees) local pt = { x = x \* math.cos(theta) - y \* math.sin(theta), y = x \* math.sin(theta) + y \* math.cos(theta) } return pt end --------------------------------- function fireBullet(source, angle) local bullet = display.newImageRect(sceneGroup,"bu.png",20,20) bullet.x, bullet.y, bullet.rotation = source.x, source.y, angle physics.addBody( bullet ) bullet.surfaceType = "bullet" bullet.isSensor = true bullet.gravityScale = 0 local direction = rotateTo( {x=5,y=0}, angle ) bullet:applyForce( direction.x, direction.y, bullet.x, bullet.y ) end ----------------------------------- local ship = display.newImageRect(sceneGroup,"cannon.png",50,50) ship.x = 50 ship.y = 150 physics.addBody( ship,"dynamic") ship.surfaceType = "ship" ship.isSensor = true ---------------------------- function touch( e ) local angle = angleBetweenPoints( ship, e ) ship.rotation = angle-0 if (e.phase == "began") then elseif (e.phase == "moved") then elseif (e.phase == "ended") then fireBullet(ship, angle) score = score - 1 scoreText.text = "ballsleft: " .. score if score == 0 then print("zero") end end return true end Runtime:addEventListener("touch",touch) ------------------------------------ local newrect = display.newRect(sceneGroup,40,280,50,50) newrect:setFillColor(.5,.8) ---------------------------------- function activateJets(self,event) self:setLinearVelocity( 0, -120 ) end local function touchListener2( event ) if ( event.phase == "began" ) then event.target.alpha = 0.5 display.getCurrentStage():setFocus( event.target ) ship.enterFrame = activateJets Runtime:addEventListener("enterFrame",ship) elseif ( event.phase == "ended" or event.phase == "cancelled" ) then event.target.alpha = 1 display.getCurrentStage():setFocus( nil ) Runtime:removeEventListener("enterFrame",ship) end return true end newrect:addEventListener( "touch", touchListener2 ) Runtime:addEventListener( "collision", onCollision ) ------------------------------------- --start gameloop of triangles and towers ------------------------------------- local function gameloop () local rand = math.random(0,3) if (rand \< 1) then local toweru1 = display.newImageRect(sceneGroup,"toweru1.png",math.random(30,60),math.random(50,130)) toweru1.x = 600 toweru1.y = 60 toweru1.alpha = .8 toweru1:rotate( math.random(0,360)) physics.addBody( toweru1, "dynamic" ) toweru1.gravityScale = 0 toweru1.isSensor = true toweru1.surfaceType = "bad" toweru1:setFillColor (.2,.5,.9) transition.moveTo( toweru1, { x=-400, y=loop, time=move } ) elseif (rand \< 2) then local toweru11 = display.newImageRect(sceneGroup,"tower4.png",math.random(50,80),math.random(50,130)) toweru11.x = 600 toweru11.y = 240 toweru11.alpha = .8 toweru11:setFillColor(.5,.8,.9) toweru11:rotate( 180 ) toweru11:rotate( math.random(180,360) ) physics.addBody( toweru11, "dynamic" ) toweru11.gravityScale = 0 toweru11.isSensor = true toweru11.surfaceType = "bad" toweru11:setFillColor (.2,.5,.9) transition.moveTo( toweru11, { x=-400, y=loop1, time=move } ) elseif(rand\<3) then local rand = math.random(0,3) if ( rand \< 1) then local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70) triangle.x = 600 triangle.y = 70 triangle:rotate( 180 ) physics.addBody( triangle, "dynamic" ) triangle.gravityScale = 0 triangle.isSensor = true triangle.surfaceType = "good" transition.moveTo( triangle, { x=-400, y=loop, time=move} ) elseif ( rand \< 2) then local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70) triangle.x = 600 triangle.y = 245 physics.addBody( triangle, "dynamic" ) triangle.gravityScale = 0 triangle.isSensor = true triangle.surfaceType = "good" transition.moveTo( triangle, { x=-400, y=loop1, time=move } ) elseif ( rand \< 3) then local tower = display.newImageRect(sceneGroup,"sl.png",math.random(20,50),math.random(50,180)) tower.x = 600 tower.y = n tower.alpha = .8 physics.addBody(tower, "dynamic" ) tower.gravityScale = 0 tower.isSensor = true tower.surfaceType = "good" transition.moveTo( tower, { x=-400, y=n, time=move } ) end end end gameloopTimer = timer.performWithDelay(500,gameloop,0) ---\*\*\*error line \*\*\*---- gameloop() end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then physics.pause() elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view physics.stop() package.loaded[physics] = nil physics = nil end --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) ----------------------------------------------------------------------------------------- return scene

Is this 391? 

local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70)

If so, the error is saying that sceneGroup is nil at that point, but I don’t see any where that sceneGroup would be getting written over.

But it’s possible if you’re leaving the scene to go to another scene and you’re not cancelling the gameLoop timer and this scene gets removed, sceneGroup would become nil and trigger this error.

Rob

Do you have any more levels? If so, consider zipping up your project files and sharing them here. Don’t worry, we won’t steal your code. :slight_smile:

Also, do you need sceneGroup for something specific? If you don’t the parameter of [group] in newImageRect is optional.

https://docs.coronalabs.com/api/library/display/newImageRect.html

Thanks…And no its not about stealing code…I just make sure that I do not confuse or frustrate you by big and unnecessary code(Which I think is)…so sometimes I post code which is relevant to the error only…

But as you said I have only scenes. 1)menu 2)level1

The game is like, when ship collides with objects having surfacetype == bad then it should go back to menu.And its working but as the composer goes to menu it shows above error. I have displayed game objects and related function in function scene:show( event ) as I want. Also when I tried to cancel gameloop in collision function it showed me an error.

may code here is like a mess…

here’s dropbox link https://www.dropbox.com/s/fx21yt5kcs93up9/ProjectFiles.zip?dl=0

The code for the level1 is…

local composer = require( "composer" ) local scene = composer.newScene() local physics = require "physics" local gameLoopTimer -------------------------------------------- ------------------------------------------- local function destroyScene() composer.gotoScene( "menu", { time=800, effect="crossFade" }) composer.removeScene("level1") end local function endGame() timer.performWithDelay(200,function() destroyScene() end) end -------------------------------------------- ------------------------------------------- local score = 3 local score2 = 0 local scoreText local scoreText2 scoreText = display.newText("ballsleft:"..score,800,15,native.systemFontBold, 30) scoreText:setFillColor (1 ) scoreText2 = display.newText("score:"..score2,220,15,native.systemFontBold, 30) scoreText2:setFillColor (1 ) local function updateText() scoreText.text = "ballsleft: " .. score end local function updateText() scoreText.text = "score: " .. score2 end ---------------------------------------- --------------------------------------- local function onCollision( event ) if ( event.phase == "began" ) then local obj1 = event.object1 local obj2 = event.object2 if (obj1.surfaceType == "good" and obj2.surfaceType == "bad" ) then display.remove( obj1 ) elseif ( (obj1.surfaceType == "ship" ) and obj2.surfaceType == "good" ) then display.remove( obj2 ) score2 = score2 + 1 scoreText2.text = "score: " .. score2 score = score + 2 scoreText.text = "ballsleft: " .. score elseif ( (obj1.surfaceType == "ship" ) and (obj2.surfaceType == "bad" )) then display.remove( obj1 ) endGame() display.remove(scoreText) display.remove(scoreText2) end end end ---------------------------------------- --------------------------------------- local loop local loop1 local angleof local angleof1 local move = 5000 loop = 60 loop1 = 240 angleof = 180 angleof1 = 0 local function speedup() move = move - 300 end timer.performWithDelay(5000000,speedup,0) local function realgame() loop = math.random(120,180) loop1 = math.random(20,190) end local function realgame1() angleof = (math.random(50,180)) angleof1 = (math.random(50,180)) end local my = function() return realgame() end timer.performWithDelay(1000,my,1) local my1 = function() return realgame1() end timer.performWithDelay(1000000,my1,1) local n = math.random(140,230) ----------------------------------------- -------------------------------------------- local screenW, screenH, halfW = display.actualContentWidth, display.actualContentHeight, display.contentCenterX ------------------------------------------ ------------------------------------------ function scene:create( event ) math.randomseed(system.getTimer()) local sceneGroup = self.view physics.setDrawMode( "normal") end ------------------------------------------- -------------------------------------------- function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then elseif phase == "did" then physics.start() physics.setGravity(0, 12) ---------------------------- -- display rcect which are translated and having no influence of physics-- ---------------------------- local speed local rect1 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect1.x = math.random(40,480) rect1.y = math.random(40,300) rect1.alpha = .1 rect1.speed = 1 local rect2 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect2.x = math.random(40,480) rect2.y = math.random(40,300) rect2.alpha = .1 rect2.speed = 2 local rect3 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect3.x = math.random(40,480) rect3.y = math.random(40,300) rect3.alpha = .1 rect3.speed = 3 local rect4 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect4.x = math.random(40,480) rect4.y = math.random(40,300) rect4.alpha = .1 rect4.speed = 4 local rect5 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect5.x = math.random(40,480) rect5.y = math.random(40,300) rect5:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect5.alpha = .5 rect5.speed = 5 local rect6 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect6.x = math.random(40,480) rect6.y = math.random(40,300) rect6:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect6.alpha = .5 rect6.speed = 4 local rect7 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect7.x = math.random(40,480) rect7.y = math.random(40,300) rect7:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect7.alpha = .5 rect7.speed = 3 local rect8 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect8.x = math.random(40,480) rect8.y = math.random(40,300) rect8:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect8.alpha = .5 rect8.speed = 2 local rect9 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect9.x = math.random(40,480) rect9.y = math.random(40,300) rect9:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect9.alpha = .5 rect9.speed = 1 ------------------------------------ ----------------------------------- local function movebackground1 ( self, event) if self.x \< -80 then self.x = math.random(550,800) self.y = math.random(0,300) self.width = math.random(40,80) self.height = math.random(40,80) self:rotate(0,179) else self.x = self.x - self.speed end end rect1.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect1) rect2.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect2) rect3.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect3) rect4.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect4) ----------------------------------- ----------------------------------- local function movebackl ( self, event) if self.x \< -80 then self.x = math.random(550,800) self.y = math.random(0,300) self.width = math.random(10,20) self.height = math.random(10,20) self:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) else self.x = self.x - self.speed end end rect5.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect5) rect6.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect6) rect7.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect7) rect8.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect8) rect9.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect9) ------------------------------------- ------------------------------------ ------------------------------------ --display ship and its functions of firing bullet when tapped on anywhere on screen-- ----------------------------------- function angleOfPoint( pt ) local x, y = pt.x, pt.y local radian = math.atan2(y,x) local angle = radian\*180/math.pi if angle \< 0 then angle = 360 + angle end return angle end -------------------------------- function angleBetweenPoints( a, b ) local x, y = b.x - a.x, b.y - a.y return angleOfPoint( { x=x, y=y } ) end function rotateTo( point, degrees ) local x, y = point.x, point.y local theta = math.rad(degrees) local pt = { x = x \* math.cos(theta) - y \* math.sin(theta), y = x \* math.sin(theta) + y \* math.cos(theta) } return pt end --------------------------------- function fireBullet(source, angle) local bullet = display.newImageRect(sceneGroup,"bu.png",20,20) bullet.x, bullet.y, bullet.rotation = source.x, source.y, angle physics.addBody( bullet ) bullet.surfaceType = "bullet" bullet.isSensor = true bullet.gravityScale = 0 local direction = rotateTo( {x=5,y=0}, angle ) bullet:applyForce( direction.x, direction.y, bullet.x, bullet.y ) end ----------------------------------- local ship = display.newImageRect(sceneGroup,"cannon.png",50,50) ship.x = 50 ship.y = 150 physics.addBody( ship,"dynamic") ship.surfaceType = "ship" ship.isSensor = true ---------------------------- function touch( e ) local angle = angleBetweenPoints( ship, e ) ship.rotation = angle-0 if (e.phase == "began") then elseif (e.phase == "moved") then elseif (e.phase == "ended") then fireBullet(ship, angle) score = score - 1 scoreText.text = "ballsleft: " .. score if score == 0 then print("zero") end end return true end Runtime:addEventListener("touch",touch) ------------------------------------ local newrect = display.newRect(sceneGroup,40,280,50,50) newrect:setFillColor(.5,.8) ---------------------------------- function activateJets(self,event) self:setLinearVelocity( 0, -120 ) end local function touchListener2( event ) if ( event.phase == "began" ) then event.target.alpha = 0.5 display.getCurrentStage():setFocus( event.target ) ship.enterFrame = activateJets Runtime:addEventListener("enterFrame",ship) elseif ( event.phase == "ended" or event.phase == "cancelled" ) then event.target.alpha = 1 display.getCurrentStage():setFocus( nil ) Runtime:removeEventListener("enterFrame",ship) end return true end newrect:addEventListener( "touch", touchListener2 ) Runtime:addEventListener( "collision", onCollision ) ------------------------------------- --start gameloop of triangles and towers ------------------------------------- local function gameloop () local rand = math.random(0,3) if (rand \< 1) then local toweru1 = display.newImageRect(sceneGroup,"toweru1.png",math.random(30,60),math.random(50,130)) toweru1.x = 600 toweru1.y = 60 toweru1.alpha = .8 toweru1:rotate( math.random(0,360)) physics.addBody( toweru1, "dynamic" ) toweru1.gravityScale = 0 toweru1.isSensor = true toweru1.surfaceType = "bad" toweru1:setFillColor (.2,.5,.9) transition.moveTo( toweru1, { x=-400, y=loop, time=move } ) elseif (rand \< 2) then local toweru11 = display.newImageRect(sceneGroup,"tower4.png",math.random(50,80),math.random(50,130)) toweru11.x = 600 toweru11.y = 240 toweru11.alpha = .8 toweru11:setFillColor(.5,.8,.9) toweru11:rotate( 180 ) toweru11:rotate( math.random(180,360) ) physics.addBody( toweru11, "dynamic" ) toweru11.gravityScale = 0 toweru11.isSensor = true toweru11.surfaceType = "bad" toweru11:setFillColor (.2,.5,.9) transition.moveTo( toweru11, { x=-400, y=loop1, time=move } ) elseif(rand\<3) then local rand = math.random(0,3) if ( rand \< 1) then local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70) triangle.x = 600 triangle.y = 70 triangle:rotate( 180 ) physics.addBody( triangle, "dynamic" ) triangle.gravityScale = 0 triangle.isSensor = true triangle.surfaceType = "good" transition.moveTo( triangle, { x=-400, y=loop, time=move} ) elseif ( rand \< 2) then local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70) triangle.x = 600 triangle.y = 245 physics.addBody( triangle, "dynamic" ) triangle.gravityScale = 0 triangle.isSensor = true triangle.surfaceType = "good" transition.moveTo( triangle, { x=-400, y=loop1, time=move } ) elseif ( rand \< 3) then local tower = display.newImageRect(sceneGroup,"sl.png",math.random(20,50),math.random(50,180)) tower.x = 600 tower.y = n tower.alpha = .8 physics.addBody(tower, "dynamic" ) tower.gravityScale = 0 tower.isSensor = true tower.surfaceType = "good" transition.moveTo( tower, { x=-400, y=n, time=move } ) end end end gameloopTimer = timer.performWithDelay(500,gameloop,0) gameloop() end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then physics.pause() elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view physics.stop() package.loaded[physics] = nil physics = nil end --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) ----------------------------------------------------------------------------------------- return scene

code for menu…

local composer = require( "composer" ) local scene = composer.newScene() local widget = require "widget" local playBtn local function onPlayBtnRelease() composer.gotoScene( "level1", "fade", 500 ) return true end function scene:create( event ) local sceneGroup = self.view local background = display.newImageRect( "background.jpg", display.actualContentWidth, display.actualContentHeight ) background.anchorX = 0 background.anchorY = 0 background.x = 0 + display.screenOriginX background.y = 0 + display.screenOriginY playBtn = widget.newButton{ label="Play", labelColor = { default={255}, over={128} }, default="button.png", over="button-over.png", width=254, height=150, onRelease = onPlayBtnRelease } playBtn.x = display.contentCenterX playBtn.y = display.contentHeight - 125 sceneGroup:insert( background ) sceneGroup:insert( playBtn ) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then elseif phase == "did" then end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view if playBtn then playBtn:removeSelf() playBtn = nil end end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

I have to tell you.  I’ve looked at this post on two occasions and skipped it because there is just no way I have time to read that much code.

You should instead do one of two things:

  • narrow down the post to just the relevant code,  

- OR if you are completely confused about the issue - 

  • zip up your entire project and share a link to the zip file (use dropbox or other sharing site)

PS - I’ll be happy to look at the code if you zip it up, but I do have a question. You’ve used the word ‘proxy’, but I’m unclear on the reason for this.  What do you mean by proxy?

dropbox link  https://www.dropbox.com/s/fx21yt5kcs93up9/ProjectFiles.zip?dl=0

Display objects can take an optional “group” as the first parameter. Our test for the first parameter apparently calls that display group a proxy instead of a table. “Proxy” is coming from our error message.

Rob

You entirely missed my point.  The project you uploaded does not run.

I won’t help if I can’t run the project.  I want to see the problems in context.

So, try again.

Just zip up the project as it is.  Don’t re-arrange it, just zip it up and post the zip.

-Thanks

To everyone reading this and thinking, “Ed aren’t you being kinda harsh or difficult?”

Remember, folks.  When you ask for help, you are asking other people to spend their time (equals money for many of us).   So, don’t waste that time.

You should spend MORE time writing and preparing the question than it takes for the person helping you to respond.  

This means,

  • posting easy to read code,
  • providing whole examples (zipped) when it makes sense, and
  • going back and re-editing + formatting your post till it is beautiful.

I wrote about all this before here: https://forums.coronalabs.com/topic/55780-ask-a-better-question-get-a-better-answer/

Just zipped entire project as you said…https://www.dropbox.com/s/pohpv3qukrfoy3q/ballA.zip?dl=0

I actually do think Ed is a bit harsh, but he has a point. :slight_smile:

After looking at your code it looks like it is a scope issue of the sceneGroup. When you use local keyword when creating a variable, it is only available in that scope. Example, look at scene:create, where the sceneGroup is only valid in that particular function.

function scene:create( event ) local sceneGroup = self.view

There are a few places where you need to make sure you have the sceneGroup. For example, in 

function fireBullet(source, angle)

you try to use it, but it is not declared.

I downloaded the latest zip file and it does not match your original post.

At least one of the issues you’ve got in your original code is with the composer usage and setup.

I asked you to supply your original code unmodified, and you didn’t.  So, I can’t help. 

To be absolutely clear.  My plan was to:

  • take your original code, including the composer framework you set up.
  • Track down, fix, and mark the issues
  • Send you back a link to a zip file with the original and modified versions of the code.
  • Give you instructions on comparing them to see what I changed and why it fixed the problems.

However, I have burned all the time I can afford following up on this, so I’ll have to let someone else help.

@Yoger Games - is right about your use of sceneGroup out of scope.  Also, you’ve got some issues with code formatting that are probably making this hard to debug.  You may want to go back and clean up the code a bit then re-review it.  Lastly, I think you’ve got a few global functions that don’t need to be global  You can solve this through forward declaration.

Sach,

I wil try to help if I can.  

First, I think it is better if you do not have so much code within the scene:show function.  And I think that is likely where your problem begins.

Second, I think there is maybe 3 or 4 nested functions (the best I can tell, is alot(maybe not all) of the blocks of code in the scene:show are not indented. This makes it really hard for anyone trying to help.

Third,  gameLoop particularly, it is such a critical function in most games, it really needs to be outside of the scene:show.  

I usually create a section of code above the scene:create function where I place as many functions as I can, rather then embedding them (or nesting them) inside either the scene:create or scene:show.

So, try and break up that scene:show by moving all those functions, and move them above the scene:create.  Also, try to indent all of the blocks within any function and also with in every if-else  or if-elseif block.

Moving those function outside of the scene:show may create more errors… depending on what you have as local variables etc… but it is best, I believe. so if other errors pop-up once you move those functions, track them down and most you will likely be able to figure out and fix, but it may take some time. That is the life of coding.

As more bugs develop (and they will) this will make it easier to debug the other issues.

Also,  I think a common thing to do, is in scene:show do most(if not all) of your ‘addEventListeners’ in scene:show and then remove those listeners in scene:hide.   I see where you added several event listeners, but I do not see any removed in scene:hide

Here is 2 lines of your code I noticed you use for your gameLoop:

gameLoopTimer = timer.performWithDelay(500, gameLoop,0)

gameLoop()

Instead of those lines of code, why not use ‘enterFrame’ event for your game loop.

Runtime:addEventListener(“enterFrame”, gameLoop)   … put his line in scene:show and then as soon as the scene:shows the gameLoop will run.  But, be sure to put your gameLoop code outside of the scene:show …  as well as nearly all the other ones you have in scene:show… it is not mandatory to do that, I think (IMHO) better coding practice and in the long run will make code easier to read and debug.

Also, in your original post you note 'line 391; as the error.  it is good to also show the actual line of code, in case the line numbers are not shown in the sample code.

Question: is there an extra ‘end’ statement in this block?  it seems to me there is , but I can guess it does not flag an error because you have another if-elseif-type block that is not properly matched up.  A common problem with lots of nesting and embedded functions.  I know because I have made all done this a few times myself.  Also, I think (again i have not read all the code) that this function ‘touch’ should be ‘local’  

function touch( e ) local angle = angleBetweenPoints( ship, e ) ship.rotation = angle-0 if (e.phase == "began") then elseif (e.phase == "moved") then elseif (e.phase == "ended") then fireBullet(ship, angle) score = score - 1 scoreText.text = "ballsleft: " .. score if score == 0 then print("zero") end end return true end

I know this doesn’t solve you initial question as to the cause and fix for the error you mentioned.  But, I can’t figure it out as the code is presently.

I apologize if I miss-read any of the code and jumped to any wrong conclusions, since I only read little parts of it, but I hope there is some bit of help in what I am trying to say. 

Coding takes alot of time and involves alot-alot-alot of re-typing and re-doing of the code, until you gain more and more experience.

Keep at it, and best of luck.

Bob

Sach,

Correction on one thing.  The comment I made about the extra ‘end’ statement in one block of your code.  It was late after a long day when I read that, and did not notice the :

if score == 0 then  

so there is ‘not’ an extra end in that block.  The way it was formatted, and because I read thru it quickly, I missed that.

I think it’s important to interject a couple of tutorials here.

1. https://coronalabs.com/blog/2015/06/09/tutorial-the-value-of-well-formatted-code/

Formatting code is critical when you want to get help, but its even more critical for your own sanity. Please take the time to read this tutorial and understand the importance of indenting your code properly.  It also discusses nesting functions inside of functions which can serve a purpose once you understand “scope” better, but for now it’s best to try and avoid nesting (a function inside a function)  because its a way to avoid dealing with scope (what variables/objects/functions can see each other).

2. https://coronalabs.com/blog/2015/06/16/tutorial-scope-for-beginners/

Posts above talk about not doing everything inside of the scene:show() function. The general reason you would put as much as you did inside of scene:show() is to avoid dealing with scope. When you indent your code properly you can visually see how your code creates “blocks”:

local a = 10 local b = 20 if something then &nbsp; &nbsp; &nbsp; -- this is a block &nbsp; &nbsp; &nbsp; local a = 20 &nbsp; &nbsp; &nbsp; local b = b + 100 local c = 200 &nbsp; &nbsp; &nbsp; print( a, b, c ) -- print's 20, 120, 200 end print( a, b, nil ) -- prints 10, 20, nil

Variable ‘a’ inside the “if” statement is a different variable than the ‘a’ above the if statement. And if you consider the “c” variable, it only exists inside the “if” function. Now for “b” it was only declared “local” above the “if” statement, but it’s accessible inside inside the “if” without declaring it local.

For Composer scene, since the scene event functions are event triggered from other actions (composer.gotoScene()) you may want to have access to objects and functions in both scene:create() and scene:show() (as well as scene:hide(), etc.). If you only put the object in scene:create() then you can’t access it in scene:show(). But if you want Composer to actually work for you, you have to create things in scene:create() and start things in scene:show(). The solution: learn scope.

Define the object at the top:

local ball

inside scene:create()

function scene:create( event ) &nbsp; &nbsp; local sceneGroup = self.view &nbsp; &nbsp; ball = display.newCircle( sceneGroup, 100, 100, 20 ) end function scene:show( event ) &nbsp; &nbsp; &nbsp;ball.x = 200 &nbsp; &nbsp; &nbsp;ball.y = 200 end

So you declare the object/function that you need scene wide.

You do the work to create the object in scene:create()

Then manipulate the object in scene:show().

Once the scene starts and is running on the screen (spawning new balls) then that can happen outside of either scene event function, so it might make sense to put the ball spawning code in function outside of the event an then call the function inside scene:create to create the first one. Anyway, spend some effort reading the scope tutorial and trying to grasp the concept.

Between the two, it will go along way to helping you write more manageable code.

Rob

Is this 391? 

local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70)

If so, the error is saying that sceneGroup is nil at that point, but I don’t see any where that sceneGroup would be getting written over.

But it’s possible if you’re leaving the scene to go to another scene and you’re not cancelling the gameLoop timer and this scene gets removed, sceneGroup would become nil and trigger this error.

Rob

Do you have any more levels? If so, consider zipping up your project files and sharing them here. Don’t worry, we won’t steal your code. :slight_smile:

Also, do you need sceneGroup for something specific? If you don’t the parameter of [group] in newImageRect is optional.

https://docs.coronalabs.com/api/library/display/newImageRect.html

Thanks…And no its not about stealing code…I just make sure that I do not confuse or frustrate you by big and unnecessary code(Which I think is)…so sometimes I post code which is relevant to the error only…

But as you said I have only scenes. 1)menu 2)level1

The game is like, when ship collides with objects having surfacetype == bad then it should go back to menu.And its working but as the composer goes to menu it shows above error. I have displayed game objects and related function in function scene:show( event ) as I want. Also when I tried to cancel gameloop in collision function it showed me an error.

may code here is like a mess…

here’s dropbox link https://www.dropbox.com/s/fx21yt5kcs93up9/ProjectFiles.zip?dl=0

The code for the level1 is…

local composer = require( "composer" ) local scene = composer.newScene() local physics = require "physics" local gameLoopTimer -------------------------------------------- ------------------------------------------- local function destroyScene() composer.gotoScene( "menu", { time=800, effect="crossFade" }) composer.removeScene("level1") end local function endGame() timer.performWithDelay(200,function() destroyScene() end) end -------------------------------------------- ------------------------------------------- local score = 3 local score2 = 0 local scoreText local scoreText2 scoreText = display.newText("ballsleft:"..score,800,15,native.systemFontBold, 30) scoreText:setFillColor (1 ) scoreText2 = display.newText("score:"..score2,220,15,native.systemFontBold, 30) scoreText2:setFillColor (1 ) local function updateText() scoreText.text = "ballsleft: " .. score end local function updateText() scoreText.text = "score: " .. score2 end ---------------------------------------- --------------------------------------- local function onCollision( event ) if ( event.phase == "began" ) then local obj1 = event.object1 local obj2 = event.object2 if (obj1.surfaceType == "good" and obj2.surfaceType == "bad" ) then display.remove( obj1 ) elseif ( (obj1.surfaceType == "ship" ) and obj2.surfaceType == "good" ) then display.remove( obj2 ) score2 = score2 + 1 scoreText2.text = "score: " .. score2 score = score + 2 scoreText.text = "ballsleft: " .. score elseif ( (obj1.surfaceType == "ship" ) and (obj2.surfaceType == "bad" )) then display.remove( obj1 ) endGame() display.remove(scoreText) display.remove(scoreText2) end end end ---------------------------------------- --------------------------------------- local loop local loop1 local angleof local angleof1 local move = 5000 loop = 60 loop1 = 240 angleof = 180 angleof1 = 0 local function speedup() move = move - 300 end timer.performWithDelay(5000000,speedup,0) local function realgame() loop = math.random(120,180) loop1 = math.random(20,190) end local function realgame1() angleof = (math.random(50,180)) angleof1 = (math.random(50,180)) end local my = function() return realgame() end timer.performWithDelay(1000,my,1) local my1 = function() return realgame1() end timer.performWithDelay(1000000,my1,1) local n = math.random(140,230) ----------------------------------------- -------------------------------------------- local screenW, screenH, halfW = display.actualContentWidth, display.actualContentHeight, display.contentCenterX ------------------------------------------ ------------------------------------------ function scene:create( event ) math.randomseed(system.getTimer()) local sceneGroup = self.view physics.setDrawMode( "normal") end ------------------------------------------- -------------------------------------------- function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then elseif phase == "did" then physics.start() physics.setGravity(0, 12) ---------------------------- -- display rcect which are translated and having no influence of physics-- ---------------------------- local speed local rect1 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect1.x = math.random(40,480) rect1.y = math.random(40,300) rect1.alpha = .1 rect1.speed = 1 local rect2 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect2.x = math.random(40,480) rect2.y = math.random(40,300) rect2.alpha = .1 rect2.speed = 2 local rect3 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect3.x = math.random(40,480) rect3.y = math.random(40,300) rect3.alpha = .1 rect3.speed = 3 local rect4 = display.newImageRect(sceneGroup,"sl.png",math.random(40,80),math.random(40,80)) rect4.x = math.random(40,480) rect4.y = math.random(40,300) rect4.alpha = .1 rect4.speed = 4 local rect5 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect5.x = math.random(40,480) rect5.y = math.random(40,300) rect5:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect5.alpha = .5 rect5.speed = 5 local rect6 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect6.x = math.random(40,480) rect6.y = math.random(40,300) rect6:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect6.alpha = .5 rect6.speed = 4 local rect7 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect7.x = math.random(40,480) rect7.y = math.random(40,300) rect7:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect7.alpha = .5 rect7.speed = 3 local rect8 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect8.x = math.random(40,480) rect8.y = math.random(40,300) rect8:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect8.alpha = .5 rect8.speed = 2 local rect9 = display.newImageRect(sceneGroup,"sl.png",math.random(10,20),math.random(10,20)) rect9.x = math.random(40,480) rect9.y = math.random(40,300) rect9:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) rect9.alpha = .5 rect9.speed = 1 ------------------------------------ ----------------------------------- local function movebackground1 ( self, event) if self.x \< -80 then self.x = math.random(550,800) self.y = math.random(0,300) self.width = math.random(40,80) self.height = math.random(40,80) self:rotate(0,179) else self.x = self.x - self.speed end end rect1.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect1) rect2.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect2) rect3.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect3) rect4.enterFrame = movebackground1 Runtime:addEventListener("enterFrame",rect4) ----------------------------------- ----------------------------------- local function movebackl ( self, event) if self.x \< -80 then self.x = math.random(550,800) self.y = math.random(0,300) self.width = math.random(10,20) self.height = math.random(10,20) self:setFillColor(math.random(0.1,.9),math.random(0.1,.9),math.random(0.1,.9)) else self.x = self.x - self.speed end end rect5.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect5) rect6.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect6) rect7.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect7) rect8.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect8) rect9.enterFrame = movebackl Runtime:addEventListener("enterFrame",rect9) ------------------------------------- ------------------------------------ ------------------------------------ --display ship and its functions of firing bullet when tapped on anywhere on screen-- ----------------------------------- function angleOfPoint( pt ) local x, y = pt.x, pt.y local radian = math.atan2(y,x) local angle = radian\*180/math.pi if angle \< 0 then angle = 360 + angle end return angle end -------------------------------- function angleBetweenPoints( a, b ) local x, y = b.x - a.x, b.y - a.y return angleOfPoint( { x=x, y=y } ) end function rotateTo( point, degrees ) local x, y = point.x, point.y local theta = math.rad(degrees) local pt = { x = x \* math.cos(theta) - y \* math.sin(theta), y = x \* math.sin(theta) + y \* math.cos(theta) } return pt end --------------------------------- function fireBullet(source, angle) local bullet = display.newImageRect(sceneGroup,"bu.png",20,20) bullet.x, bullet.y, bullet.rotation = source.x, source.y, angle physics.addBody( bullet ) bullet.surfaceType = "bullet" bullet.isSensor = true bullet.gravityScale = 0 local direction = rotateTo( {x=5,y=0}, angle ) bullet:applyForce( direction.x, direction.y, bullet.x, bullet.y ) end ----------------------------------- local ship = display.newImageRect(sceneGroup,"cannon.png",50,50) ship.x = 50 ship.y = 150 physics.addBody( ship,"dynamic") ship.surfaceType = "ship" ship.isSensor = true ---------------------------- function touch( e ) local angle = angleBetweenPoints( ship, e ) ship.rotation = angle-0 if (e.phase == "began") then elseif (e.phase == "moved") then elseif (e.phase == "ended") then fireBullet(ship, angle) score = score - 1 scoreText.text = "ballsleft: " .. score if score == 0 then print("zero") end end return true end Runtime:addEventListener("touch",touch) ------------------------------------ local newrect = display.newRect(sceneGroup,40,280,50,50) newrect:setFillColor(.5,.8) ---------------------------------- function activateJets(self,event) self:setLinearVelocity( 0, -120 ) end local function touchListener2( event ) if ( event.phase == "began" ) then event.target.alpha = 0.5 display.getCurrentStage():setFocus( event.target ) ship.enterFrame = activateJets Runtime:addEventListener("enterFrame",ship) elseif ( event.phase == "ended" or event.phase == "cancelled" ) then event.target.alpha = 1 display.getCurrentStage():setFocus( nil ) Runtime:removeEventListener("enterFrame",ship) end return true end newrect:addEventListener( "touch", touchListener2 ) Runtime:addEventListener( "collision", onCollision ) ------------------------------------- --start gameloop of triangles and towers ------------------------------------- local function gameloop () local rand = math.random(0,3) if (rand \< 1) then local toweru1 = display.newImageRect(sceneGroup,"toweru1.png",math.random(30,60),math.random(50,130)) toweru1.x = 600 toweru1.y = 60 toweru1.alpha = .8 toweru1:rotate( math.random(0,360)) physics.addBody( toweru1, "dynamic" ) toweru1.gravityScale = 0 toweru1.isSensor = true toweru1.surfaceType = "bad" toweru1:setFillColor (.2,.5,.9) transition.moveTo( toweru1, { x=-400, y=loop, time=move } ) elseif (rand \< 2) then local toweru11 = display.newImageRect(sceneGroup,"tower4.png",math.random(50,80),math.random(50,130)) toweru11.x = 600 toweru11.y = 240 toweru11.alpha = .8 toweru11:setFillColor(.5,.8,.9) toweru11:rotate( 180 ) toweru11:rotate( math.random(180,360) ) physics.addBody( toweru11, "dynamic" ) toweru11.gravityScale = 0 toweru11.isSensor = true toweru11.surfaceType = "bad" toweru11:setFillColor (.2,.5,.9) transition.moveTo( toweru11, { x=-400, y=loop1, time=move } ) elseif(rand\<3) then local rand = math.random(0,3) if ( rand \< 1) then local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70) triangle.x = 600 triangle.y = 70 triangle:rotate( 180 ) physics.addBody( triangle, "dynamic" ) triangle.gravityScale = 0 triangle.isSensor = true triangle.surfaceType = "good" transition.moveTo( triangle, { x=-400, y=loop, time=move} ) elseif ( rand \< 2) then local triangle = display.newImageRect(sceneGroup,"triangle.png",70,70) triangle.x = 600 triangle.y = 245 physics.addBody( triangle, "dynamic" ) triangle.gravityScale = 0 triangle.isSensor = true triangle.surfaceType = "good" transition.moveTo( triangle, { x=-400, y=loop1, time=move } ) elseif ( rand \< 3) then local tower = display.newImageRect(sceneGroup,"sl.png",math.random(20,50),math.random(50,180)) tower.x = 600 tower.y = n tower.alpha = .8 physics.addBody(tower, "dynamic" ) tower.gravityScale = 0 tower.isSensor = true tower.surfaceType = "good" transition.moveTo( tower, { x=-400, y=n, time=move } ) end end end gameloopTimer = timer.performWithDelay(500,gameloop,0) gameloop() end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then physics.pause() elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view physics.stop() package.loaded[physics] = nil physics = nil end --------------------------------------------------------------------------------- scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) ----------------------------------------------------------------------------------------- return scene

code for menu…

local composer = require( "composer" ) local scene = composer.newScene() local widget = require "widget" local playBtn local function onPlayBtnRelease() composer.gotoScene( "level1", "fade", 500 ) return true end function scene:create( event ) local sceneGroup = self.view local background = display.newImageRect( "background.jpg", display.actualContentWidth, display.actualContentHeight ) background.anchorX = 0 background.anchorY = 0 background.x = 0 + display.screenOriginX background.y = 0 + display.screenOriginY playBtn = widget.newButton{ label="Play", labelColor = { default={255}, over={128} }, default="button.png", over="button-over.png", width=254, height=150, onRelease = onPlayBtnRelease } playBtn.x = display.contentCenterX playBtn.y = display.contentHeight - 125 sceneGroup:insert( background ) sceneGroup:insert( playBtn ) end function scene:show( event ) local sceneGroup = self.view local phase = event.phase if phase == "will" then elseif phase == "did" then end end function scene:hide( event ) local sceneGroup = self.view local phase = event.phase if event.phase == "will" then elseif phase == "did" then end end function scene:destroy( event ) local sceneGroup = self.view if playBtn then playBtn:removeSelf() playBtn = nil end end scene:addEventListener( "create", scene ) scene:addEventListener( "show", scene ) scene:addEventListener( "hide", scene ) scene:addEventListener( "destroy", scene ) return scene

I have to tell you.  I’ve looked at this post on two occasions and skipped it because there is just no way I have time to read that much code.

You should instead do one of two things:

  • narrow down the post to just the relevant code,  

- OR if you are completely confused about the issue - 

  • zip up your entire project and share a link to the zip file (use dropbox or other sharing site)

PS - I’ll be happy to look at the code if you zip it up, but I do have a question. You’ve used the word ‘proxy’, but I’m unclear on the reason for this.  What do you mean by proxy?

dropbox link  https://www.dropbox.com/s/fx21yt5kcs93up9/ProjectFiles.zip?dl=0