use of com.almasb.fxgl.entity.action.Action in project FXGL by AlmasB.
the class EntityActionSample method initInput.
@Override
protected void initInput() {
getInput().addAction(new UserAction("Move Now") {
@Override
protected void onActionBegin() {
entity.getControl(ActionControl.class).clearActions();
entity.getControl(ActionControl.class).addAction(new MoveAction(getInput().getMouseXWorld(), getInput().getMouseYWorld()));
}
}, MouseButton.PRIMARY);
getInput().addAction(new UserAction("Queue Move Action") {
@Override
protected void onActionBegin() {
entity.getControl(ActionControl.class).addAction(new MoveAction(getInput().getMouseXWorld(), getInput().getMouseYWorld()));
}
}, MouseButton.SECONDARY);
getInput().addAction(new UserAction("Remove Current Action") {
@Override
protected void onActionBegin() {
Action<?> a = actionsView.getSelectionModel().getSelectedItem();
if (a != null) {
entity.getControl(ActionControl.class).removeAction(a);
}
}
}, KeyCode.F);
}
use of com.almasb.fxgl.entity.action.Action in project FXGL by AlmasB.
the class EntityActionSample method initInput.
@Override
protected void initInput() {
getInput().addAction(new UserAction("Move Now") {
@Override
protected void onActionBegin() {
entity.getComponent(ActionComponent.class).cancelActions();
entity.getComponent(ActionComponent.class).addAction(new MoveAction(getInput().getMouseXWorld(), getInput().getMouseYWorld()));
}
}, MouseButton.SECONDARY);
getInput().addAction(new UserAction("Queue Move Action") {
@Override
protected void onActionBegin() {
entity.getComponent(ActionComponent.class).addAction(new MoveAction(getInput().getMouseXWorld(), getInput().getMouseYWorld()));
}
}, MouseButton.PRIMARY);
getInput().addAction(new UserAction("Remove Current Action") {
@Override
protected void onActionBegin() {
Action a = actionsView.getSelectionModel().getSelectedItem();
if (a != null) {
entity.getComponent(ActionComponent.class).removeAction(a);
}
}
}, KeyCode.F);
}
Aggregations