@jake72,
I assume you’re saying Yes to me and not Brent. Its hard to tell.
As far as how your organize you code, I think you should go with what makes sense for you. I (an and I think Brent) am a little confused by the level of indirection going on. That said, again use what works for you.
What about performance? Sure maybe there is a more efficient way to go, but until you measure you won’t know. I suggest not worrying about it for now. As long as your game performs well on your target devices you’re OK. Again, work the way that works best for you and change/learn as you go along. (Some folks will probably want to smack me for saying that, but I think right now you’re more worried about getting the darn thing working.)
Finally, let’s talk about the crash. I am not convinced the crash is occurring in that piece of code. I looked at the dump and from what I could see, your code died while executing the collision listener. Beyond that I can’t tell. I really need to see more code. In fact, if it isn’t too long the entire collision handler would be helpful.
Short of seeing all your code, please consider instrumenting the code with print statements like this:
[lua]if(scene) then
print(“A”, scene, scene.lives )
else
print(“A - SCENE MISSING”)
end
if scene.lives > 0 then
if(scene.hudLives) then
print(“B - scene.hudLives found” )
else
print(“B - scene.hudLives NOT FOUND” )
end
if(scene.hudLives,objects) then
print(“C - scene.hudLives.objects found” )
else
print(“C - scene.hudLives.objects NOT FOUND” )
end
if(scene.hudLives.objects[scene.lives]) then
print(“D - scene.hudLives.objects[scene.lives] found”, type(scene.hudLives.objects[scene.lives]) )
else
print(“D - scene.hudLives.objects[scene.lives] NOT FOUND” )
end
local theObj = scene.hudLives.objects[scene.lives]
if(theObj.removeSelf and type(theObj.removeSelf) == “function” ) then
print(“E - theObj is a valid display object” )
else
print(“E - theObj is NOT a valid display object” )
end
scene.hudLives.objects[scene.lives]:removeSelf()
if(scene.hudLives) then
print(“F - scene.hudLives found” )
else
print(“F - scene.hudLives NOT FOUND” )
end
scene.lives = scene.lives - 1
end
if(scene.lives) then
print(“G”, scene, scene.lives )
else
print(“G - SCENE MISSING”)
end[/lua]
Yes, this is horrible and unsophisticated, but I’d love to see the output nonetheless. Without access to your code, consider this my ‘remote debugger’. 
Just use the code, run till failure and grab the output of the console. Note: If the console crashes too, you may have to redirect the output to a file and get the file contents.
If you get stuck on this write back and we’ll figure out a way to get some debug output. Oh, and anyone still reading at this point who has a better suggestion for getting a sense of what this code is doing without actually having it, please shoot your suggestions this way.
-Ed
[import]uid: 110228 topic_id: 33332 reply_id: 132443[/import]