GitHubНачать

Справочник API собран из Go doc-комментариев в исходном коде и написан на английском языке.

package hostbridge

import "github.com/nsgo-dev/game/pkg/hostbridge"

Обзор

Package hostbridge is experimental: its API and documented formats may change in a minor release. See the API stability policy. connects a game's loop and mixer to an embedding page.

Указатель

Константы

const (
	// EventPause asks the game to pause its loop.
	EventPause = "pause"
	// EventResume ends a host pause; the loop resumes unless the game had paused it before.
	EventResume = "resume"
	// EventMute asks the game to suspend its mixer.
	EventMute = "mute"
	// EventUnmute resumes a mixer suspended by EventMute.
	EventUnmute = "unmute"
	// EventLoadingProgress carries {"loaded": n, "total": n} bytes or items.
	EventLoadingProgress = "loadingProgress"
	// EventLoaded reports that loading finished.
	EventLoaded = "loaded"
	// EventGameplayStart reports that the player is in gameplay.
	EventGameplayStart = "gameplayStart"
	// EventGameplayStop reports that gameplay stopped, such as at a menu or game over.
	EventGameplayStop = "gameplayStop"
)

Host event names. The embedding page sends EventPause, EventResume, EventMute and EventUnmute; the game posts the others.

Типы

type Bridge struct {
	// contains filtered or unexported fields
}

Bridge exposes the host embedding contract.

func Attach(cx *core.Scope, loop *game.Loop, mixer *sound.Mixer) *Bridge

Attach listens for the stable pause and mute events sent by an embedding host.

func (b *Bridge) GameplayStarted()

GameplayStarted reports gameplay start to the host.

func (b *Bridge) GameplayStopped()

GameplayStopped reports gameplay stop to the host.

func (b *Bridge) Loaded()

Loaded reports that loading finished.

func (b *Bridge) LoadingProgress(loaded, total int64)

LoadingProgress reports loading progress to the host.