Skip to content

onActionEnd not triggered with removeEntities #1427

@mazingerz01

Description

@mazingerz01

As suggested here
this is a bug description and a minimal example which shows the problem.

An input is bound to MouseButton.PRIMARY -> onActionBegin/onActionEnd.
With getGameWorld().removeEntities() in the primaryMouse-onActionBegin override, the onActionEnd
is never triggered.

This is only the case if the to-be-removed entity's xProperty AND yProperty is bound. If one of these is not bound, everything works fine.

`
public class Main extends GameApplication {
private static final Logger LOGGER = Logger.get("Main");

@Override
protected void initSettings(GameSettings settings) {
}

@Override
protected void initInput() {
    Input input = getInput();
    input.addAction(new UserAction("mouse primary") {
        @Override
        protected void onActionBegin() {
            LOGGER.info("onActionBegin");
            getGameWorld().removeEntities(getGameWorld().getEntities().stream().toList());
            LOGGER.info("onActionBegin finished");
        }
        @Override
        protected void onActionEnd() {
            LOGGER.info("onActionEnd");
        }
    }, MouseButton.PRIMARY);
}

@Override
protected void initGame() {
    EntityBuilder entityBuilder = entityBuilder()
            .at(100, 100)
            .viewWithBBox(getCircleShape());
    Entity entity = entityBuilder.buildAndAttach();
    entity.xProperty().bind(getGameScene().getInput().mouseXWorldProperty());
    entity.yProperty().bind(getGameScene().getInput().mouseYWorldProperty());
}

private Circle getCircleShape() {
    Circle circle = new Circle(100);
    circle.setStroke(Color.MAGENTA);
    circle.setStrokeWidth(3);
    circle.getStrokeDashArray().addAll(14.0, 24.0);
    return circle;
}

public static void main(String[] args) {
    launch(args);
}

}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions