Documentation ¶
Index ¶
- Constants
- func ComputeDotOffset(text string, fontFace font.Face, pivot string) (x, y int, err error)
- type Components
- type EngineComponents
- type Sprite
- type SpriteRender
- type SpriteSheet
- type Text
- type Texture
- type Transform
- func (t *Transform) ComputeOriginOffset(screenWidth, screenHeight float64) (offsetX, offsetY float64)
- func (t *Transform) SetDepth(depth float64) *Transform
- func (t *Transform) SetOrigin(origin string) *Transform
- func (t *Transform) SetRotation(angle float64) *Transform
- func (t *Transform) SetScale(sx, sy float64) *Transform
- func (t *Transform) SetTranslation(tx, ty float64) *Transform
- type UITransform
Constants ¶
const ( TransformOriginTopLeft = "TopLeft" TransformOriginTopMiddle = "TopMiddle" TransformOriginTopRight = "TopRight" TransformOriginMiddleLeft = "MiddleLeft" TransformOriginMiddle = "Middle" TransformOriginMiddleRight = "MiddleRight" TransformOriginBottomLeft = "BottomLeft" TransformOriginBottomMiddle = "BottomMiddle" TransformOriginBottomRight = "BottomRight" )
Transform origin variants
const ( PivotDot = "Dot" PivotTopLeft = "TopLeft" PivotTopMiddle = "TopMiddle" PivotTopRight = "TopRight" PivotMiddleLeft = "MiddleLeft" PivotMiddle = "Middle" PivotMiddleRight = "MiddleRight" PivotBottomLeft = "BottomLeft" PivotBottomMiddle = "BottomMiddle" PivotBottomRight = "BottomRight" )
Pivot variants
const ( UITransformOriginTopLeft = "TopLeft" UITransformOriginTopMiddle = "TopMiddle" UITransformOriginTopRight = "TopRight" UITransformOriginMiddleLeft = "MiddleLeft" UITransformOriginMiddle = "Middle" UITransformOriginMiddleRight = "MiddleRight" UITransformOriginBottomLeft = "BottomLeft" UITransformOriginBottomMiddle = "BottomMiddle" UITransformOriginBottomRight = "BottomRight" )
UI transform origin variants
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Components ¶
type Components struct { Engine *EngineComponents Game interface{} }
Components contains engine and game components
func InitComponents ¶
func InitComponents(manager *ecs.Manager, gameComponents interface{}) *Components
InitComponents initializes components
type EngineComponents ¶
type EngineComponents struct { SpriteRender *ecs.SliceComponent Transform *ecs.SliceComponent Text *ecs.SliceComponent UITransform *ecs.SliceComponent }
EngineComponents contains references to all engine components
type Sprite ¶
type Sprite struct { // Horizontal position of the sprite in the sprite sheet X int // Vertical position of the sprite in the sprite sheet Y int // Width of the sprite Width int // Height of the sprite Height int }
Sprite structure
type SpriteRender ¶
type SpriteRender struct { // Reference sprite sheet SpriteSheet *SpriteSheet // Index of the sprite on the sprite sheet SpriteNumber int // Draw options Options ebiten.DrawImageOptions }
SpriteRender component
type SpriteSheet ¶
type SpriteSheet struct { // Texture image Texture Texture `toml:"texture_image"` // List of sprites Sprites []Sprite }
SpriteSheet structure
type Texture ¶
type Texture struct {
// Texture image
Image *ebiten.Image
}
Texture structure
func (*Texture) UnmarshalText ¶
UnmarshalText fills structure fields from text data
type Transform ¶
type Transform struct { // Scale1 vector defines image scaling. Contains scale value minus 1 so that zero value is identity. Scale1 math.Vector2 `toml:"scale_minus_1"` // Rotation angle is measured counterclockwise. Rotation float64 // Translation defines the position of the image center relative to the origin. Translation math.Vector2 // Origin defines the origin (0, 0) relative to the screen. Default is "BottomLeft". Origin string // Depth determines the drawing order on the screen. Images with higher depth are drawn above others. Depth float64 }
Transform component. The origin (0, 0) is the lower left part of screen. Image is first rotated, then scaled, and finally translated.
func NewTransform ¶
func NewTransform() *Transform
NewTransform creates a new default transform, corresponding to identity.
func (*Transform) ComputeOriginOffset ¶
func (t *Transform) ComputeOriginOffset(screenWidth, screenHeight float64) (offsetX, offsetY float64)
ComputeOriginOffset returns the transform origin offset.
func (*Transform) SetRotation ¶
SetRotation sets transform rotation.
func (*Transform) SetTranslation ¶
SetTranslation sets transform translation.
type UITransform ¶
type UITransform struct { // Translation defines the position of the pivot relative to the origin. Translation math.VectorInt2 // Origin defines the origin (0, 0) relative to the screen. Default is "BottomLeft". Origin string // Pivot defines the position of the element relative to its translation (default is Middle). Pivot string }
UITransform component
func (*UITransform) ComputeOriginOffset ¶
func (t *UITransform) ComputeOriginOffset(screenWidth, screenHeight int) (offsetX, offsetY int)
ComputeOriginOffset returns the UI transform origin offset