本文整理了Java中org.jbox2d.dynamics.Body.getAngle()
方法的一些代码示例,展示了Body.getAngle()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.getAngle()
方法的具体详情如下:
包路径:org.jbox2d.dynamics.Body
类名称:Body
方法名:getAngle
[英]Get the angle in radians.
[中]获取以弧度为单位的角度。
代码示例来源:origin: libgdx/libgdx
/** Get the angle in radians.
* @return the current world rotation angle in radians. */
public float getAngle () {
return body.getAngle();
}
代码示例来源:origin: libgdx/libgdx
public void initialize(Body bA, Body bB) {
bodyA = bA;
bodyB = bB;
Vec2 xB = bodyB.getPosition();
bodyA.getLocalPointToOut(xB, linearOffset);
float angleA = bodyA.getAngle();
float angleB = bodyB.getAngle();
angularOffset = angleB - angleA;
}
}
代码示例来源:origin: libgdx/libgdx
/**
* Initialize the bodies, anchors, and reference angle using a world anchor point.
*
* @param bA
* @param bB
* @param anchor
*/
public void initialize(Body bA, Body bB, Vec2 anchor) {
bodyA = bA;
bodyB = bB;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
}
代码示例来源:origin: libgdx/libgdx
/**
* Initialize the bodies, anchors, and reference angle using the world anchor.
*
* @param b1
* @param b2
* @param anchor
*/
public void initialize(final Body b1, final Body b2, final Vec2 anchor) {
bodyA = b1;
bodyB = b2;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
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 b1, Body b2, Vec2 anchor, Vec2 axis) {
bodyA = b1;
bodyB = b2;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
bodyA.getLocalVectorToOut(axis, localAxisA);
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
}
代码示例来源:origin: jbox2d/jbox2d
public void initialize(Body bA, Body bB) {
bodyA = bA;
bodyB = bB;
Vec2 xB = bodyB.getPosition();
bodyA.getLocalPointToOut(xB, linearOffset);
float angleA = bodyA.getAngle();
float angleB = bodyB.getAngle();
angularOffset = angleB - angleA;
}
}
代码示例来源:origin: jbox2d/jbox2d
/**
* Initialize the bodies, anchors, and reference angle using a world anchor point.
*
* @param bA
* @param bB
* @param anchor
*/
public void initialize(Body bA, Body bB, Vec2 anchor) {
bodyA = bA;
bodyB = bB;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
}
代码示例来源:origin: jbox2d/jbox2d
/**
* Initialize the bodies, anchors, and reference angle using the world anchor.
*
* @param b1
* @param b2
* @param anchor
*/
public void initialize(final Body b1, final Body b2, final Vec2 anchor) {
bodyA = b1;
bodyB = b2;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
}
代码示例来源:origin: jbox2d/jbox2d
/**
* Initialize the bodies, anchors, axis, and reference angle using the world anchor and world
* axis.
*/
public void initialize(Body b1, Body b2, Vec2 anchor, Vec2 axis) {
bodyA = b1;
bodyB = b2;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
bodyA.getLocalVectorToOut(axis, localAxisA);
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
}
代码示例来源:origin: konsoletyper/teavm
context.save();
context.translate(center.x, center.y);
context.rotate(body.getAngle());
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
Shape shape = fixture.getShape();
代码示例来源:origin: HpWens/MeiWidgetView
private float getViewRotation(View view) {
Body body = (Body) view.getTag(R.id.wd_view_body_tag);
if (null != body) {
float angle = body.getAngle();
//注意换算
return (angle / 3.14f * 180f) % 360;
}
return 0;
}
代码示例来源:origin: stackoverflow.com
@Override
public boolean onAreaTouched( final TouchEvent pSceneTouchEvent, final ITouchArea pTouchArea,final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
if(pSceneTouchEvent.isActionMove()) {
final AnimatedSprite face = (AnimatedSprite) pTouchArea;
final Body faceBody = (Body)face.getUserData();
faceBody.setTransform(pSceneTouchEvent.getX() / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, pSceneTouchEvent.getY() / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, faceBody.getAngle());
return true;
}
return false;
}
代码示例来源:origin: com.github.almasb/fxgl-physics
public void initialize(Body bA, Body bB) {
bodyA = bA;
bodyB = bB;
Vec2 xB = bodyB.getPosition();
bodyA.getLocalPointToOut(xB, linearOffset);
float angleA = bodyA.getAngle();
float angleB = bodyB.getAngle();
angularOffset = angleB - angleA;
}
}
代码示例来源:origin: andmizi/MobikeTags
/**
* Initialize the bodies, anchors, axis, and reference angle using the world anchor and world
* axis.
*/
public void initialize(Body b1, Body b2, Vec2 anchor, Vec2 axis) {
bodyA = b1;
bodyB = b2;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
bodyA.getLocalVectorToOut(axis, localAxisA);
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
}
代码示例来源:origin: org.jbox2d/jbox2d-library
/**
* Initialize the bodies, anchors, axis, and reference angle using the world
* anchor and world axis.
*/
public void initialize(Body b1, Body b2, Vec2 anchor, Vec2 axis){
bodyA = b1;
bodyB = b2;
bodyA.getLocalPointToOut(anchor, localAnchorA);
bodyB.getLocalPointToOut(anchor, localAnchorB);
bodyA.getLocalVectorToOut(axis, localAxisA);
referenceAngle = bodyB.getAngle() - bodyA.getAngle();
}
}
代码示例来源:origin: jbox2d/jbox2d
void Break() {
// Create two bodies from one.
Body body1 = m_piece1.getBody();
Vec2 center = body1.getWorldCenter();
body1.destroyFixture(m_piece2);
m_piece2 = null;
BodyDef bd = new BodyDef();
bd.type = BodyType.DYNAMIC;
bd.position = body1.getPosition();
bd.angle = body1.getAngle();
Body body2 = getWorld().createBody(bd);
m_piece2 = body2.createFixture(m_shape2, 1.0f);
// Compute consistent velocities for new bodies based on
// cached velocity.
Vec2 center1 = body1.getWorldCenter();
Vec2 center2 = body2.getWorldCenter();
Vec2 velocity1 = m_velocity.add(Vec2.cross(m_angularVelocity, center1.sub(center)));
Vec2 velocity2 = m_velocity.add(Vec2.cross(m_angularVelocity, center2.sub(center)));
body1.setAngularVelocity(m_angularVelocity);
body1.setLinearVelocity(velocity1);
body2.setAngularVelocity(m_angularVelocity);
body2.setLinearVelocity(velocity2);
}
代码示例来源:origin: stackoverflow.com
public void drawSpriteForBody(Body body, Sprite sprite, SpriteBatch spriteBatch) {
Vector2 offset = new Vector2(sprite.getWidth() / 2f, sprite.getHeight() / 2f);
Vector2 position = body.getPosition().cpy().scl(Constants.PIXELS_PER_METER).sub(offset);
float rotation = body.getAngle() * MathUtils.radiansToDegrees;
sprite.setRotation(rotation);
sprite.setPosition(position.x, position.y);
sprite.draw(spriteBatch);
}
代码示例来源:origin: jbox2d/jbox2d
builder.setAngle(argBody.getAngle());
builder.setLinearVelocity(vecToPb(argBody.getLinearVelocity()));
builder.setAngularVelocity(argBody.getAngularVelocity());
代码示例来源:origin: jbox2d/jbox2d
ground.getLocalPointToOut(bd1.position, jd1.localAnchorA);
body1.getLocalPointToOut(bd1.position, jd1.localAnchorB);
jd1.referenceAngle = body1.getAngle() - ground.getAngle();
m_joint1 = (RevoluteJoint) m_world.createJoint(jd1);
代码示例来源:origin: InnoFang/Android-Code-Demos
void display() {
Vec2 pos = box2d.getBodyPixelCoord(body);
float a = body.getAngle();
rectMode(CENTER);
pushMatrix();
translate(pos.x, pos.y);
rotate(-a);
fill(175);
stroke(0);
rect(0, 0, w, h);
popMatrix();
}
内容来源于网络,如有侵权,请联系作者删除!