Sprite sprite = new Sprite(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2, 32, 32, mDTextureRegion, vbom); Body body = PhysicsFactory.createCircleBody(mPhysicsWorld, sprite, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(0.5f, 0.5f, 0.5f)); // create a simple circle body from the sprite scene.attachChild(sprite); Debug.i("ORIG MASS Y: " + body.getMassData().center.y); // this is just generated info FixtureDef fd = PhysicsFactory.createFixtureDef(10f, 1f, 1f, true); // high density fixture; it is a sensor, i.e. it won't affect collisions CircleShape cs = new CircleShape(); cs.setRadius(0.1f); // make it very small fd.shape = cs; cs.setPosition(new Vector2(0, -0.5f)); // attach below the current centre body.createFixture(fd); // attach to body Debug.i("NEW MASS Y: " + mDBody.getMassData().center.y); // the generated info changed mPhysicsWorld.registerPhysicsConnector(new PhysicsConnector(sprite, body, true, true));
CircleShape circleShape = new CircleShape(); circleShape.setRadius(0.75f); circleShape.setPosition(new Vector2(0,2)); //<------Add this FixtureDef circleFixtureDef = new FixtureDef(); circleFixtureDef.shape = circleShape; circleFixtureDef.restitution = 0.8f; rectangleBody.createFixture(circleFixtureDef);
CircleShape circleShape = new CircleShape(); circleShape.setRadius(circle.radius / ppt); circleShape.setPosition(new Vector2(circle.x / ppt, circle.y / ppt)); return circleShape;