Documentation ¶
Index ¶
- Variables
- type Button
- func (e *Button) AlignmentRead() int
- func (e *Button) AlignmentUpdate(alignment int)
- func (e *Button) EnabledRead() bool
- func (e *Button) EnabledUpdate(isEnabled bool)
- func (e *Button) IsDestroyed() bool
- func (e *Button) IsVisible() bool
- func (e *Button) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, ...)
- func (e *Button) NameRead() string
- func (e *Button) RenderIndexRead() int64
- func (e *Button) RenderIndexUpdate(renderIndex int64)
- func (e *Button) SetOnPressFunction(f func())
- func (e *Button) SetOnPressed(f func(e *Button))
- func (e *Button) SetShape(shape common.Rectangle)
- func (e *Button) Shape() *common.Rectangle
- func (e *Button) TextUpdate(text string)
- func (e *Button) VisibleRead() bool
- func (e *Button) VisibleUpdate(isVisible bool)
- type Frame
- func (e *Frame) AlignmentRead() int
- func (e *Frame) AlignmentUpdate(alignment int)
- func (e *Frame) EnabledRead() bool
- func (e *Frame) EnabledUpdate(isEnabled bool)
- func (e *Frame) IsDestroyed() bool
- func (e *Frame) IsVisible() bool
- func (e *Frame) LerpPosition(endPosition common.Vector, duration time.Duration, isDestroyed bool, ...)
- func (e *Frame) NameRead() string
- func (e *Frame) RenderIndexRead() int64
- func (e *Frame) RenderIndexUpdate(renderIndex int64)
- func (e *Frame) SetOnPressFunction(f func())
- func (e *Frame) SetOnPressed(f func(e *Frame))
- func (e *Frame) SetShape(shape common.Rectangle)
- func (e *Frame) Shape() *common.Rectangle
- func (e *Frame) TextUpdate(text string)
- func (e *Frame) VisibleRead() bool
- func (e *Frame) VisibleUpdate(isVisible bool)
- type Interfacer
- type Label
- func (e *Label) EnabledRead() bool
- func (e *Label) EnabledUpdate(isEnabled bool)
- func (e *Label) IsDestroyed() 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) NameRead() string
- func (e *Label) RenderIndexRead() int64
- func (e *Label) RenderIndexUpdate(renderIndex int64)
- func (e *Label) SetOnPressFunction(f func())
- func (e *Label) SetOnPressed(f func(e *Label))
- func (e *Label) SetShape(shape common.Rectangle)
- func (e *Label) Shape() *common.Rectangle
- func (e *Label) TextUpdate(text string)
- func (e *Label) VisibleRead() bool
- func (e *Label) VisibleUpdate(isVisible bool)
- type Scene
- type UI
- func (u *UI) AddResource(name string, img *ebiten.Image) error
- func (u *UI) AddScene(name string, scene *Scene) error
- func (u *UI) CurrentScene() *Scene
- func (u *UI) NewButton(name string, resourceName string, scene string, text string, ...) (*Button, error)
- func (u *UI) NewFrame(name string, resourceName string, text string, shape *common.Rectangle) (e *Frame, err error)
- func (u *UI) NewLabel(name string, text string, shape common.Rectangle, color color.Color) (e *Label, err error)
- func (u *UI) Resolution() image.Point
- func (u *UI) Resource(name string) (*ebiten.Image, error)
- func (u *UI) Scene(name string) (*Scene, error)
- func (u *UI) SetCurrentScene(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 ( // 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") // ErrResourceNameInvalid is returned when a resource name has invalid characters or too short ErrResourceNameInvalid = fmt.Errorf("resource name invalid") // ErrResourceAlreadyExists is returned when a resource already exists ErrResourceAlreadyExists = fmt.Errorf("resource already exists") // ErrResourceNotFound is returned when a resource was not found ErrResourceNotFound = fmt.Errorf("resource 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 ¶
This section is empty.
Types ¶
type Button ¶
type Button struct {
// contains filtered or unexported fields
}
Button represents a UI Button element
func (*Button) AlignmentRead ¶
AlignmentRead returns the alignment style
func (*Button) AlignmentUpdate ¶
AlignmentUpdate changes the alignment of the element
func (*Button) EnabledRead ¶
EnabledRead returns true if a button is enabled
func (*Button) EnabledUpdate ¶
EnabledUpdate changes if a button is enabled
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) RenderIndexRead ¶
RenderIndexRead returns the render index of element
func (*Button) RenderIndexUpdate ¶
RenderIndexUpdate sets the render index of element
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) TextUpdate ¶
TextUpdate changes the text on the button
func (*Button) VisibleRead ¶
VisibleRead returns true if a button is visible
func (*Button) VisibleUpdate ¶
VisibleUpdate changes the visibility of a button
type Frame ¶
type Frame struct {
// contains filtered or unexported fields
}
Frame represents a UI Frame element
func (*Frame) AlignmentRead ¶
AlignmentRead returns the alignment style
func (*Frame) AlignmentUpdate ¶
AlignmentUpdate changes the alignment of the element
func (*Frame) EnabledRead ¶
EnabledRead returns true if a Frame is enabled
func (*Frame) EnabledUpdate ¶
EnabledUpdate changes if a Frame is enabled
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) RenderIndexRead ¶
RenderIndexRead returns the render index of element
func (*Frame) RenderIndexUpdate ¶
RenderIndexUpdate sets the render index of element
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) TextUpdate ¶
TextUpdate changes the text on the Frame
func (*Frame) VisibleRead ¶
VisibleRead returns true if a Frame is visible
func (*Frame) VisibleUpdate ¶
VisibleUpdate changes the visibility of a Frame
type Interfacer ¶
type Interfacer interface { //TargetPositionUpdate(tp *common.Vector, duration time.Duration) EnabledRead() bool EnabledUpdate(isEnabled bool) VisibleRead() bool VisibleUpdate(isVisible bool) IsVisible() bool NameRead() string RenderIndexRead() int64 RenderIndexUpdate(renderIndex int64) IsDestroyed() bool // 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()) TextUpdate(string) // 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) EnabledRead ¶
EnabledRead returns true if a button is enabled
func (*Label) EnabledUpdate ¶
EnabledUpdate changes if a button is enabled
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) RenderIndexRead ¶
RenderIndexRead returns the render index of element
func (*Label) RenderIndexUpdate ¶
RenderIndexUpdate sets the render index of element
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) TextUpdate ¶
TextUpdate changes the text on the label
func (*Label) VisibleRead ¶
VisibleRead returns true if a button is visible
func (*Label) VisibleUpdate ¶
VisibleUpdate 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 UI ¶
type UI struct {
// contains filtered or unexported fields
}
UI contains core game components
func (*UI) AddResource ¶
AddResource adds an image resource to ui
func (*UI) NewButton ¶
func (u *UI) NewButton(name string, resourceName string, scene string, text string, shape *common.Rectangle, textColor color.Color) (*Button, error)
NewButton creates a new button instance
func (*UI) NewFrame ¶
func (u *UI) NewFrame(name string, resourceName 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) SetCurrentScene ¶
SetCurrentScene sets current scene
func (*UI) SetResolution ¶
SetResolution changes the resolution of the UI