Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: AchievementService

[19:7] extends: EngineService

Wraps FXGL's AchievementService, the engine service that watches registered achievements and unlocks them when their bound world property crosses the trigger value. Reached at runtime via fxgl.getAchievementService; obtain a wrapper via adopt. Achievements are registered through GameSettings before launch (see GameSettings.getAchievements) -- the service exposes only read-only inspection.

Methods

  • AchievementService (Ajo = null)

    Creates an AchievementService wrapper. Empty by default; the (Ajo) form wraps an existing instance from fxgl.getAchievementService.

    • @p Ajo is an optional AussomJavaObject around an AchievementService.
  • adopt (object Ajo)

    Wraps an existing AchievementService AussomJavaObject.

    • @p Ajo is an AussomJavaObject around an AchievementService.
    • @r A new wrapper.
  • getAchievementByName (string Name)

    Returns the registered achievement with the given name. Throws if no such achievement exists.

    • @p Name is the achievement name.
    • @r An Achievement wrapper.
  • getAchievementsCopy ()

    Returns the entire registered-achievement list as a list of Achievement wrappers. Useful for building achievement UI that enumerates every achievement (locked + unlocked).

    • @r A list of Achievement wrappers.
  • onInit ()

    EngineService onInit lifecycle hook.

  • onMainLoopStarting ()

    EngineService onMainLoopStarting lifecycle hook.

  • onGameReady (object PropertyMapObj)

    EngineService onGameReady lifecycle hook with the world PropertyMap.

  • write (object BundleObj)

    Persists achievement state into a Bundle.

  • read (object BundleObj)

    Restores achievement state from a Bundle.