1 decade ago by Sledge
I am attempting to use collision filtering in a Box2D game in order to improve gameplay. After reading through some of the documentation online, my understanding is that in order to implement this feature one must define collision groups, then implement the collision filter. They way I am doing this is by defining:
in my player.js entity, and:
in my enemy.js entity.
I then add the following method to main.js in order to override the default collision filter:
When I load the game it is clear that the filtering does not work and I am quite confused. Can anyone give me a hint as to what might be going wrong?
... categoryBits: 0x0001, // collsion type player maskBits: 0x0002, // collides with enemy ...
in my player.js entity, and:
... categoryBits: 0x0002, // collsion type enemy maskBits: 0x0001, // collides with player ...
in my enemy.js entity.
I then add the following method to main.js in order to override the default collision filter:
SetContactFilter: function() { this.parent(); };
When I load the game it is clear that the filtering does not work and I am quite confused. Can anyone give me a hint as to what might be going wrong?