Hi,
I m new in Using Spine. There's been a few posts about similar questions, but none completely address my question:
I m able to use box2d in Spine with Region Attachment..
*code
AtlasAttachmentLoader atlasLoader = new AtlasAttachmentLoader(atlas){
public RegionAttachment newRegionAttachment (Skin skin, String name, String path) {
AtlasRegion region = atlas.findRegion(path);
Box2dAttachment attachment = new Box2dAttachment(name);
if (region == null)
throw new RuntimeException("Region not found in atlas: " + path + " (region attachment: " + name + ")");
attachment.setRegion(region);
return attachment;
}};
for (Slot slot : skeleton.getSlots()) {
if (!(slot.getAttachment() instanceof Box2dAttachment))continue;
Box2dAttachment attachment = (Box2dAttachment)slot.getAttachment();
PolygonShape boxPoly = new PolygonShape();
boxPoly.setAsBox(attachment.getWidth() / 2 * attachment.getScaleX(),
attachment.getHeight() / 2 * attachment.getScaleY(), vector.set(attachment.getX(), attachment.getY()),
attachment.getRotation() * MathUtils.degRad);
BodyDef boxBodyDef = new BodyDef();
boxBodyDef.type = BodyType.DynamicBody;
attachment.body = world.createBody(boxBodyDef);
attachment.body.setUserData(ud);
attachment.body.createFixture(boxPoly, 1).setUserData(slot.getData().getName());
boxPoly.dispose();
System.out.println(slot.getData().getName());
}
and "box2dattachment" calss is this
static class Box2dAttachment extends RegionAttachment {
Body body;
public Box2dAttachment (String name) {
super(name);
}
}
But is there is any way to use box 2d with Skinned mesh Attachment or Weighted Mesh attachment?
Would love some feedback, suggestions, ideas,
Thanks
*Note: English is not my native language so go easy with this