Game runs fine .268, crashes the simulator in .484

Hey guys,

It's been a long time since I've posted here but I'm having an issue and I was hoping someone else may have already had it and solved it by now given that I only just downloaded the new build.

Basically I have an app, also a template, of a simple side scrolling shooter. (You're a ship shooting asteroids and aliens but avoiding space bunnies.)

Anyway; it works fine in .268 but when I run it in the simulator or on my iPhone built from .484 I'm crashing.

The game uses physics, sprites and director and the crash occurs when moving the to game over screen which happens when you hit a space bunny or your lives reach 0.

HOWEVER - When I tried a timer (1 second delay, 5 second delay and 30 second delay) it all went fine.

So, my question is basically what has changed that might have caused this? Removing objects or canceling timers? Anything with physics?

It's very confusing to me as I haven't encountered anything like this before - if anyone has any insight please share it.

Thanks,
Peach

What is the exact error message in Terminal? And, how do you go about removing objects?

My remove object functions always look something like this:

1
2
3
4
5
6
7
local function removeAlien ()
    if alien and alien.removeSelf then
        transition.cancel ( alien.trans ) -- remove any lingering transition
        alien:removeSelf()  -- remove object
        alien = nil -- remove variable (nothing ever to be after this statement)
    end
end

Have you tried...

:canceling all transitions?

:maybe it's collision related? you could zero out all the physics attributes like velocity etc...

:I also had issues with functions still firing after gameover, referring to objects that were in the process of being cleaned up.

I will give this exact code a try and post again shortly.

If it helps, awesome! If not, thanks so much for the speedy response :)

Peach

Hey finnk,

Sorry - I was writing while you posted.

I'm sure I did cancel all transitions but it never hurts to double check. (Did that not cause any errors in .268? I'm just trying to isolate what's up.)

Alright, off to try BeyondtheTech's code. :)

What is the error message in Terminal?

(beyondthetech already asked this but I don't know if you noticed)

1
2
3
4
/Applications/CoronaSDK/Corona Terminal: line 9:  5259 Bus error               "$path/Corona Simulator.app/Contents/MacOS/Corona Simulator" $*
logout
 
[Process completed]

hm, well that appears to be referring to a line in Corona's code, not in your code. swell

What I would do at this point is put a bunch of print statements interspersed with the code around where the problem occurs to try to isolate exactly when the crash happens. Like, if you had

1
2
3
print("1")
corona.command()
print("2")

Hey jhocking,

I'm actually trying to do that now, but it's quite a long process; this was one of my first projects and is pretty lengthy.

Still, maybe I'll get some answers.

I hope to try and isolate it tonight but given it is now 5:30 AM that may not happen >.<'

Peach

peachpellen.goto("bed")

Resolved - kind of.

It works so I'm happy but I'm still not entirely sure where the issue lies.

How I fixed it was actually simple; rather than using director:changeScene within a function I gave it its own function which I called using a timer.

Calling it with a timer works, without the timer fails.

This still makes no sense to me but I'm glad it's working XD

Thanks guys!
Peach :)

jhocking.mute()

Ah, now I'm understanding better. Changing the scene pretty much kills everything that you've added into the group. This could be problematic because you may have running timers, transitions, and functions that get destroyed while they're still in progress.

For future reference, you need to make sure that timers and transitions are assigned a variable that you can access and cancel at will. The reason why your addition of a timer works may be that you've give the function enough time to exit itself completely before the director class destroys it.

oh I just thought of something related to that. I think somewhere between .268 and .484 they changed the behavior for how objects and event listeners are removed. The change was that now child objects are automatically removed along with their parent without needing to be explicitly removed.

That means you probably had a memory leak where you were failing to remove some child object that had a timer on it; now that the object gets removed, the timer has an error.

Or wait I bet it's related to a transition. The transition has an onComplete function to remove the object but now the object gets removed before the transition is complete, causing the error.

*rubs poor head*

It's still incredibly confusing; you said about making sure each timer and transition had a variable I could cancel at will - well, I was doing that.

That part is still identical - everything is the same as in .268 except the 1/10 second timer. (Timers and transitions are still being canceled as they were.)

Anyway - I still don't know exactly what it was but for now, at least, it's resolved so I can sleep shortly XD

I haven't had an issue like this in a long time, so I panicked, lol.

Peach :)

views:1559 update:2011/10/3 8:06:12
corona forums © 2003-2011