:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/../../GodotApplePlugins/doc_classes/GKAchievement.xml. .. _class_GKAchievement: GKAchievement ============= **Inherits:** :ref:`RefCounted` **<** :ref:`Object` Represents an Apple Game Center achievement and provides helper methods to manage progress. .. rst-class:: classref-introduction-group Description ----------- Use ``GKAchievement`` to mirror the player's progress that you configured on App Store Connect. The static helpers expose the same workflows mentioned in the Achievements section of ``GameCenterGuide.md``: listing the player's reported achievements, resetting them during testing, and sending new completion percentages. Apple's API reference is available at `Apple's GKAchievement reference `__. List all achievements (straight from the guide): .. tabs:: .. code-tab:: gdscript GKAchievement.load_achievements(func(achievements: Array[GKAchievement], error: Variant) -> void: if error: print("Load achievement error %s" % error) else: for achievement in achievements: print("Achievement: %s" % achievement.identifier) ) Report progress and reset utilities: .. tabs:: .. code-tab:: gdscript var id := "a001" var percentage := 100.0 GKAchievement.load_achievements(func(achievements: Array[GKAchievement], error: Variant) -> void: if error: print("Load achievement error %s" % error) return for achievement in achievements: if achievement.identifier == id and not achievement.is_completed: achievement.percent_complete = percentage achievement.shows_completion_banner = true GKAchievement.report_achivement([achievement], func(submit_error: Variant) -> void: if submit_error: print("Error submitting achievement %s" % submit_error) else: print("Success!") ) ) GKAchievement.reset_achivements(func(error: Variant) -> void: if error: print("Error resetting achievements %s" % error) else: print("Reset complete") ) .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +---------------------------------+--------------------------------------------------------------------------------------+----------------------------------------------+ | :ref:`String` | :ref:`identifier` | ``"*uninitialized achievement identifier*"`` | +---------------------------------+--------------------------------------------------------------------------------------+----------------------------------------------+ | :ref:`bool` | :ref:`is_completed` | ``false`` | +---------------------------------+--------------------------------------------------------------------------------------+----------------------------------------------+ | :ref:`float` | :ref:`last_reported_date` | ``1765604200.0`` | +---------------------------------+--------------------------------------------------------------------------------------+----------------------------------------------+ | :ref:`float` | :ref:`percent_complete` | ``0.0`` | +---------------------------------+--------------------------------------------------------------------------------------+----------------------------------------------+ | :ref:`GKPlayer` | :ref:`player` | | +---------------------------------+--------------------------------------------------------------------------------------+----------------------------------------------+ | :ref:`bool` | :ref:`shows_completion_banner` | ``true`` | +---------------------------------+--------------------------------------------------------------------------------------+----------------------------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`load_achievements`\ (\ callback\: :ref:`Callable`\ ) |static| | +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`report_achivement`\ (\ achivements\: :ref:`Array`, callback\: :ref:`Callable`\ ) |static| | +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`reset_achivements`\ (\ callback\: :ref:`Callable`\ ) |static| | +--------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_GKAchievement_property_identifier: .. rst-class:: classref-property :ref:`String` **identifier** = ``"*uninitialized achievement identifier*"`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_identifier**\ (\ value\: :ref:`String`\ ) - :ref:`String` **get_identifier**\ (\ ) The achievement identifier configured on App Store Connect. .. rst-class:: classref-item-separator ---- .. _class_GKAchievement_property_is_completed: .. rst-class:: classref-property :ref:`bool` **is_completed** = ``false`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`bool` **get_is_completed**\ (\ ) Read-only flag that mirrors GameKit's ``isCompleted`` property. .. rst-class:: classref-item-separator ---- .. _class_GKAchievement_property_last_reported_date: .. rst-class:: classref-property :ref:`float` **last_reported_date** = ``1765604200.0`` :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`float` **get_last_reported_date**\ (\ ) .. container:: contribute There is currently no description for this property. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_GKAchievement_property_percent_complete: .. rst-class:: classref-property :ref:`float` **percent_complete** = ``0.0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_percent_complete**\ (\ value\: :ref:`float`\ ) - :ref:`float` **get_percent_complete**\ (\ ) The player's reported completion percentage (0-100). Update this and then call :ref:`report_achivement()` to submit it. .. rst-class:: classref-item-separator ---- .. _class_GKAchievement_property_player: .. rst-class:: classref-property :ref:`GKPlayer` **player** :ref:`🔗` .. rst-class:: classref-property-setget - :ref:`GKPlayer` **get_player**\ (\ ) The ``GKPlayer`` owner of this achievement, if GameKit was able to resolve it. .. rst-class:: classref-item-separator ---- .. _class_GKAchievement_property_shows_completion_banner: .. rst-class:: classref-property :ref:`bool` **shows_completion_banner** = ``true`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_shows_completion_banner**\ (\ value\: :ref:`bool`\ ) - :ref:`bool` **get_shows_completion_banner**\ (\ ) Matches Apple's ``showsCompletionBanner`` flag. Set it to true when you want the system to display the stock achievement toast when the progress hits 100%. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_GKAchievement_method_load_achievements: .. rst-class:: classref-method |void| **load_achievements**\ (\ callback\: :ref:`Callable`\ ) |static| :ref:`🔗` Loads the achievements that the local player has already reported. The callback is invoked with ``Array[GKAchievement]`` and a ``Variant`` error argument (``null`` on success, or a localized error string). .. rst-class:: classref-item-separator ---- .. _class_GKAchievement_method_report_achivement: .. rst-class:: classref-method |void| **report_achivement**\ (\ achivements\: :ref:`Array`, callback\: :ref:`Callable`\ ) |static| :ref:`🔗` Submits the new state for the provided achievements. The callback receives a single ``Variant`` that is ``null`` on success or contains an error string reported by GameKit. This is the method used in the "Report Progress" snippet inside ``GameCenterGuide.md``. .. rst-class:: classref-item-separator ---- .. _class_GKAchievement_method_reset_achivements: .. rst-class:: classref-method |void| **reset_achivements**\ (\ callback\: :ref:`Callable`\ ) |static| :ref:`🔗` Asks GameKit to clear every achievement for the local player. The callback receives ``null`` on success or a ``Variant`` with the error description, matching Apple's ``resetAchievements`` API. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`