use of com.almasb.fxgl.texture.ColoredTexture in project FXGL by AlmasB.
the class RemoveSelectedEntitesBug method initGame.
@Override
protected void initGame() {
Entity e1 = Entities.builder().at(100, 100).viewFromNode(new ColoredTexture(40, 30, Color.BLUE)).with(new SelectableComponent(true)).buildAndAttach(getGameWorld());
Entity e2 = Entities.builder().at(200, 100).viewFromNode(new Rectangle(40, 40, Color.RED)).with(new SelectableComponent(true)).buildAndAttach(getGameWorld());
Cursor cursor = getGameScene().getRoot().getCursor();
// this solves the issue, I think when mouse is clicked / released the game cursor is overridden
// e1.getView().setCursor(cursor);
// e2.getView().setCursor(cursor);
getGameWorld().selectedEntityProperty().addListener((o, oldEntity, newEntity) -> {
if (newEntity != null)
getGameWorld().removeEntity(newEntity);
});
}
Aggregations