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.
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:
[lua]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[/lua]
[import]uid: 6084 topic_id: 8904 reply_id: 32497[/import]
: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. [import]uid: 11024 topic_id: 8904 reply_id: 32498[/import]
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. [import]uid: 10144 topic_id: 8904 reply_id: 32502[/import]
/Applications/CoronaSDK/Corona Terminal: line 9: 5259 Bus error "$path/Corona Simulator.app/Contents/MacOS/Corona Simulator" $\*
logout
[Process completed]
That’s what I’m getting in the terminal.
Sadly I rewrote the part where I canceled transitions, once like yours, once more crudely - neither stopped the crash.
I am usually good at this sort of thing but this just doesn’t make sense to me - has something changed in this build that would cause a crash? (I don’t mean like a bug, I mean something that previously worked fine intentionally doesn’t now?)
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
print("1")
corona.command()
print("2")
and the terminal output only showed “1” before crashing then you know the problem must be something to do with that command. [import]uid: 12108 topic_id: 8904 reply_id: 32513[/import]
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 [import]uid: 10144 topic_id: 8904 reply_id: 32514[/import]
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. [import]uid: 12108 topic_id: 8904 reply_id: 32521[/import]
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.