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 andrecaribe

I'm doing some tests and ..

I drew, in Weltmeister, an ramp like a collision layer, but this ramp is converted to some rectangles, instead of something like a triangle.
This is bad because my car give some little jumps and create ramps in Weltmeister is long time and needs small tile size and great dimensions.

Example:
/><br />
<br />
Can I draw an triangle (or more) with Box2d (plugin) and put on my map? How I set the triangle to fixed, to not change position on collision and not suffer the effect of gravity?			</div>
		</div>
			<div class=

1 decade ago by andrecaribe

Ok, I got it. Triangle entity works fine.
I had some problems with the order of the vertices, if not in the correct order the object does not collide.

createBody: function() {
    var shapeDef = new b2.PolygonDef();
    shapeDef.vertexCount = 3;
    shapeDef.vertices[0].Set(    0.0           ,     0.0           );
    shapeDef.vertices[1].Set(-this.w * b2.SCALE,     0.0           );
    shapeDef.vertices[2].Set(    0.0           , -this.h * b2.SCALE);

    shapeDef.density = 1.0;
    shapeDef.friction = 1;
    shapeDef.restitution = 0;

    shapeDef.filter.maskBits = 0xffff & ~0x0001;
    shapeDef.filter.categoryBits = 0x0001;

    this.bodyDef = new b2.BodyDef();
    this.bodyDef.position.Set(this.pos.x * b2.SCALE, this.pos.y * b2.SCALE);

    this.body = ig.world.CreateBody(this.bodyDef);
    this.body.CreateShape(shapeDef);
}
Page 1 of 1
« first « previous next › last »