gameservices

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package gameservices provides a thin, provider-neutral API for platform game services: local player authentication, achievements, leaderboards, and native Game Center / Play Games UI overlays.

Operations run asynchronously and invoke their callbacks on the engine goroutine via core.Scope.Post so frames are never blocked and callbacks can safely update reactive signals. Check cx.Env().CanUseGameServices() to adapt UI on platforms without a native game service backend (Windows, Linux, the web, watchOS and mini programs), where calls answer ErrUnsupported.

Index

Constants

Leaderboard time scopes.

Leaderboard player scopes.

Variables

View Source
var (
	// ErrUnsupported is returned when the platform has no native game service
	// backend (core.Env.CanUseGameServices is false).
	ErrUnsupported = driver.ErrGameServicesUnsupported
	// ErrUnavailable is returned when the platform game service cannot be
	// reached or is not enabled in the current environment.
	ErrUnavailable = driver.ErrGameServicesUnavailable
	// ErrUnauthenticated is returned when an operation requires a signed-in
	// player and none is authenticated.
	ErrUnauthenticated = driver.ErrGameServicesUnauthenticated
	// ErrCancelled is returned when the user dismisses or cancels sign-in.
	ErrCancelled = driver.ErrGameServicesCancelled
)

Sentinel errors returned by package gameservices.

Functions

func Authenticate

func Authenticate(cx *core.Scope, done func(Player, error))

Authenticate signs the local player into the platform game service (such as Game Center on Apple platforms or Play Games Services on Android) and calls done on the engine goroutine with the authenticated Player or an error.

func LoadScores

func LoadScores(cx *core.Scope, leaderboardID string, scope PlayerScope, timeScope TimeScope, limit int, done func([]ScoreEntry, error))

LoadScores loads up to limit ranked entries from leaderboardID filtered by scope and timeScope, and calls done on the engine goroutine with the entries or an error. Non-positive limits default to 25 and values above 100 are clamped to 100.

func ReportAchievement

func ReportAchievement(cx *core.Scope, id string, percent float64, done func(error))

ReportAchievement reports completion progress for achievement id, clamping percent to the range 0..100 (100 unlocks the achievement), and calls done on the engine goroutine once the platform accepts or rejects the update.

func ShowAchievements

func ShowAchievements(cx *core.Scope)

ShowAchievements presents the platform's native achievements UI overlay when supported and authenticated; it does nothing where unsupported.

func ShowLeaderboard

func ShowLeaderboard(cx *core.Scope, leaderboardID string)

ShowLeaderboard presents the platform's native leaderboard UI overlay for leaderboardID when supported and authenticated; it does nothing when unsupported or when leaderboardID is empty.

func SubmitScore

func SubmitScore(cx *core.Scope, leaderboardID string, score int64, done func(error))

SubmitScore submits score to leaderboardID for the authenticated local player and calls done on the engine goroutine with the result.

Types

type Achievement

type Achievement = driver.GameAchievement

Achievement describes an achievement's reported completion progress (0..100).

type Player

type Player = driver.GamePlayer

Player identifies the local player signed into the platform game service.

type PlayerScope

type PlayerScope = driver.GamePlayerScope

PlayerScope selects which players LoadScores includes: Global or Friends.

type ScoreEntry

type ScoreEntry = driver.GameScoreEntry

ScoreEntry is one ranked leaderboard row returned by LoadScores.

type TimeScope

type TimeScope = driver.GameTimeScope

TimeScope selects the time window for LoadScores: AllTime, Week or Today.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL