Documentation
¶
Index ¶
- Variables
- type AnimatedIcon
- func (a *AnimatedIcon) Draw(screen *ebiten.Image, x, y, scaleX, scaleY, tilt float64)
- func (a *AnimatedIcon) DrawWithColorScale(screen *ebiten.Image, x, y, scaleX, scaleY, tilt, r, g, b, alpha float64)
- func (a *AnimatedIcon) SetIconState(state string) error
- func (a *AnimatedIcon) Update(dt time.Duration)
- type AnimationMode
- type AtlasManager
- type AtlasMeta
- type Frame
- type IconState
Constants ¶
This section is empty.
Variables ¶
var MasterAtlasManager = &AtlasManager{ IconStateCache: map[string]IconState{}, BasePath: "media/sprites", }
The main atlas manager instance.
Functions ¶
This section is empty.
Types ¶
type AnimatedIcon ¶
An animated icon is a set of icon states.
func NewAnimatedIconFromPath ¶
func NewAnimatedIconFromPath(path string, stateKey string) (*AnimatedIcon, error)
Looks up the provided icon and state in the cache. Tries to cut and cache the icon if not already cached.
func (*AnimatedIcon) Draw ¶
func (a *AnimatedIcon) Draw(screen *ebiten.Image, x, y, scaleX, scaleY, tilt float64)
func (*AnimatedIcon) DrawWithColorScale ¶
func (a *AnimatedIcon) DrawWithColorScale(screen *ebiten.Image, x, y, scaleX, scaleY, tilt, r, g, b, alpha float64)
Colors the icon when rendering.
func (*AnimatedIcon) SetIconState ¶
func (a *AnimatedIcon) SetIconState(state string) error
Changes the icon's active state.
func (*AnimatedIcon) Update ¶
func (a *AnimatedIcon) Update(dt time.Duration)
Iterates through the frames.
type AnimationMode ¶
type AnimationMode int
const ( AnimationModeOnce AnimationMode = iota AnimationModeLoop AnimationMode = iota AnimationModePingPong AnimationMode = iota )
type AtlasManager ¶
type AtlasManager struct {
IconStateCache map[string]IconState
BasePath string
// contains filtered or unexported fields
}
AtlasManager caches cut icons to reuse them.
func (*AtlasManager) CacheIconStates ¶
func (m *AtlasManager) CacheIconStates(path string) error
Parses an Aseprite format .json file, reads the .png spritesheet from the provided directory and cuts it. Caches the result.
func (*AtlasManager) CutAtlas ¶
Cuts the .png spritesheet into `Frame`s and combines them into `IconState`s.
func (*AtlasManager) GetIconState ¶
func (m *AtlasManager) GetIconState(iconName, iconState string) (IconState, error)
GetIconState returns a cached icon state by compound key "iconName_iconState".
type AtlasMeta ¶
type AtlasMeta struct {
Name string
States []assets.IconStateMeta
}
AtlasMeta is a single atlas entity (png + aseprite-style JSON).