Documentation ¶
Index ¶
- Variables
- func DrawNineSlicing(dst, src *ebiten.Image, sliceKey *SliceKey, width int, height int, ...)
- 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 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 Scene
- type Slice
- type SliceKey
- 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) 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 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 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 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 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) 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