@Override public boolean keyDown (int keyCode) { if (keyCode == Input.Keys.COMMA) { if (m_bullet != null) { world.destroyBody(m_bullet); m_bullet = null; } { CircleShape shape = new CircleShape(); shape.setRadius(0.25f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; fd.restitution = 0.05f; BodyDef bd = new BodyDef(); bd.type = BodyType.DynamicBody; bd.bullet = true; bd.position.set(-31, 5); m_bullet = world.createBody(bd); m_bullet.createFixture(fd); m_bullet.setLinearVelocity(new Vector2(400, 0)); } } return false; }
shape.set(new Vector2(-40.0f, 0), new Vector2(40, 0)); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.3f;
shape.setRadius(1); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 1.0f;
shape.set(new Vector2(-20, 0), new Vector2(20, 0)); FixtureDef fd = new FixtureDef(); fd.shape = shape; ground.createFixture(fd); shape.setAsBox(0.5f, 4.0f, new Vector2(4.0f, 0), 0.5f * (float)Math.PI); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.6f; shape.setAsBox(0.75f, 0.75f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.6f;
FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; shape.set(vertices); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 1.0f; shape.setRadius(0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 1.0f;
shape.setAsBox(0.5f, 0.125f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; shape.setAsBox(0.5f, 0.125f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 1.0f; FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 1.0f;
shape.set(new Vector2(-40.0f, 0), new Vector2(40, 0)); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.3f; polygon.set(vertices); FixtureDef triangleShapeDef = new FixtureDef(); triangleShapeDef.shape = polygon; triangleShapeDef.density = 1.0f; FixtureDef boxShapeDef = new FixtureDef(); boxShapeDef.shape = polygon; boxShapeDef.density = 1; circle.setRadius(1); FixtureDef circleShapeDef = new FixtureDef(); circleShapeDef.shape = circle; circleShapeDef.density = 1.0f;
shape.setAsBox(0.6f, 0.125f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f;
FixtureDef sd = new FixtureDef(); sd.shape = shape; sd.density = 0; poly1.set(vertices); FixtureDef sd1 = new FixtureDef(); sd1.shape = poly1; sd1.density = 4.0f; poly2.set(vertices); FixtureDef sd2 = new FixtureDef(); sd2.shape = poly2; sd2.density = 2.0f; shape.setAsBox(0.5f, 0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 1.0f;
shape.setAsBox(10.0f, 0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.friction = 0.8f;
shape.setAsBox(0.5f, 0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 1.0f;
shape.setAsBox(0.5f, 0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; shape.set(vertices); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; shape.setRadius(0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f;
shape.setAsBox(0.5f, 0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; shape.set(vertices); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f; shape.setRadius(0.5f); FixtureDef fd = new FixtureDef(); fd.shape = shape; fd.density = 20.0f;
FixtureDef fixtureDef = new FixtureDef(); fixtureDef.shape = groundPoly; fixtureDef.filter.groupIndex = 0;
public Enemy(Texture texture, float x, float y) { this.texture = texture; enemyBody = createPolygon(BodyType.DynamicBody, x, y, 1f, 0f, 0.8f, ENEMY_WIDTH * 0.5f, ENEMY_HEIGHT * 0.5f, CATEGORY_ENEMY, MASK_ENEMY); //To identify the specific instance when collisions happen enemyBody.setUserData(this); // Sensor shape to detect other bodies getting close to him CircleShape circle = new CircleShape(); circle.setRadius(1f); FixtureDef sensorFD = new FixtureDef(); sensorFD.isSensor = true; sensorFD.shape = circle; sensorFD.filter.categoryBits = CATEGORY_SENSOR; sensorFD.filter.maskBits = MASK_SENSOR; enemyBody.createFixture(sensorFD); }
private void createGround() { BodyDef bd = new BodyDef(); bd.position.set(0, 0); bd.type = BodyType.StaticBody; PolygonShape shape = new PolygonShape(); shape.setAsBox(VIEWPORT_WIDTH, 1); FixtureDef fd = new FixtureDef(); fd.density = 1; fd.friction = 0.5f; fd.restitution = 0.5f; fd.shape = shape; world.createBody(bd).createFixture(fd); shape.dispose(); }
private Body createPolygon(BodyType type, float x, float y, float d, float r, float f, float halfwidth, float halfheight) { BodyDef bodyDef = new BodyDef(); bodyDef.type = type; bodyDef.position.set(SCENE_WIDTH*0.5f+x,y); bodyDef.angle=0; Body square = world.createBody(bodyDef); FixtureDef fixtureDef=new FixtureDef(); fixtureDef.density=d; fixtureDef.restitution=r; fixtureDef.friction=f; fixtureDef.shape=new PolygonShape(); ((PolygonShape) fixtureDef.shape).setAsBox(halfwidth, halfheight); square.createFixture(fixtureDef); fixtureDef.shape.dispose(); return square; }
private Body createPolygon(BodyType type, float x, float y, float d, float r, float f, float halfwidth, float halfheight) { BodyDef bodyDef = new BodyDef(); bodyDef.type = type; bodyDef.position.set(x,y); bodyDef.angle=45 * MathUtils.degreesToRadians; Body square = world.createBody(bodyDef); FixtureDef fixtureDef=new FixtureDef(); fixtureDef.density=d; fixtureDef.restitution=r; fixtureDef.friction=f; fixtureDef.shape=new PolygonShape(); ((PolygonShape) fixtureDef.shape).setAsBox(halfwidth, halfheight); square.createFixture(fixtureDef); fixtureDef.shape.dispose(); return square; }
private Body createPolygon(BodyType type, float x, float y, float d, float r, float f, float halfwidth, float halfheight) { BodyDef bodyDef = new BodyDef(); bodyDef.type = type; bodyDef.position.set(SCENE_WIDTH*0.5f+x,y); bodyDef.angle=0; Body square = world.createBody(bodyDef); FixtureDef fixtureDef=new FixtureDef(); fixtureDef.density=d; fixtureDef.restitution=r; fixtureDef.friction=f; fixtureDef.shape=new PolygonShape(); ((PolygonShape) fixtureDef.shape).setAsBox(halfwidth, halfheight); square.createFixture(fixtureDef); fixtureDef.shape.dispose(); return square; }
public InteractiveTileObject(PlayScreen screen, MapObject object){ this.object = object; this.screen = screen; this.world = screen.getWorld(); this.map = screen.getMap(); this.bounds = ((RectangleMapObject) object).getRectangle(); BodyDef bdef = new BodyDef(); FixtureDef fdef = new FixtureDef(); PolygonShape shape = new PolygonShape(); bdef.type = BodyDef.BodyType.StaticBody; bdef.position.set((bounds.getX() + bounds.getWidth() / 2) / MarioBros.PPM, (bounds.getY() + bounds.getHeight() / 2) / MarioBros.PPM); body = world.createBody(bdef); shape.setAsBox(bounds.getWidth() / 2 / MarioBros.PPM, bounds.getHeight() / 2 / MarioBros.PPM); fdef.shape = shape; fixture = body.createFixture(fdef); }