yes it may come to that. a bit tricky since the case in hand is a collision detection. and … did i mention it’s intermittent? if it were not I’d have killed it by now.
Next step is to get the ids of all the created and destroyed ships and show that the one colliding is from a previous generation. After that … dunno
That reminds me. Do all objects have an id method? It seems they might …
It’s a lot of code to read. And not clean enough to publish yet. I’ll post a bit when I get a chance.
They are stored in the table by their key, not by index:
FlyingObjects[ship] = ship
Storing by index wasn’t useful because when a Ship wants to die, it needs to remove itself from the table, but doesn’t know its index. This way it can just do FlyingObjects[self] = Explosion() or FlyingObjects[self] = nil.
Is there some reason why one can’t do it that way? It seems to work but is admittedly odd.
I’ll post some snippets shortly. That’s easier said than done of course …
@RonJeffries I’m just guessing without being able to see any code.
@RonJeffries - post code, there’s no point us guessing
@RonJeffries If they’re not physics objects and you’re doing all the calculations, then your not deleting them from the table correctly. When you delete them from the table, are you deleting them in reverse table order. If you have 10 objects in a table and you want to delete item position 4 and 8, you need to delete 8 first, then 4. If you delete 4 first, then item 8 becomes item 7 because everything moves down with the deletion of item 4.
Yes. As I say, these are not physical, just a bunch of little objects that know how to move and draw and detect collision via closeness. So I see no reason why they’d still be around … and even if they were, there’s no physics to trigger the collide. Mysterious, so far. I assume it’s my bug but so far not seeing it.
Here’s an example showing what happens if you don’t destroy an object. Tap the screen to create another ball. You’ll see that the ball sits on top of the balls that aren’t destroyed. Then uncomment the line of code in touched and thing will work the way you expect it.
if t.state==BEGAN then
if b then
--b:destroy() -- destroy the existing ball
@RonJeffries If they’re physics objects, you have to call “destroy” to remove then from the physics engine besides removing them from any table you have them in.
@RonJeffries - if the two are physics objects, they may take some time to be destroyed.
You need to use the destroy command on the physics objects before removing them from the tables, too ensure immediate destruction.
See the last part of this post
Not physical, sorry for not mentioning it.
Sooner or later, I’ll find it or refactor it away, I suppose. But there sure seems to be a ship hanging about that shouldn’t be there.
I’ll report what I find, and welcome ideas …