本文整理了Java中com.badlogic.gdx.physics.box2d.Body.getAngle()
方法的一些代码示例,展示了Body.getAngle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.getAngle()
方法的具体详情如下:
包路径:com.badlogic.gdx.physics.box2d.Body
类名称:Body
方法名:getAngle
[英]Get the angle in radians.
[中]获取以弧度为单位的角度。
代码示例来源:origin: libgdx/libgdx
/** Initialize the bodies and offsets using the current transforms. */
public void initialize (Body body1, Body body2) {
this.bodyA = body1;
this.bodyB = body2;
this.linearOffset.set(bodyA.getLocalPoint(bodyB.getPosition()));
this.angularOffset = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: libgdx/libgdx
/** Initialize the bodies and offsets using the current transforms. */
public void initialize (Body body1, Body body2) {
this.bodyA = body1;
this.bodyB = body2;
this.linearOffset.set(bodyA.getLocalPoint(bodyB.getPosition()));
this.angularOffset = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: libgdx/libgdx
/** Initialize the bodies, anchors, and reference angle using a world anchor point. */
public void initialize (Body bodyA, Body bodyB, Vector2 anchor) {
this.bodyA = bodyA;
this.bodyB = bodyB;
localAnchorA.set(bodyA.getLocalPoint(anchor));
localAnchorB.set(bodyB.getLocalPoint(anchor));
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: libgdx/libgdx
/** Initialize the bodies, anchors, and reference angle using a world anchor point. */
public void initialize (Body body1, Body body2, Vector2 anchor) {
this.bodyA = body1;
this.bodyB = body2;
this.localAnchorA.set(body1.getLocalPoint(anchor));
this.localAnchorB.set(body2.getLocalPoint(anchor));
referenceAngle = body2.getAngle() - body1.getAngle();
}
代码示例来源:origin: libgdx/libgdx
public void initialize (Body body1, Body body2, Vector2 anchor) {
this.bodyA = body1;
this.bodyB = body2;
this.localAnchorA.set(body1.getLocalPoint(anchor));
this.localAnchorB.set(body2.getLocalPoint(anchor));
referenceAngle = body2.getAngle() - body1.getAngle();
}
代码示例来源:origin: libgdx/libgdx
/** Initialize the bodies, anchors, and reference angle using a world anchor point. */
public void initialize (Body bodyA, Body bodyB, Vector2 anchor) {
this.bodyA = bodyA;
this.bodyB = bodyB;
localAnchorA.set(bodyA.getLocalPoint(anchor));
localAnchorB.set(bodyB.getLocalPoint(anchor));
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: libgdx/libgdx
/** Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis. */
public void initialize (Body bodyA, Body bodyB, Vector2 anchor, Vector2 axis) {
this.bodyA = bodyA;
this.bodyB = bodyB;
localAnchorA.set(bodyA.getLocalPoint(anchor));
localAnchorB.set(bodyB.getLocalPoint(anchor));
localAxisA.set(bodyA.getLocalVector(axis));
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: libgdx/libgdx
/** Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis. */
public void initialize (Body bodyA, Body bodyB, Vector2 anchor, Vector2 axis) {
this.bodyA = bodyA;
this.bodyB = bodyB;
localAnchorA.set(bodyA.getLocalPoint(anchor));
localAnchorB.set(bodyB.getLocalPoint(anchor));
localAxisA.set(bodyA.getLocalVector(axis));
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: libgdx/libgdx
private void renderBox (Body body, float halfWidth, float halfHeight) {
// get the bodies center and angle in world coordinates
Vector2 pos = body.getWorldCenter();
float angle = body.getAngle();
// set the translation and rotation matrix
transform.setToTranslation(pos.x, pos.y, 0);
transform.rotate(0, 0, 1, (float)Math.toDegrees(angle));
// render the box
renderer.begin(ShapeType.Line);
renderer.setTransformMatrix(transform);
renderer.setColor(1, 1, 1, 1);
renderer.rect(-halfWidth, -halfHeight, halfWidth * 2, halfHeight * 2);
renderer.end();
}
代码示例来源:origin: libgdx/libgdx
public void create () {
cam = new OrthographicCamera(48, 32);
cam.position.set(0, 15, 0);
renderer = new Box2DDebugRenderer();
world = new World(new Vector2(0, -10), true);
Body body = world.createBody(new BodyDef());
CircleShape shape = new CircleShape();
shape.setRadius(1f);
MassData mass = new MassData();
mass.mass = 1f;
body.setMassData(mass);
body.setFixedRotation(true);
body.setType(BodyType.KinematicBody);
body.createFixture(shape, 1);
body.setBullet(true);
body.setTransform(new Vector2(0, 0), body.getAngle());
body.setLinearVelocity(new Vector2(50f, 0));
}
代码示例来源:origin: libgdx/libgdx
Body box = boxes.get(i);
float angle = MathUtils.radiansToDegrees * box.getAngle(); // the rotation angle around the center
batch.draw(textureRegion, position.x - 1, position.y - 1, // the bottom left corner of the box, unrotated
1f, 1f, // the rotation center relative to the bottom left corner of the box
代码示例来源:origin: dsaltares/libgdx-cookbook
public Box(float x, float y, float box_width, float box_height, Texture texture) {
BOX_WIDTH = box_width;
BOX_HEIGHT = box_height;
boxTex = texture;
boxBody = createPolygon(BodyType.DynamicBody, x, y, 1f, 0.2f, 0.8f, box_width * 0.5f,
box_height * 0.5f);
this.x = x - (BOX_WIDTH*.5f);
this.y = y - (BOX_HEIGHT*.5f);
this.angle = boxBody.getAngle();
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-box2d
/** Initialize the bodies and offsets using the current transforms. */
public void initialize (Body body1, Body body2) {
this.bodyA = body1;
this.bodyB = body2;
this.linearOffset.set(bodyA.getLocalPoint(bodyB.getPosition()));
this.angularOffset = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: manuelbua/uracer-kotd
@Override
public void saveStateTo (EntityRenderState state) {
state.position.set(body.getPosition());
state.orientation = body.getAngle();
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-box2d
/** Initialize the bodies, anchors, and reference angle using a world anchor point. */
public void initialize (Body body1, Body body2, Vector2 anchor) {
this.bodyA = body1;
this.bodyB = body2;
this.localAnchorA.set(body1.getLocalPoint(anchor));
this.localAnchorB.set(body2.getLocalPoint(anchor));
referenceAngle = body2.getAngle() - body1.getAngle();
}
代码示例来源:origin: com.badlogicgames.gdx/gdx-box2d
/** Initialize the bodies, anchors, axis, and reference angle using the world anchor and world axis. */
public void initialize (Body bodyA, Body bodyB, Vector2 anchor, Vector2 axis) {
this.bodyA = bodyA;
this.bodyB = bodyB;
localAnchorA.set(bodyA.getLocalPoint(anchor));
localAnchorB.set(bodyB.getLocalPoint(anchor));
localAxisA.set(bodyA.getLocalVector(axis));
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
代码示例来源:origin: dsaltares/libgdx-cookbook
@Override
public boolean mouseMoved(int screenX, int screenY) {
viewport.getCamera().unproject(point.set(screenX, screenY, 0));
pointerBody.setTransform(point.x, point.y, pointerBody.getAngle() + 5 * MathUtils.degreesToRadians);
return true;
}
代码示例来源:origin: libgdx/box2dlights
protected void updateBody() {
if (body == null || staticLight) return;
final Vector2 vec = body.getPosition();
float angle = body.getAngle();
final float cos = MathUtils.cos(angle);
final float sin = MathUtils.sin(angle);
final float dX = bodyOffsetX * cos - bodyOffsetY * sin;
final float dY = bodyOffsetX * sin + bodyOffsetY * cos;
start.x = vec.x + dX;
start.y = vec.y + dY;
setDirection(bodyAngleOffset + angle * MathUtils.radiansToDegrees);
}
代码示例来源:origin: com.badlogicgames.box2dlights/box2dlights
protected void updateBody() {
if (body == null || staticLight) return;
final Vector2 vec = body.getPosition();
float angle = body.getAngle();
final float cos = MathUtils.cos(angle);
final float sin = MathUtils.sin(angle);
final float dX = bodyOffsetX * cos - bodyOffsetY * sin;
final float dY = bodyOffsetX * sin + bodyOffsetY * cos;
start.x = vec.x + dX;
start.y = vec.y + dY;
setDirection(bodyAngleOffset + angle * MathUtils.radiansToDegrees);
}
代码示例来源:origin: lycying/c2d-engine
/**
* set the position use the camera's viewPort . the zero-zero is on the left bottom
*/
public void setPosition(final float x,final float y){
super.setPosition(x, y);
model.body.setTransform(new Vector2(x,y).add(model.drawableOffsetX,model.drawableOffsetY).scl(1/RADIO), model.body.getAngle());
}
内容来源于网络,如有侵权,请联系作者删除!