| name | fxgl-minigames |
| description | Use and extend the FXGL built-in mini-game system — launch lock-picking, sweet-spot, trigger-mash, trigger-sequence (QTE), circuit-breaker, and random-occurrence mini-games via MiniGameService, handle success/failure results, configure difficulty, and author custom mini-games. Use this skill when adding interactive skill-check moments, lock- picking mechanics, quick-time events, button-mashing sequences, or any mini-game overlay.
|
| triggers | ["mini game","minigame","MiniGameService","lock pick","sweet spot","QTE","quick time event","trigger mash","circuit breaker","random occurrence"] |
| compatibility | Java 17+, FXGL 21.x. MiniGameService must be registered.
|
| category | fxgl/minigames |
| tags | ["fxgl","java","javafx","minigames"] |
| metadata | {"author":"fxgl-skills","version":"1.0","fxgl-version":"21.1"} |
| allowed-tools | ["Read","Write","Edit","Bash"] |
FXGL Mini-Game System
Setup
settings.addEngineService(MiniGameService.class);
Launching a Mini-Game
All mini-games share the same launch pattern:
getMiniGameService().startMiniGame(
new SomeMiniGame(),
result -> {
if (result.isSuccess()) {
} else {
}
}
);
The mini-game view overlays the GameScene. The underlying game loop continues unless the
mini-game itself pauses it.
Lock Picking Mini-Game
The player rotates a pick to find the sweet spot for each pin.
LockPickMiniGame lockPick = new LockPickMiniGame();
lockPick.setNumPins(3);
lockPick.setTimeLimit(Duration.seconds(30));
getMiniGameService().startMiniGame(lockPick, result -> {
LockPickResult lpr = (LockPickResult) result;
if (lpr.isSuccess()) {
openChest();
play("sounds/unlock.wav");
} else {
breakLockPick();
inc("lockPicksUsed", +1);
}
});
Sweet Spot Mini-Game
A bar oscillates; the player presses a key when it's inside the target zone.
SweetSpotMiniGame sweetSpot = new SweetSpotMiniGame();
sweetSpot.setBarSpeed(2.0);
sweetSpot.setTargetWidth(0.2);
sweetSpot.setTimeLimit(Duration.seconds());
getMiniGameService().startMiniGame(sweetSpot, result -> {
(SweetSpotResult) result;
(ssr.isSuccess()) {
ssr.getAccuracy();
()(accuracy * );
inc(, bonus);
}
});