Checking if the object reference is nil
won’t catch your issue.
The reference is NOT nil
at the time you’re trying to use it. It is invalid. i.e. It has value in it that references a non-existent object.
What is on lines:
- 4557
- 4651
- 4725
in main.lua
? As per the dialog, that is where the issue is or very near it.
You will get errors similar to that, this happens:
local obj = display.newCircle( ... )
-- Add body, etc. here
timer.performWithDelay( 1000, function() obj:applyImpulse( ... ) end )
display.remove( obj )
1-second later you’ll get a error.
This is effectively what is happening in your game. You have to hunt down:
- Where you’re destroying objects and do a cleanup: Cancel listeners and timers.
- Where you’re getting these errors (doing the actual action that is complained about) and check for valid objects.