Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Sledge

Hello Impact Community,

I am afraid that I have more stupid questions about Box2D, please bear with me.

Firstly, do the following properties have any use in Box2D?:
type: ig.Entity.TYPE.B,
checkAgainst: ig.Entity.TYPE.A,
collides: ig.Entity.COLLIDES.PASSIVE,

The reason I ask is because I am trying to set the collision properties of certain objects so that they do not collide with each other using the following Box2D properties:
categoryBits: 0x002,	// collsion type enemy
maskBits: 0x001,		// collision type player

I read through the documentation here http://www.iforce2d.net/b2dtut/collision-filtering and http://www.box2dflash.org/docs/2.1a/reference/ but it is still not clear to me exactly how to implement this functionality. Currently I am simply defining both of the categoryBits and maskBits as properties of the player & enemy objects in their respective entity files.

Source here: https://github.com/Sledge-/KWSGame_RR_Box2D_v0.3

1 decade ago by Joncom

Firstly, do the following properties have any use in Box2D?:
Yes, you can use type and checkAgainst for firing events, but not collides for resolving collision because that is handled by Box2D. You're on the right track with collision filtering. Unfortunately I haven't yet had a chance to play with that.

1 decade ago by Sledge

The documentation associated with the flash & c++ versions of box2D collision filtering leads me to believe that box2D will automatically handle the filtering problem by simply defining the variables:

categoryBits: 0x0002,	// collsion type enemy
maskBits: 0x0001,  // collides with player

in each of your entitiy files and letting box2d do the rest. I can report that this is apparently not the case for the impact implementation of box2d.

I have also tried trivially overwriting the b2FilterData method:
b2FilterData :function(){
			this.parent();
		},

and then calling this.b2FilterData() in each entity's update loop. Has anyone else out there tried to implement this feature?

Also, is there a version of an un-baked box2d/lib.js file out there somewhere? I feel like I could figure this out if I could see the source. Thanks for any help you can give.

1 decade ago by Sledge

Sorry to bump an old thread... I am currently reading through the source code for box2d trying to figure out how to implement collision filtering in the box2d implementation of impact. In plugins/box2d/lib.js there is the following block of code:

...

E.b2DebugDraw=function(){};

E.prototype.b2DebugDraw=function(){};

E.prototype.SetFlags=function(){};

E.prototype.GetFlags=function(){};

E.prototype.AppendFlags=function(){};

...

At the risk of exposing my inexperience with advanced coding concepts I have to ask: what is the point of declaring empty function definitions in javascript (or any other language)?

1 decade ago by Joncom

Quote from Sledge
what is the point of declaring empty function definitions in javascript (or any other language)?
One possible reason is to make it obvious that such a function does exist (and has a purpose), even if it is perfectly acceptable to leave it "empty".

An example of this is the .ready function. It does absolutely nothing, until you overload it and give it functionality. Until then, it is just a placeholder. It still get's called, but just has no effect.

1 decade ago by collinhover

If you're reading through the box2d source code to figure out anything, I feel your pain. This might save you some time: http://www.iforce2d.net/b2dtut/
Page 1 of 1
« first « previous next › last »