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); }
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));
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); }
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); }
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; }
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)); }
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());
public void moveBody(Body body, float x, float y) { x = x/scale; y = y/scale; body.setTransform(x, y, 0); } }
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); }
public void setWorldPosMt (Vector2 worldPosition, float orientationRads) { body.setTransform(worldPosition, orientationRads); resetState(); }
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()); } }
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); } }
public void setRotation(float degrees){ super.setRotation(degrees); model.body.setTransform(model.body.getPosition(), degrees*MathUtils.degreesToRadians); }
public void setWorldPosMt (Vector2 worldPosition) { body.setTransform(worldPosition, body.getAngle()); resetState(); }
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; }
protected void toNormalRelativeAngle () { // normalize body angle since it can grows unbounded float angle = AMath.normalRelativeAngle(body.getAngle()); body.setTransform(body.getPosition(), angle); } }
@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; }
public void dodge() { if (!(jumping || hit)) { body.setTransform(getUserData().getDodgePosition(), getUserData().getDodgeAngle()); dodging = true; } }
/** * 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()); }
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; } }