use of com.almasb.fxgl.entity.state.StateComponent in project FXGL by AlmasB.
the class RobotFactory method newRobot.
@Spawns("robot")
public Entity newRobot(SpawnData data) {
BodyDef bd = new BodyDef();
bd.setFixedRotation(true);
bd.setType(BodyType.DYNAMIC);
PhysicsComponent physics = new PhysicsComponent();
// friction 0 to avoid sticking to walls
physics.setFixtureDef(new FixtureDef().friction(0).density(0.25f));
physics.setBodyDef(bd);
physics.addGroundSensor(new HitBox("GROUND_SENSOR", new Point2D(275 / 2 - 3, 260 - 5), BoundingShape.box(6, 10)));
return entityBuilder(data).from(data).bbox(new HitBox("head", new Point2D(110, 50), BoundingShape.box(70, 70))).bbox(new HitBox("body", new Point2D(110, 120), BoundingShape.box(40, 130))).bbox(new HitBox("legs", new Point2D(275 / 2 - 25, 125 * 2), BoundingShape.box(40, 10))).scaleOrigin(275 / 2, 125 * 2).collidable().with(new StateComponent()).with(physics).with(new RobotComponent()).build();
}
Aggregations