Simulator crashes on "touch".

I hate to make a new post so soon, but I have been pulling my hair out all day with this. My debugger also does not work so I cant even debugg the issue with corona.

So I have this application which is basically the same as the balloon test but with different images etc etc. This works perfectly in the sim and on the device with tilt and all. I wanted to take this little beginner project a step further and add a menu screen.

So I used the Game Template available here:

http://developer.anscamobile.com/code/game-template

I modified it to my needs, and it also works perfectly. Buttons do what they should and it transitions into new scenes and back again correctly. So moving on I started to modify my current app that works alone, adding the Director class lines as needed.

The “play” button on the menu correctly changes scenes to my “game” physics work as expected and the object drop from gravity. However when I touch this screen Corona freezes and crashes. I have 3 objects (like the 3 balloons) and a pause button which when pressed would return you to the menu.lua.

I wish I could use the debugger but it just hangs and I have to force quit.

Here is the code for the original stand alone game, no menus or anything. It works like a charm.

local physics = require "physics"  
physics.start()  
physics.setGravity( 0, 9.8 )  
physics.setDrawMode("standard")  
  
system.setAccelerometerInterval( 100 )  
  
function onTilt( event )  
 physics.setGravity( ( 9.8 \* event.xGravity ), ( -9.8 \* event.yGravity ) )  
end  
   
Runtime:addEventListener( "accelerometer", onTilt )  
  
system.activate( "multitouch" )  
  
local background = display.newImage("bkg\_space.jpg")  
  
local moon = display.newImage("moon.png")  
moon.x = display.contentWidth/2  
physics.addBody(moon, { bounce = 0.3, radius = 60, friction = 1.0 } )  
  
local earth = display.newImage("earth.png")  
earth.x = moon.x -180  
physics.addBody(earth, { bounce = 0.2, radius = 115, friction = 1.0 } )  
  
local mars = display.newImage("mars.png")  
mars.x = moon.x +180  
physics.addBody(mars, { bounce = 0.5, radius = 55, friction = 1.0 } )  
  
local floor = display.newRect( 0, 960, display.contentWidth, 0 )  
local ceiling = display.newRect( 0, 0, display.contentWidth, 0 )  
local leftWall = display.newRect( 0, 0, 0, display.contentHeight )  
local rightWall = display.newRect( 640, 0, 0, display.contentHeight )  
  
physics.addBody(floor, "static", { bounce = 0.2, friction = 1.0 } )  
physics.addBody(ceiling, "static", { bounce = 0.2, friction = 1.0 } )  
physics.addBody(leftWall, "static", { bounce = 0.2, friction = 1.0 } )  
physics.addBody(rightWall, "static", { bounce = 0.2, friction = 1.0 } )  
  
function moveMoon(event)  
 local moon = event.target  
 moon:applyLinearImpulse( 0, -0.5, event.x, event.y )  
end  
  
moon:addEventListener("touch", moveMoon)  
earth:addEventListener("touch", moveMoon)  
mars:addEventListener("touch", moveMoon)  
  
display.setStatusBar(display.HiddenStatusBar)  

Now using the Game Template linked above I ran through the other files and observed how everything was working and tried to modify my main.lua above for a pause button etc. It is accessed from the menu.lua via the “play” button and it executes. But as stated above when I try to interact with it Corona crashes.

module(..., package.seeall)  
  
-- Main function - MUST return a display.newGroup()  
function new()  
 local ui = require("ui")  
  
 local localGroup = display.newGroup()  
  
 -- Background  
 local background = display.newImage("images/bk-default.png")  
 localGroup:insert(background)  
  
-- physics start   
local physics = require "physics"  
physics.start()  
physics.setGravity( 0, 9.8 )  
physics.setDrawMode("standard")  
  
system.setAccelerometerInterval( 100 )  
  
function onTilt( event )  
 physics.setGravity( ( 9.8 \* event.xGravity ), ( -9.8 \* event.yGravity ) )  
end  
   
Runtime:addEventListener( "accelerometer", onTilt )  
-- physics end  
  
-- multitouch  
system.activate( "multitouch" )  
-- multitouch  
  
-- pause button start  
  
 local pauseButton = nil  
 local function onPause ( event )  
 if event.phase == "release" and pauseButton.isActive then  
 director:changeScene("menu", "fade", 0,0,0)  
 end  
 end   
 pauseButton = ui.newButton{  
 defaultSrc = "images/btn-pause.png",  
 defaultX = 58,  
 defaultY = 58,   
 overSrc = "images/btn-pause.png",  
 overX = 58,  
 overY = 58,   
 onEvent = onPause,  
 id = "pauseButton",  
 text = "",  
 font = "Helvetica",  
 textColor = { 255, 255, 255, 255 },  
 emboss = false  
 }  
 pauseButton.x = 60  
 pauseButton.y = 60  
 pauseButton.isActive = true  
 localGroup:insert(pauseButton)  
  
-- pause button end  
  
-- physics objects start  
local moon = display.newImage("images/moon.png")  
localGroup:insert(moon)  
moon.x = display.contentWidth/2  
physics.addBody(moon, { bounce = 0.3, radius = 60, friction = 1.0 } )  
  
local earth = display.newImage("images/earth.png")  
localGroup:insert(earth)  
earth.x = moon.x -180  
physics.addBody(earth, { bounce = 0.2, radius = 115, friction = 1.0 } )  
  
local mars = display.newImage("images/mars.png")  
localGroup:insert(mars)  
mars.x = moon.x +180  
physics.addBody(mars, { bounce = 0.5, radius = 55, friction = 1.0 } )  
  
local floor = display.newRect( 0, 960, display.contentWidth, 0 )  
local ceiling = display.newRect( 0, 0, display.contentWidth, 0 )  
local leftWall = display.newRect( 0, 0, 0, display.contentHeight )  
local rightWall = display.newRect( 640, 0, 0, display.contentHeight )  
  
physics.addBody(floor, "static", { bounce = 0.2, friction = 1.0 } )  
physics.addBody(ceiling, "static", { bounce = 0.2, friction = 1.0 } )  
physics.addBody(leftWall, "static", { bounce = 0.2, friction = 1.0 } )  
physics.addBody(rightWall, "static", { bounce = 0.2, friction = 1.0 } )  
  
function moveMoon(event)  
 local moon = event.target  
 moon:applyLinearImpulse( 0, -0.5, event.x, event.y )  
end  
  
moon:addEventListener("touch", moveMoon)  
earth:addEventListener("touch", moveMoon)  
mars:addEventListener("touch", moveMoon)  
-- physics objects end  
  
-- hide status bar  
display.setStatusBar(display.HiddenStatusBar)  
-- hide status bar  
  
 unloadMe = function()  
 end  
  
 -- MUST return a display.newGroup()  
 return localGroup  
end  

Any help, pointers, or insight would be greatly appreciated. Learned a lot so far!

Thanks again,

-Marc [import]uid: 20431 topic_id: 5274 reply_id: 305274[/import]

What does the terminal logs say?

If you aren’t already, instead of opening the simulator, open the terminal (which will in turn open the simulator automatically). I find the Debugger totally useless, but the Terminal outputs are greatly valuable.

If the crash logs don’t help you find the problem, start putting print() statements all over your code.

I usually do that when testing to know when a specific function fires or to know the value of certain variables at certain times. It’s not a full blown debugger, but it works for the most part. [import]uid: 10835 topic_id: 5274 reply_id: 17515[/import]

/Applications/Corona.243/Corona Terminal: line 9: 7636 Bus error "$path/Corona Simulator.app/Contents/MacOS/Corona Simulator" $\*  

Here is the error it outputs, I have no idea what a 7636 Bus error is. I will try to search and see what I come up with. Thanks for your help so far, appreciate it. [import]uid: 20431 topic_id: 5274 reply_id: 17559[/import]

Well I built the app and installed it on a device and it works perfectly. I read someone had a similar issue with bus errors and a reboot of the machine fixed it so I will give that a go. [import]uid: 20431 topic_id: 5274 reply_id: 17564[/import]

Guys, please write your questions at Director’s sub-forum. I don’t have too much time to answer and I really didn’t see most of the topics created for Director. I’m sorry for that and I will appreciate if you all could go to this link:

http://developer.anscamobile.com/forums/director-class [import]uid: 8556 topic_id: 5274 reply_id: 18705[/import]

Well Ricadro,

The problem was not with Director at all as it turns out. I got really lucky commenting out lines of code and came across it quickly.

When I comment out system.activate( “multitouch” ) there is no issue with the app on iOS4. If I have multitouch activated it crashes…

So anyone know what the problem could be with that? I looked over the API and as far as I know I am calling it correctly. Maybe it needs to be placed somewhere specific? I have it after my physics. [import]uid: 20431 topic_id: 5274 reply_id: 18742[/import]

Thank YOU!!! I was ripping my hair out because of the multitouch issue. [import]uid: 16901 topic_id: 5274 reply_id: 22093[/import]