Hi guys,
I’m having this error only when running my app on my ios device:
Application ‘segmentation’ exited abnormally with signal 11: Segmentation fault: 11
Basically what I do is take the code from the Bridge example (a bridge with joints) and insert it into scene1. Then I Add a touch listener on an object to change to scene2.
In scene2 right after scene:enterScene I call storyboard.removeAll() and boom! my app crashes and quits immediately leaving a segmentation fault. It’s frustrating because on the simulator runs perfectly fine.
I appreciate your help a lot, I even removed the touch joint listeners from the Bridge example thinking it had something to do with that. but keeps crashing every time.
thanks
[code]
– scene1.lua
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
local physics = require “physics”
physics.start(); physics.pause()
– forward declarations and other locals
local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5
local grass
local function changeE(event)
storyboard.gotoScene(“scene2”)
end
– BEGINNING OF YOUR IMPLEMENTATION
– Called when the scene’s view does not exist:
function scene:createScene( event )
local group = self.view
– create a grey rectangle as the backdrop
local background = display.newRect( 0, 0, screenW, screenH )
background:setFillColor( 128 )
– create a grass object and add physics (with custom shape)
grass = display.newImageRect( “grass.png”, screenW, 82 )
grass:setReferencePoint( display.BottomLeftReferencePoint )
grass.x, grass.y = 0, display.contentHeight
– define a shape that’s slightly shorter than image bounds (set draw mode to “hybrid” or “debug” to see)
local grassShape = { -halfW,-34, halfW,-34, halfW,34, -halfW,34 }
physics.addBody( grass, “static”, { friction=0.3, shape=grassShape } )
grass:addEventListener(“touch”,changeE)
– all display objects must be inserted into group
group:insert( background )
group:insert( grass)
end
– Called immediately after scene has moved onscreen:
function scene:enterScene( event )
local group = self.view
physics.start()
—code from the bridge example
local pole1 = display.newImage( “bamboo.png” )
pole1.x = 50; pole1.y = 250; pole1.rotation = -12
physics.addBody( pole1, “static”, { friction=0.5 } )
local pole2 = display.newImage( “bamboo.png” )
pole2.x = 430; pole2.y = 250; pole2.rotation = 12
physics.addBody( pole2, “static”, { friction=0.5 } )
group:insert(pole1)
group:insert(pole2)
local board = {}
local joint = {}
for j = 1,16 do
board[j] = display.newImage( “board.png” )
group:insert(board[j])
board[j].x = 20 + (j*26)
board[j].y = 150
physics.addBody( board[j], { density=2, friction=0.3, bounce=0.3 } )
– damping the board motion increases the “tension” in the bridge
board[j].angularDamping = 5000
board[j].linearDamping = 0.7
– create joints between boards
if (j > 1) then
prevLink = board[j-1] – each board is joined with the one before it
else
prevLink = pole1 – first board is joined to left pole
end
joint[j] = physics.newJoint( “pivot”, prevLink, board[j], 6+(j*26), 150 )
end
– join final board to right pole
joint[#joint + 1] = physics.newJoint( “pivot”, board[16], pole2, 6+(17*26), 150 )
end
– Called when scene is about to move offscreen:
function scene:exitScene( event )
local group = self.view
grass:removeEventListener(“touch”,changeE)
physics.stop()
end
– If scene’s view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
local group = self.view
package.loaded[physics] = nil
physics = nil
end
[/code] [import]uid: 74667 topic_id: 35324 reply_id: 335324[/import]