简体   繁体   中英

Box2d & Libgdx Contact listener and inactive Bodies

Im working on a project with libgdx, box2d, in Java.

This is what my program does :

_ when collision between 2 fixtures, set one of the fixture's Body as not 'Active'

   myBody.setActive(false);

Problem :

I noticed that I get a Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1) in the logcat when I put this line, probably because the inactive body is still in the ContactListener.

I just got 1 ContactListener class in my main program.

How to remove / add a Body to the ContactListener ? I don't know if this is the solution, but I guess, could you help me ? I don't know how to solve this.

Thats because the contact handling in the listener ocurrs inside the world.step, and the world is blocked while its running.

You can add it to a list for example, for it to be set inactive once the world.step ends.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM