gui

package
v0.0.0-...-23eb08f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Assets

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

func (Assets) GetSprite

func (assets Assets) GetSprite(spriteName string) *graphics.Sprite

GetSprite Returns sprite for the given spriteName. spriteName shall be passed without extension. See example in RegisterAssets.

func (*Assets) RegisterAssets

func (assets *Assets) RegisterAssets(dirPath string, fs embed.FS) error

RegisterAssets Loads assets from given directory and filesystem for further usage currently supports only png files which are recognized as sprites dirPath is a relative path to directory from fs root. It is used as prefix for further calls. Example:

fs ~ assetsDir/
     ├── logo.png
     ├── character/
         ├── male.png
         ├── female.png
         └── alien.png

gameAssets := new(Assets)
gameAssets.RegisterAssets("assetsDir", fs)

maleSprite := gameAssets.GetSprite("character/male")
femaleSprite := gameAssets.GetSprite("character/female")
alienSprite := gameAssets.GetSprite("character/alien")
logoSprite := gameAssets.GetSprite("logo")

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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