use of com.almasb.fxgl.input.UserAction 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.input.UserAction in project FXGL by AlmasB.
the class RangeTest method initInput.
@Override
protected void initInput() {
Input input = getInput();
input.addAction(new UserAction("Move Left") {
@Override
protected void onAction() {
playerControl.left();
}
}, KeyCode.A);
input.addAction(new UserAction("Move Right") {
@Override
protected void onAction() {
playerControl.right();
}
}, KeyCode.D);
input.addAction(new UserAction("Move Up") {
@Override
protected void onAction() {
playerControl.up();
}
}, KeyCode.W);
input.addAction(new UserAction("Move Down") {
@Override
protected void onAction() {
playerControl.down();
}
}, KeyCode.S);
}
use of com.almasb.fxgl.input.UserAction in project FXGL by AlmasB.
the class EntityPerformanceTest method initInput.
@Override
protected void initInput() {
getInput().addAction(new UserAction("Test Add") {
@Override
protected void onActionBegin() {
testAdd();
}
}, KeyCode.F);
getInput().addAction(new UserAction("Test Remove") {
@Override
protected void onActionBegin() {
testRemove();
}
}, KeyCode.G);
}
use of com.almasb.fxgl.input.UserAction in project FXGL by AlmasB.
the class BreakoutApp method initInput.
@Override
protected void initInput() {
getInput().addAction(new UserAction("Up 1") {
@Override
protected void onAction() {
paddle1.translateY(-PADDLE_SPEED);
}
}, KeyCode.W);
getInput().addAction(new UserAction("Down 1") {
@Override
protected void onAction() {
paddle1.translateY(PADDLE_SPEED);
}
}, KeyCode.S);
getInput().addAction(new UserAction("Up 2") {
@Override
protected void onAction() {
paddle2.translateY(-PADDLE_SPEED);
}
}, KeyCode.UP);
getInput().addAction(new UserAction("Down 2") {
@Override
protected void onAction() {
paddle2.translateY(PADDLE_SPEED);
}
}, KeyCode.DOWN);
}
use of com.almasb.fxgl.input.UserAction in project FXGL by AlmasB.
the class InputSample method initInput.
@Override
protected void initInput() {
// 1. get input service
Input input = FXGL.getInput();
// 2. add key/mouse bound actions
// when app is running press F to see output to console
input.addAction(new UserAction("Print Line") {
@Override
protected void onActionBegin() {
System.out.println("Action Begin");
}
@Override
protected void onAction() {
System.out.println("On Action");
}
@Override
protected void onActionEnd() {
System.out.println("Action End");
}
}, KeyCode.F);
}
Aggregations