Search in sources :

Example 1 with InputSequence

use of com.almasb.fxgl.input.InputSequence in project FXGL by AlmasB.

the class InputSequenceSample method initInput.

@Override
protected void initInput() {
    Input input = FXGL.getInput();
    var sequence = new InputSequence(KeyCode.Q, KeyCode.W, KeyCode.E, KeyCode.R);
    // the action fires only when the sequence above (Q, W, E, R) is complete
    // useful for input combos
    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");
        }
    }, sequence);
}
Also used : UserAction(com.almasb.fxgl.input.UserAction) Input(com.almasb.fxgl.input.Input) InputSequence(com.almasb.fxgl.input.InputSequence)

Aggregations

Input (com.almasb.fxgl.input.Input)1 InputSequence (com.almasb.fxgl.input.InputSequence)1 UserAction (com.almasb.fxgl.input.UserAction)1