Die API-Referenz stammt aus den Go-Doc-Kommentaren im Quellcode und ist auf Englisch verfasst.
package hostbridge
import "github.com/nsgo-dev/game/pkg/hostbridge"Übersicht
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.
Index
Konstanten
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.
Typen
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) *BridgeAttach 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) LoadingProgress(loaded, total int64)LoadingProgress reports loading progress to the host.