In regular box2d does not support polyline bodies so you can solve it by creating multiple bodies and connect them.
But the problem is to reference an image to such a body. In spritekit it is simple but i would like to stay cross platform and wanna use X2.
what would be the best way to do that?
another problem that i am facing is the difference between a body and the size of the graphical image. Is it possible to increase the size of the image to fit the size of the body?
hi erel, i did manage to create a multiple bodies connected to each other with a WeldJoint but i dont like the physics behavior.
if a body fall on another body the bodies disconnect and connect again so you can tell it is not a single body.
in other framework i create a body with multiple fixtures (body shape in it)
this can also be done in X2 and i think this is the correct way to do that.
B4X:
Dim testbody As X2BodyWrapper
Dim bd As B2BodyDef
bd.BodyType = bd.TYPE_DYNAMIC
bd.Position.Set(WorldWidth/2,WorldHeight/2)
testbody = X2.CreateBodyAndWrapper(bd, Null,"testbody")
Dim circle As B2CircleShape
circle.Initialize(0.5)
Dim poly As B2PolygonShape
poly.Initialize
poly.SetAsBox(1,1)
testbody.Body.CreateFixture2(poly,1)
testbody.Body.CreateFixture2(circle,1)
it acts like a single body that has a complex shape and now we can create a much complex body but what i am missing is the Position property of the BodyShape
Every fixture has a shape which is used to check for collisions with other fixtures as it moves around the scene. A shape can be a circle or a polygon. Let's set up a circle shape...
1
2
3
b2CircleShape circleShape;
circleShape.m_p.Set(0, 0); //position, relative to body position
circleShape.m_radius = 1; //radius