Fixture destroy check

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
elkiwydev
Prole
Posts: 8
Joined: Tue Jul 01, 2014 5:56 pm

Fixture destroy check

Post by elkiwydev »

Hi everyone,
I have a little problem.. I'm stuck in the error "Attempt to use a destroyed fixture" and I can't find a solution..
How do I check if a fixture is destroyed or not? I tried with "a==nil" (a is the fixture) but is not nil,is just destroyed..
Also every method I try to apply to the fixture like a:getBody() return the error..
I want to do an if statement like

Code: Select all

if *the fixture is destroyed* then
    --do nothing
else
   --do the work with the fixture
end
Please help :cry:
User avatar
OmarShehata
Party member
Posts: 259
Joined: Tue May 29, 2012 6:46 pm
Location: Egypt
Contact:

Re: Fixture destroy check

Post by OmarShehata »

This is generally a code design flaw.

Why is it that your code is trying to use a destroyed fixture anyway? If you're keeping them in an array, make sure you remove the destroyed ones, or mark them as destroyed in a table until they get removed.

Alternatively, you can try running a test through pcall, to catch the error, but you should really redesign your code to avoid this situation in the first place.

If you can give more info on how things are set up we can try to come up with more specific solutions :)
Post Reply

Who is online

Users browsing this forum: secretsue92 and 80 guests