use of com.almasb.fxgl.entity.component.DrawableComponent in project FXGL by AlmasB.
the class DrawableSample method initGame.
@Override
protected void initGame() {
BiConsumer<GraphicsContext, Entity> drawing = (g, entity) -> {
Point2D pos = entity.getPosition();
g.setFill(Color.BLUE);
g.fillRect(pos.getX(), pos.getY(), 40, 40);
};
Entity entity = new Entity();
entity.setPosition(400, 300);
entity.addComponent(new DrawableComponent(drawing));
Entity entity2 = new Entity();
entity2.setPosition(750, 300);
entity2.addComponent(new DrawableComponent(drawing));
getGameWorld().addEntities(entity, entity2);
}
Aggregations