Documentation ¶
Index ¶
- Variables
- func DrawNineSlicing(dst, src *ebiten.Image, sliceKey *SliceKey, width int, height int, ...)
- func Index(gid uint32) uint32
- type Animation
- type Button
- func (e *Button) IsDestroyed() bool
- func (e *Button) IsEnabled() bool
- func (e *Button) IsVisible() bool
- func (e *Button) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, ...)
- func (e *Button) Name() string
- func (e *Button) RenderIndex() int64
- func (e *Button) SetEnabled(isEnabled bool)
- func (e *Button) SetIsDestroyed(isDestroyed bool)
- func (e *Button) SetOnPressFunction(f func())
- func (e *Button) SetOnPressed(f func(e *Button))
- func (e *Button) SetRenderIndex(renderIndex int64)
- func (e *Button) SetShape(shape common.Rectangle)
- func (e *Button) SetText(text string)
- func (e *Button) SetVisible(isVisible bool)
- func (e *Button) Shape() *common.Rectangle
- func (e *Button) X() float64
- func (e *Button) Y() float64
- type Font
- type Frame
- func (e *Frame) IsDestroyed() bool
- func (e *Frame) IsEnabled() bool
- func (e *Frame) IsVisible() bool
- func (e *Frame) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, ...)
- func (e *Frame) Name() string
- func (e *Frame) RenderIndex() int64
- func (e *Frame) SetIsDestroyed(isDestroyed bool)
- func (e *Frame) SetIsEnabled(isEnabled bool)
- func (e *Frame) SetOnPressFunction(f func())
- func (e *Frame) SetOnPressed(f func(e *Frame))
- func (e *Frame) SetRenderIndex(renderIndex int64)
- func (e *Frame) SetShape(shape common.Rectangle)
- func (e *Frame) SetText(text string)
- func (e *Frame) Shape() *common.Rectangle
- type GID
- func (g GID) D() bool
- func (g GID) H() bool
- func (g GID) Index() uint32
- func (g GID) Rotation() (rotation int)
- func (g GID) SetD(val bool)
- func (g GID) SetH(val bool)
- func (g GID) SetRotation(rotation int) (err error)
- func (g GID) SetV(val bool)
- func (g GID) SetValue() uint32
- func (g GID) V() bool
- func (g GID) Value() uint32
- type Image
- type Interfacer
- type Label
- func (e *Label) IsDestroyed() bool
- func (e *Label) IsEnabled() bool
- func (e *Label) IsVisible() bool
- func (e *Label) LerpColor(endColor color.Color, duration time.Duration, isDestroyed bool, endFunc func())
- func (e *Label) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, ...)
- func (e *Label) Name() string
- func (e *Label) RenderIndex() int64
- func (e *Label) SetEnabled(isEnabled bool)
- func (e *Label) SetIsDestroyed(isDestroyed bool)
- func (e *Label) SetOnPressFunction(f func())
- func (e *Label) SetOnPressed(f func(e *Label))
- func (e *Label) SetRenderIndex(renderIndex int64)
- func (e *Label) SetShape(shape common.Rectangle)
- func (e *Label) SetText(text string)
- func (e *Label) SetVisible(isVisible bool)
- func (e *Label) Shape() *common.Rectangle
- type Map
- func (e *Map) IsDestroyed() bool
- func (e *Map) IsEnabled() bool
- func (e *Map) IsVisible() bool
- func (e *Map) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, ...)
- func (e *Map) Name() string
- func (e *Map) RenderIndex() int64
- func (e *Map) SetData(data MapData) error
- func (e *Map) SetEnabled(isEnabled bool)
- func (e *Map) SetIsDestroyed(isDestroyed bool)
- func (e *Map) SetOnPressFunction(f func())
- func (e *Map) SetOnPressed(f func(e *Map))
- func (e *Map) SetRenderIndex(renderIndex int64)
- func (e *Map) SetShape(shape common.Rectangle)
- func (e *Map) SetText(text string)
- func (e *Map) SetVisible(isVisible bool)
- func (e *Map) Shape() *common.Rectangle
- func (e *Map) X() float64
- func (e *Map) Y() float64
- type MapCollider
- type MapData
- type MapLayer
- type MapTile
- type Scene
- type Slice
- type SliceKey
- type Sprite
- func (e *Sprite) Animation() string
- func (e *Sprite) IsDestroyed() bool
- func (e *Sprite) IsEnabled() bool
- func (e *Sprite) IsVisible() bool
- func (e *Sprite) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, ...)
- func (e *Sprite) Name() string
- func (e *Sprite) RenderIndex() int64
- func (e *Sprite) SetAnimation(name string)
- func (e *Sprite) SetEnabled(isEnabled bool)
- func (e *Sprite) SetIsDestroyed(isDestroyed bool)
- func (e *Sprite) SetOnPressFunction(f func())
- func (e *Sprite) SetOnPressed(f func(e *Sprite))
- func (e *Sprite) SetRenderIndex(renderIndex int64)
- func (e *Sprite) SetShape(shape common.Rectangle)
- func (e *Sprite) SetText(text string)
- func (e *Sprite) SetVisible(isVisible bool)
- func (e *Sprite) Shape() *common.Rectangle
- func (e *Sprite) X() float64
- func (e *Sprite) Y() float64
- type UI
- func (u *UI) AddFont(font *Font) error
- func (u *UI) AddImage(img *Image) error
- func (u *UI) AddScene(name string, scene *Scene) error
- func (u *UI) CurrentScene() *Scene
- func (u *UI) DefaultFont(name string) error
- func (u *UI) Font(name string) (*Font, error)
- func (u *UI) Image(name string) (*Image, error)
- func (u *UI) NewButton(name string, scene string, text string, shape common.Rectangle, ...) (*Button, error)
- func (u *UI) NewFontTTF(name string, fontData []byte, opts *truetype.Options, r rune) (*Font, error)
- func (u *UI) NewFrame(name string, imageName string, text string, shape *common.Rectangle) (e *Frame, err error)
- func (u *UI) NewImage(name string, f io.Reader, filter ebiten.Filter) (*Image, error)
- func (u *UI) NewLabel(name string, text string, shape common.Rectangle, color color.Color) (e *Label, err error)
- func (u *UI) NewMap(name string, scene string, shape common.Rectangle, tintColor color.Color, ...) (*Map, error)
- func (ui *UI) NewScene(name string) (*Scene, error)
- func (u *UI) NewSprite(name string, scene string, shape common.Rectangle, tintColor color.Color, ...) (*Sprite, error)
- func (u *UI) RemoveFont(font *Font) error
- func (u *UI) Resolution() image.Point
- func (u *UI) Scene(name string) (*Scene, error)
- func (u *UI) SetCurrentScene(name string) error
- func (u *UI) SetDefaultFont(name string) error
- func (u *UI) SetResolution(resolution image.Point)
- func (u *UI) Update(image *ebiten.Image) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrSliceNameInvalid is returned when a slice name has invalid characters or too short ErrSliceNameInvalid = fmt.Errorf("slice name invalid") // ErrSliceAlreadyExists is returned when a slice already exists ErrSliceAlreadyExists = fmt.Errorf("slice already exists") // ErrSliceNotFound is returned when a slice is not loaded into the UI ErrSliceNotFound = fmt.Errorf("slice not found") )
var ( // ErrElementNameInvalid is returned when a element name has invalid characters or too short ErrElementNameInvalid = fmt.Errorf("element name invalid") // ErrElementAlreadyExists is returned when a element already exists ErrElementAlreadyExists = fmt.Errorf("element already exists") // ErrElementNotFound is returned when a element is not loaded into the UI ErrElementNotFound = fmt.Errorf("element not found") // ErrFontNameInvalid is returned when a font name has invalid characters or too short ErrFontNameInvalid = fmt.Errorf("font name invalid") // ErrFontAlreadyExists is returned when a font already exists ErrFontAlreadyExists = fmt.Errorf("font already exists") // ErrFontNotFound is returned when a font was not found ErrFontNotFound = fmt.Errorf("font not found") // ErrFontCannotRemoveDefault is returned when you attempt to delete a font currently set as default ErrFontCannotRemoveDefault = fmt.Errorf("font is default, cannot remove") // ErrImageNameInvalid is returned when a image name has invalid characters or too short ErrImageNameInvalid = fmt.Errorf("image name invalid") // ErrImageAlreadyExists is returned when a image already exists ErrImageAlreadyExists = fmt.Errorf("image already exists") // ErrImageNotFound is returned when a image was not found ErrImageNotFound = fmt.Errorf("image not found") // ErrSceneNameInvalid is returned when a scene name has invalid characters or too short ErrSceneNameInvalid = fmt.Errorf("scene name invalid") // ErrSceneAlreadyExists is returned when a Scene already exists ErrSceneAlreadyExists = fmt.Errorf("scene already exists") // ErrSceneNotFound is returned when a scene is not loaded into the UI ErrSceneNotFound = fmt.Errorf("scene not found") )
Functions ¶
Types ¶
type Animation ¶ added in v0.0.6
type Animation struct { //Counter tracks what animation frame is currently being played Counter int //Current sprite name being played CurrentName string //Speed to play animation Speed int //If the sheet has multiple sprites, which index of the bundle to use BundleIndex int CellWidth float64 CellHeight float64 Image string Alpha string Clips [][]int BundleCount int Animations map[string][][]float64 }
Animation handles animation details
type Button ¶
type Button struct {
// contains filtered or unexported fields
}
Button represents a UI Button element
func (*Button) IsDestroyed ¶
IsDestroyed returns true when the element is flagged for deletion
func (*Button) LerpPosition ¶
func (e *Button) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())
LerpPosition changes an element's position over duration
func (*Button) RenderIndex ¶ added in v0.0.4
RenderIndex returns the render index of element
func (*Button) SetEnabled ¶ added in v0.0.4
SetEnabled changes if a button is enabled
func (*Button) SetIsDestroyed ¶ added in v0.0.4
SetIsDestroyed sets an element to be destroyed on next update
func (*Button) SetOnPressFunction ¶
func (e *Button) SetOnPressFunction(f func())
SetOnPressFunction lets you pass a function without the need of button handling
func (*Button) SetOnPressed ¶
SetOnPressed sets a button state
func (*Button) SetRenderIndex ¶ added in v0.0.4
SetRenderIndex sets the render index of element
func (*Button) SetVisible ¶ added in v0.0.4
SetVisible changes the visibility of a button
type Font ¶ added in v0.0.4
type Font struct { Face font.Face Height int Name string Language language.Tag // contains filtered or unexported fields }
Font contains related data for loading a font file
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame represents a UI Frame element
func (*Frame) IsDestroyed ¶
IsDestroyed returns true when the element is flagged for deletion
func (*Frame) LerpPosition ¶
func (e *Frame) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())
LerpPosition changes an element's position over duration
func (*Frame) RenderIndex ¶ added in v0.0.4
RenderIndex returns the render index of element
func (*Frame) SetIsDestroyed ¶ added in v0.0.4
SetIsDestroyed sets an element to be destroyed on next update
func (*Frame) SetIsEnabled ¶ added in v0.0.4
SetIsEnabled changes if a Frame is enabled
func (*Frame) SetOnPressFunction ¶
func (e *Frame) SetOnPressFunction(f func())
SetOnPressFunction lets you pass a function without the need of Frame handling
func (*Frame) SetOnPressed ¶
SetOnPressed sets a Frame state
func (*Frame) SetRenderIndex ¶ added in v0.0.4
SetRenderIndex sets the render index of element
type GID ¶ added in v0.0.8
type GID struct {
// contains filtered or unexported fields
}
GID represents a global ID, uses rotation padding on the last 3 bytes
func (GID) Rotation ¶ added in v0.0.8
Rotation returns the rotation of the object. Can only be 0, 90, 180, or 270
func (GID) SetRotation ¶ added in v0.0.8
SetRotation sets the rotation of a tile clockwise, supports 0, 90, 180, 270
type Image ¶ added in v0.0.4
type Image struct {
// contains filtered or unexported fields
}
Image represents a ebiten image with added details on how to render
func (*Image) RemoveSlice ¶ added in v0.0.4
RemoveSlice removes 9slicing data from an image
type Interfacer ¶
type Interfacer interface { //TargetPositionUpdate(tp *common.Vector, duration time.Duration) IsEnabled() bool SetEnabled(isEnabled bool) IsVisible() bool SetVisible(isVisible bool) Name() string RenderIndex() int64 SetRenderIndex(renderIndex int64) IsDestroyed() bool SetIsDestroyed(isDestroyed bool) SetText(text string) // Shape returns the shape of an element Shape() *common.Rectangle // SetShape sets the shape of an element SetShape(shape common.Rectangle) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func()) // contains filtered or unexported methods }
Interfacer is a generic user interface wrapper
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label represents a UI label element
func (*Label) IsDestroyed ¶
IsDestroyed returns true when the element is flagged for deletion
func (*Label) LerpColor ¶
func (e *Label) LerpColor(endColor color.Color, duration time.Duration, isDestroyed bool, endFunc func())
LerpColor changes the label's color over duration
func (*Label) LerpPosition ¶
func (e *Label) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())
LerpPosition changes an element's position over duration
func (*Label) RenderIndex ¶ added in v0.0.4
RenderIndex returns the render index of element
func (*Label) SetEnabled ¶ added in v0.0.4
SetEnabled changes if a button is enabled
func (*Label) SetIsDestroyed ¶ added in v0.0.4
SetIsDestroyed sets an element to be destroyed on next update
func (*Label) SetOnPressFunction ¶
func (e *Label) SetOnPressFunction(f func())
SetOnPressFunction lets you pass a function without the need of label handling
func (*Label) SetOnPressed ¶
SetOnPressed sets a label state
func (*Label) SetRenderIndex ¶ added in v0.0.4
SetRenderIndex sets the render index of element
func (*Label) SetVisible ¶ added in v0.0.4
SetVisible changes the visibility of a button
type Map ¶ added in v0.0.7
type Map struct {
// contains filtered or unexported fields
}
Map represents a UI Map element
func (*Map) IsDestroyed ¶ added in v0.0.7
IsDestroyed returns true when the element is flagged for deletion
func (*Map) LerpPosition ¶ added in v0.0.7
func (e *Map) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())
LerpPosition changes an element's position over duration
func (*Map) RenderIndex ¶ added in v0.0.7
RenderIndex returns the render index of element
func (*Map) SetEnabled ¶ added in v0.0.7
SetEnabled changes if a map is enabled
func (*Map) SetIsDestroyed ¶ added in v0.0.7
SetIsDestroyed sets an element to be destroyed on next update
func (*Map) SetOnPressFunction ¶ added in v0.0.7
func (e *Map) SetOnPressFunction(f func())
SetOnPressFunction lets you pass a function without the need of map handling
func (*Map) SetOnPressed ¶ added in v0.0.7
SetOnPressed sets a map state
func (*Map) SetRenderIndex ¶ added in v0.0.7
SetRenderIndex sets the render index of element
func (*Map) SetShape ¶ added in v0.0.7
SetShape sets an element's X/Y position as well as width/height
func (*Map) SetVisible ¶ added in v0.0.7
SetVisible changes the visibility of a map
type MapCollider ¶ added in v0.0.7
type MapCollider struct { IsCollider bool `json:"is_collider,omitempty"` Cost float32 `json:"cost,omitempty"` }
MapCollider is a boolean if a collider is true or not
type MapData ¶ added in v0.0.7
type MapData struct { Source string `json:"source,omitempty"` Width int64 `json:"width,omitempty"` Height int64 `json:"height,omitempty"` TileWidth int64 `json:"tile_width,omitempty"` TileHeight int64 `json:"tile_height,omitempty"` TileCount int64 `json:"tile_count,omitempty"` TileSheetWidth int64 TileSheetHeight int64 TileFrames []image.Rectangle Layers []MapLayer `json:"layers,omitempty"` Colliders []MapCollider `json:"colliders,omitempty"` }
MapData contains map related information
type MapLayer ¶ added in v0.0.7
type MapLayer struct { Name string `json:"name,omitempty"` Opacity float32 `json:"opacity,omitempty"` Tiles []MapTile `json:"tiles,omitempty"` }
MapLayer contains layer data
type MapTile ¶ added in v0.0.7
type MapTile struct {
GID uint32 `json:"gid,omitempty"`
}
MapTile contains the Gid of a specified tile
type Scene ¶
type Scene struct {
// contains filtered or unexported fields
}
Scene represents a layout of ui
func (*Scene) AddElement ¶
func (s *Scene) AddElement(e Interfacer) error
AddElement adds an element to the scene list
func (*Scene) Element ¶
func (s *Scene) Element(name string) (Interfacer, error)
Element returns an element based on name
func (*Scene) RemoveElement ¶
RemoveElement flags an element to be removed next update
type SliceKey ¶ added in v0.0.4
type SliceKey struct { Frame string `xml:"frame,attr"` X float64 `xml:"x,attr"` Y float64 `xml:"y,attr"` W float64 `xml:"w,attr"` H float64 `xml:"h,attr"` CX float64 `xml:"cx,attr"` CY float64 `xml:"cy,attr"` CW float64 `xml:"cw,attr"` CH float64 `xml:"ch,attr"` PivotX float64 `xml:"px,attr"` PivotY float64 `xml:"py,attr"` }
SliceKey represents each slice's key data
type Sprite ¶ added in v0.0.6
type Sprite struct {
// contains filtered or unexported fields
}
Sprite represents a UI Sprite element
func (*Sprite) IsDestroyed ¶ added in v0.0.6
IsDestroyed returns true when the element is flagged for deletion
func (*Sprite) LerpPosition ¶ added in v0.0.6
func (e *Sprite) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, endFunc func())
LerpPosition changes an element's position over duration
func (*Sprite) RenderIndex ¶ added in v0.0.6
RenderIndex returns the render index of element
func (*Sprite) SetAnimation ¶ added in v0.0.6
SetAnimation sets the current animation group name
func (*Sprite) SetEnabled ¶ added in v0.0.6
SetEnabled changes if a sprite is enabled
func (*Sprite) SetIsDestroyed ¶ added in v0.0.6
SetIsDestroyed sets an element to be destroyed on next update
func (*Sprite) SetOnPressFunction ¶ added in v0.0.6
func (e *Sprite) SetOnPressFunction(f func())
SetOnPressFunction lets you pass a function without the need of sprite handling
func (*Sprite) SetOnPressed ¶ added in v0.0.6
SetOnPressed sets a sprite state
func (*Sprite) SetRenderIndex ¶ added in v0.0.6
SetRenderIndex sets the render index of element
func (*Sprite) SetShape ¶ added in v0.0.6
SetShape sets an element's X/Y position as well as width/height
func (*Sprite) SetVisible ¶ added in v0.0.6
SetVisible changes the visibility of a sprite
func (*Sprite) Shape ¶ added in v0.0.6
Shape returns an element's X/Y position as well as width/height
type UI ¶
type UI struct {
// contains filtered or unexported fields
}
UI contains core game components
func (*UI) DefaultFont ¶ added in v0.0.4
DefaultFont returns the current default font
func (*UI) NewButton ¶
func (u *UI) NewButton(name string, scene string, text string, shape common.Rectangle, textColor color.Color, imageName string, pressedSliceName string, unpressedSliceName string) (*Button, error)
NewButton creates a new button instance
func (*UI) NewFontTTF ¶ added in v0.0.4
func (u *UI) NewFontTTF(name string, fontData []byte, opts *truetype.Options, r rune) (*Font, error)
NewFontTTF instantiates a truetype font. truetype.Parse() can be used to load a TTF to fontData
func (*UI) NewFrame ¶
func (u *UI) NewFrame(name string, imageName string, text string, shape *common.Rectangle) (e *Frame, err error)
NewFrame creates a new Frame instance
func (*UI) NewLabel ¶
func (u *UI) NewLabel(name string, text string, shape common.Rectangle, color color.Color) (e *Label, err error)
NewLabel creates a new label instance
func (*UI) NewMap ¶ added in v0.0.7
func (u *UI) NewMap(name string, scene string, shape common.Rectangle, tintColor color.Color, imageName string) (*Map, error)
NewMap creates a new map instance
func (*UI) NewSprite ¶ added in v0.0.6
func (u *UI) NewSprite(name string, scene string, shape common.Rectangle, tintColor color.Color, imageName string) (*Sprite, error)
NewSprite creates a new sprite instance
func (*UI) RemoveFont ¶ added in v0.0.4
RemoveFont is used to unload and remove a font
func (*UI) SetCurrentScene ¶
SetCurrentScene sets current scene
func (*UI) SetDefaultFont ¶ added in v0.0.4
SetDefaultFont updates all elements to use a new default font
func (*UI) SetResolution ¶
SetResolution changes the resolution of the UI