Corona crashes on scene transition

Oh sorry I have been a bit confusing. The code posted before is from scene2. And as I go from scene2 to scene3 there is the problem. No scene transition there. Also in scene3 I am drawing the level and player under createScene(). My game logic is then in enterScene().

Also if I put in scene3 purgeScene(“scene2”) then I get the error from my posts above.

can you post your scene3 code?

While transitioning to scene3 I get also this error:

ERROR: physics.start() has not been called.

Could this be the reason?

Here is some code, scene3 has more than 1400 lines. :frowning:

--------------------------------------------------------------------------------- -- -- scene3.lua -- --------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) local scene = storyboard.newScene() --------------------------------------------------------------------------------- -- THE GAME --------------------------------------------------------------------------------- local height = display.contentHeight local width = display.contentWidth local xOffset, yOffset = 0, 0 local menuTip = display.newGroup() -- Tips content local tipEnergyLeft, tipEnergyRight, tipMenu local armTopL, armTopR, armBottomL, armBottomR, handL, handR, head, torso1, torso2, torso3, torso4, torso5, torso6, legTopL, legTopR, legBottomL, legBottomR, footL, footR local wallBottom, backGround, numberGrips local leftValue, rightValue local allElements = display.newGroup() local energy = display.newGroup() local grip = {} local button1, button2, button3, button4 local energyLimitText local myGameSettings local description = "" local function setFill(obj, param) obj:setFillColor(param[1], param[2], param[3], param[4] or 255) end local colorShirt = {251, 74, 74, 255} local colorSkin = {249, 203, 138, 255} local colorPants = {22, 127, 134, 255} local energyBar = { 78,132,132, 255} --SAVE GAME DATA local jsonCopy = require("jsonCopy") -- Called when the scene's view does not exist: function scene:createScene( event ) local group = self.view local physics = require( "physics" ) physics.setContinuous( false ) physics.setScale( 60 ) physics.start() --physics.setDrawMode( "hybrid" ) --COLLISION FILTERS buttonCollisionFilter1 = { categoryBits = 1, maskBits = 1 } -- left arm, right leg buttonCollisionFilter2 = { categoryBits = 2, maskBits = 2 } -- left leg, right arm leftLegCollisionFilter = { categoryBits = 4, maskBits = 36 } rightLegCollisionFilter = { categoryBits = 8, maskBits = 40 } climberCollisionFilter = { categoryBits = 16, maskBits = 48 } borderCollisionFilter = { categoryBits = 32, maskBits = 252 } leftArmCollisionFilter = { categoryBits = 64, maskBits = 96 } rightArmCollisionFilter = { categoryBits = 128, maskBits = 160 } limitFeetCollisionFilter = { categoryBits = 256, maskBits = 256 } hairCollisionFilter = { groupIndex = -2, categoryBits = 512, maskBits = 512 } routeId = storyboard.state.routeId myGameSettings = jsonCopy.loadTable("mygamesettings.json") local wrapText = require( "text" ) --SQLITE --get main route data for row in db:nrows("SELECT \* FROM main WHERE route\_id = " .. routeId) do routeW = row.width routeH = row.height routeName = row.route\_name description = row.description topHeight = row.topHeight difficulty = row.difficulty climbedStatus = row.climbed\_status count = row.count end myGameSettings.lastLevel = difficulty count = count + 1 local kl = ("UPDATE main SET count="..count .. " WHERE route\_id=" .. routeId) db:exec( kl ) local backGround2 = display.newRect(menuTip, 0,0,width,height) backGround2:setFillColor(255,250,229) backGround = display.newRect(0,(height-routeH),routeW,routeH) --backGround:setFillColor(255,250,229) backGround.alpha = 0 backGround.isHitTestable = true local function getWidth() local trueWidth if (routeW \> width) then trueWidth = routeW else trueWidth = width end return trueWidth end local heightLimit = display.newLine( allElements, 0,topHeight, getWidth(), topHeight ) heightLimit:setColor( 200, 200, 200 ) heightLimit.width = 2 local heightLimitText = display.newText (allElements, "MAX HEIGHT", width/2, topHeight, native.systemFont, 20) heightLimitText:setTextColor( 200, 200, 200 ) if (topHeight == 0) or (climbedStatus == 1) then heightLimit.isVisible = false heightLimitText.isVisible = false end ...

It could be.  I notice that you are requiruring physics inside createScene and making it local to createScene.  This will prevent you from accessing physics in other functions.  You should move that to the top of the scene file.

Also, generally with storyboard, you want to have things that kickoff movement delayed until enterScene().  I would move your physics.start() call there. 

Now for the error, are you using widgets like a widget.newTableView() anywhere?

OK, I am now requiring physics on the top, also I have moved all physics functions(addbody, addjoints) to enterScene. Unfortunatly no succes. I am pasting bellow the whole code for createScene, nothing special in it.

function scene:createScene( event ) local group = self.view --COLLISION FILTERS buttonCollisionFilter1 = { categoryBits = 1, maskBits = 1 } buttonCollisionFilter2 = { categoryBits = 2, maskBits = 2 } leftLegCollisionFilter = { categoryBits = 4, maskBits = 36 } rightLegCollisionFilter = { categoryBits = 8, maskBits = 40 } climberCollisionFilter = { categoryBits = 16, maskBits = 48 } borderCollisionFilter = { categoryBits = 32, maskBits = 252 } leftArmCollisionFilter = { categoryBits = 64, maskBits = 96 } rightArmCollisionFilter = { categoryBits = 128, maskBits = 160 } limitFeetCollisionFilter = { categoryBits = 256, maskBits = 256 } hairCollisionFilter = { groupIndex = -2, categoryBits = 512, maskBits = 512 } routeId = storyboard.state.routeId myGameSettings = jsonCopy.loadTable("mygamesettings.json") local wrapText = require( "text" ) --SQLITE --get main route data for row in db:nrows("SELECT \* FROM main WHERE route\_id = " .. routeId) do routeW = row.width routeH = row.height routeName = row.route\_name description = row.description topHeight = row.topHeight difficulty = row.difficulty status = row.status count = row.count end myGameSettings.lastLevel = difficulty count = count + 1 local kl = ("UPDATE main SET count="..count .. " WHERE route\_id=" .. routeId) db:exec( kl ) if (routeW \> width) then startX = (width - routeW)/2 else startX = 0 end local backGround2 = display.newRect(menuTip, 0,0,width,height) backGround2:setFillColor(255,250,229) backGround = display.newRect( startX,(height-routeH),routeW,routeH) backGround.alpha = 0 backGround.isHitTestable = true local heightLimit = display.newLine( allElements, startX,topHeight, getWidth(), topHeight ) heightLimit:setColor( 200, 200, 200 ) heightLimit.width = 2 energyLimitText = display.newText (menuTip, "TRY TO REST!", width/2-120, height/2, native.systemFontBold, 35) energyLimitText:setTextColor( 200, 200, 200 ) energyLimitText.isVisible = false local heightLimitText = display.newText (allElements, "MAX HEIGHT", width/2, topHeight, native.systemFont, 20) heightLimitText:setTextColor( 200, 200, 200 ) if (topHeight == 0) or (status == 1) then heightLimit.isVisible = false heightLimitText.isVisible = false end --GRIFI local level = require("routes.route"..routeId) numberGrips = level.countT() for row in db:nrows("SELECT \* FROM route WHERE route\_id = " .. routeId) do local gripX = row.grip\_location\_x local gripY = row.grip\_location\_y local gripType = row.grip\_type end local function createGrips() local originX = width/2 local originY = height -75 --they begin from bellow for i=1,numberGrips do local r = (level[i][3]) local x = originX + level[i][1] local y = originY - level[i][2] if (r == 1) then grip[i] = display.newImage( allElements, "images/grif1.png", x, y ) elseif (r == 2) then grip[i] = display.newImage( allElements, "images/grif2.png", x, y ) elseif (r == 3) then grip[i] = display.newImage( allElements, "images/grif3.png", x, y ) end grip[i].status = "active" grip[i].size = gripSize[r].s end end createGrips() allElements:insert( backGround ) backGround:toBack() local function getGoal() local trueGoal if (routeH \> height) then trueGoal = 75 else trueGoal = 75-routeH+height end return trueGoal end local function getHeight() local trueHeight if (routeH \< height) then trueHeight = 0 else trueHeight = -routeH+height end return trueHeight end local goal = display.newRect(allElements, startX,getHeight(),getWidth(),getGoal()) goal:setFillColor( 255, 205, 5 ) local goalText = display.newText(allElements, "it ends here", 80,height-routeH,native.systemFontBold, 35) goalText:setTextColor(90) tipEnergyLeft = display.newImage( energy, "images/left\_handA.png", 40, 20) tipEnergyRight = display.newImage( energy, "images/right\_handA.png", width-120, 20) tipMenu = display.newImage( menuTip, "images/open\_menuA.png", width - 230, height-45) if myGameSettings.tipsOn then tipEnergyLeft.isVisible = true tipEnergyRight.isVisible = true tipMenu.isVisible = true else tipEnergyLeft.isVisible = false tipEnergyRight.isVisible = false tipMenu.isVisible = false end armTopL = display.newRect(allElements,w-59,h+29,38,8) setFill(armTopL, colorSkin) armTopR = display.newRect(allElements,w+23,h+29,38,8) setFill(armTopR, colorSkin) armBottomL = display.newRect(allElements,w-105,h+29,48,8) setFill(armBottomL, colorSkin) armBottomR = display.newRect(allElements,w+59,h+29,48,8) setFill(armBottomR, colorSkin) handL = display.newCircle(allElements,w-115,h+29,r) handR = display.newCircle(allElements,w+117,h+29,r) setFill(handL, colorSkin) setFill(handR, colorSkin) head = display.newCircle(allElements,w,h-2,20) head:setFillColor(50,50,50) torso1 = display.newRect(allElements,w-23,h+20,46,18) setFill(torso1, colorShirt) torso2 = display.newRect(allElements,w-20,h+36,40,18) setFill(torso2, colorShirt) torso3 = display.newRect(allElements,w-17,h+52,34,18) setFill(torso3, colorShirt) torso4 = display.newRect(allElements,w-14,h+68,28,12) setFill(torso4, colorShirt) torso5 = display.newRect(allElements,w-16,h+78,32,16) setFill(torso5, colorShirt) torso6 = display.newRect(allElements,w-18,h+92,36,16) setFill(torso6, colorPants) legTopL = display.newRect(allElements,w-18,h+106,16,58) setFill(legTopL, colorPants) legTopR = display.newRect(allElements,w+2,h+106,16,58) setFill(legTopR, colorPants) legBottomL = display.newRect(allElements,w-15,h+162,10,68) setFill(legBottomL, colorSkin) legBottomR = display.newRect(allElements,w+5,h+162,10,68) setFill(legBottomR, colorSkin) footL = display.newImage(allElements,"images/footL.png", w-34,h+228) footR = display.newImage(allElements,"images/footR.png",w+3,h+228) bag = display.newRect(allElements,w-10,h+92,20,30) bag:setFillColor(50,50,50) head:toFront() -- BUTTONS local buttonRadius = 35 button1 = display.newCircle(allElements,(footL.x-4),(footL.y),buttonRadius) button1.myName = "footL" button2 = display.newCircle(allElements,(footR.x+4),(footR.y),buttonRadius) button2.myName = "footR" button3 = display.newCircle(allElements,(handL.x),(handL.y),buttonRadius) button3.myName = "handL" button4 = display.newCircle(allElements,(handR.x),(handR.y),buttonRadius) button4.myName = "handR" end

To the error. widget.newTableVIew() is being used in scene2. There the player is selecting his level.