I have two Runtimes. And when I go to another composer Scene… I get the error
Attempt to perform arithmetic on field ‘x’ (a nil value)
-- Circle-based collision detection local function hasCollidedCircle( obj1, obj2 ) if ( obj1 == nil ) then -- Make sure the first object exists return false end if ( obj2 == nil ) then -- Make sure the other object exists return false end local dx = obj1.x - obj2.x --// HERE IS THE ERROR local dy = obj1.y - obj2.y local distance = math.sqrt( dx\*dx + dy\*dy ) local objectSize = (obj2.contentWidth/2) + (obj1.contentWidth/2) if ( distance \< objectSize ) then return true end return false end hasCollidedCircle( obj1, obj2 )
I remove the Runtime here
local buttonBack = display.newImageRect(sceneGroup, "images/backButton.png", 150, 150) buttonBack.x = 100 buttonBack.y = 60 local function buttonBackListener() Runtime:removeEventListener("enterFrame", explosion ) Runtime:removeEventListener("touch", screenTouched) composer.gotoScene("menu3") end buttonBack:addEventListener("tap", buttonBackListener)
When can I be doing wrong.
Thanks for your help
and Happy new Year 2016