本文整理了Java中com.badlogic.gdx.physics.box2d.Body.setTransform()
方法的一些代码示例,展示了Body.setTransform()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Body.setTransform()
方法的具体详情如下:
包路径:com.badlogic.gdx.physics.box2d.Body
类名称:Body
方法名:setTransform
[英]Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.
[中]设置实体原点和旋转的位置。这会断开任何接触并唤醒其他物体。操纵实体的变换可能会导致非物理行为。
代码示例来源:origin: libgdx/libgdx
private void launch () {
m_body.setTransform(new Vector2(0, 20), 0);
m_angularVelocity = (float)Math.random() * 100 - 50;
m_body.setLinearVelocity(new Vector2(0, -100));
m_body.setAngularVelocity(m_angularVelocity);
}
代码示例来源:origin: libgdx/libgdx
box.setTransform(30, 3, 0);
box = createBox(BodyType.StaticBody, 1.2f, 1.2f, 0);
box.setTransform(5, 2.4f, 0);
player = createPlayer();
player.setTransform(-40.0f, 4.0f, 0);
player.setFixedRotation(true);
box.setTransform((float)Math.random() * 10f - (float)Math.random() * 10f, (float)Math.random() * 10 + 6,
(float)(Math.random() * 2 * Math.PI));
circle.setTransform((float)Math.random() * 10f - (float)Math.random() * 10f, (float)Math.random() * 10 + 6,
(float)(Math.random() * 2 * Math.PI));
代码示例来源:origin: libgdx/libgdx
public CirclePlatform (int x, int y, float radius, float da) {
platform = createCircle(BodyType.KinematicBody, radius, 1);
platform.setTransform(x, y, 0);
platform.getFixtureList().get(0).setUserData("p");
platform.setAngularVelocity(da);
platform.setUserData(this);
}
代码示例来源:origin: libgdx/libgdx
public MovingPlatform (float x, float y, float width, float height, float dx, float dy, float da, float maxDist) {
platform = createBox(BodyType.KinematicBody, width, height, 1);
pos.x = x;
pos.y = y;
dir.x = dx;
dir.y = dy;
this.maxDist = maxDist;
platform.setTransform(pos, 0);
platform.getFixtureList().get(0).setUserData("p");
platform.setAngularVelocity(da);
platform.setUserData(this);
}
代码示例来源:origin: libgdx/libgdx
private Body createEdge (BodyType type, float x1, float y1, float x2, float y2, float density) {
BodyDef def = new BodyDef();
def.type = type;
Body box = world.createBody(def);
EdgeShape poly = new EdgeShape();
poly.set(new Vector2(0, 0), new Vector2(x2 - x1, y2 - y1));
box.createFixture(poly, density);
box.setTransform(x1, y1, 0);
poly.dispose();
return box;
}
代码示例来源: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
player.setLinearVelocity(vel.x, 0);
System.out.println("jump before: " + player.getLinearVelocity());
player.setTransform(pos.x, pos.y + 0.01f, 0);
player.applyLinearImpulse(0, 40, pos.x, pos.y, true);
System.out.println("jump, " + player.getLinearVelocity());
代码示例来源:origin: oakes/libgdx-examples
public void moveBody(Body body, float x, float y) {
x = x/scale;
y = y/scale;
body.setTransform(x, y, 0);
}
}
代码示例来源:origin: dozingcat/Vector-Pinball
public void setStartAndAngle(float x1, float y1, float angle) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x1 + (float)(this.length * Math.cos(angle));
this.y2 = y1 + (float)(this.length * Math.sin(angle));
// The "origin" is the midpoint of the wall, so we reposition it by calling
// setTransform with the midpoint.
wallBody.setTransform((x1+x2) / 2f, (y1+y2) / 2f, angle);
}
代码示例来源:origin: manuelbua/uracer-kotd
public void setWorldPosMt (Vector2 worldPosition, float orientationRads) {
body.setTransform(worldPosition, orientationRads);
resetState();
}
代码示例来源:origin: dozingcat/Vector-Pinball
public void applyRotation(Field field, double dt) {
currentAngle += dt*rotationSpeed;
if (currentAngle>TAU) currentAngle -= TAU;
if (currentAngle<0) currentAngle += TAU;
for(int i=0; i<elementIDs.length; i++) {
double angle = currentAngle + angleIncrement*i;
FieldElement element = field.getFieldElementById(elementIDs[i]);
Body body = element.getBodies().get(0);
double x = centerX + radius*Math.cos(angle);
double y = centerY + radius*Math.sin(angle);
body.setTransform((float)x, (float)y, body.getAngle());
}
}
代码示例来源:origin: danialgoodwin/dev
public void stopDodge() {
dodging = false;
// If the runner is hit don't force him back to the running position
if (!hit) {
body.setTransform(getUserData().getRunningPosition(), 0f);
}
}
代码示例来源:origin: lycying/c2d-engine
public void setRotation(float degrees){
super.setRotation(degrees);
model.body.setTransform(model.body.getPosition(), degrees*MathUtils.degreesToRadians);
}
代码示例来源:origin: manuelbua/uracer-kotd
public void setWorldPosMt (Vector2 worldPosition) {
body.setTransform(worldPosition, body.getAngle());
resetState();
}
代码示例来源:origin: narfman0/GDXWorld
private void shift(){
if(lastTouchedPolygon != null){
lastTouchedPolygon.getCenter().set(coordinates);
lastTouchedPolygon.setCenter(coordinates);
if(bodies.containsKey(lastTouchedPolygon))
bodies.get(lastTouchedPolygon).setTransform(coordinates, 0);
}else if(lastTouchedVertex != null){
lastTouchedVertex.set(coordinates);
polygonWindow.repopulate();
}
tiledMeshRenderer = null;
}
代码示例来源:origin: manuelbua/uracer-kotd
protected void toNormalRelativeAngle () {
// normalize body angle since it can grows unbounded
float angle = AMath.normalRelativeAngle(body.getAngle());
body.setTransform(body.getPosition(), angle);
}
}
代码示例来源: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: danialgoodwin/dev
public void dodge() {
if (!(jumping || hit)) {
body.setTransform(getUserData().getDodgePosition(), getUserData().getDodgeAngle());
dodging = true;
}
}
代码示例来源: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());
}
代码示例来源:origin: narfman0/GDXWorld
public static Body createEdge(World world, BodyType type, float x1, float y1,
float x2, float y2, float density) {
synchronized(world){
BodyDef def = new BodyDef();
def.type = type;
Body box = world.createBody(def);
EdgeShape boxShape = new EdgeShape();
boxShape.set(new Vector2(0, 0), new Vector2(x2 - x1, y2 - y1));
/*Fixture fixture = */box.createFixture(boxShape, density);
box.setTransform(x1, y1, 0);
boxShape.dispose();
return box;
}
}
内容来源于网络,如有侵权,请联系作者删除!