Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Problem with removing a fixture and world event listeners — Gideros Forum

Problem with removing a fixture and world event listeners

MikeHartMikeHart Guru
edited February 2012 in General questions
Hi Atilim,

during a frame, I remove the fixture and the body of a sprite:
	local body = self.xBody
	local fixture = self.xFixture
	body:destroyFixture(fixture)
	world:destroyBody(body)
So far so good. The problem is, sometimes an event listener like onEndContact
fires with the destroyed fixture and so crashes with an error like this:
main.lua:885: Fixture is already destroyed.
The offending line here is
local bodyB = fixtureB:getBody()
Imho it happens when there are more than one contacts in a frame and after the first the fixture is destroyed. The event listener is added tot he world. Before firing an event, Gideros should check if one of the two fixtures are already destroyed and not call the event listener then.

Cheers
Michael

Dislikes: r033rt

+1 -1 (+0 / -1 )Share on Facebook

Comments

Sign In or Register to comment.