sprites

package
v2.0.0-...-ee2978b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Left HorizonalAlignment = func(x float64, width float64) float64 {
		return x
	}

	Center HorizonalAlignment = func(x float64, width float64) float64 {
		return x - (width / 2)
	}

	Right HorizonalAlignment = func(x float64, width float64) float64 {
		return x - width
	}

	Top VerticalAlignment = func(y float64, height float64) float64 {
		return y
	}

	Middle VerticalAlignment = func(y float64, height float64) float64 {
		return y - (height / 2)
	}

	Bottom VerticalAlignment = func(y float64, height float64) float64 {
		return y - height
	}

	TopLeft Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Top(y, height), Left(x, width)
	}

	TopCenter Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Top(y, height), Center(x, width)
	}

	TopRight Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Top(y, height), Right(x, width)
	}

	MiddleLeft Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Middle(y, height), Left(x, width)
	}

	MiddleCenter Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Middle(y, height), Center(x, width)
	}

	MiddleRight Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Middle(y, height), Right(x, width)
	}

	BottomLeft Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Bottom(y, height), Left(x, width)
	}

	BottomMiddle Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Bottom(y, height), Middle(x, width)
	}

	BottomRight Alignment = func(x float64, y float64, width float64, height float64) (float64, float64) {
		return Bottom(y, height), Right(x, width)
	}
)

Functions

This section is empty.

Types

type Alignment

type Alignment func(x float64, y float64, width float64, height float64) (float64, float64)

type Animation

type Animation struct {
	// Frames is a slice of this animation's individual frames.
	Frames []*Frame
	// Direction is the direction the animation will be played (forward/reverse).
	Direction Direction
}

Animation objects contain the actual images and metadata used by sprites. Sprites are responsible for maintaining their own state, such as which frame of an animation is currently displayed.

type Direction

type Direction string

Direction a possible animation direction (forward/reverse).

type Frame

type Frame struct {
	// Image is the frame's image.
	Image *ebiten.Image

	// Duration is the duration the frame is displayed before progressing to the next frame.
	Duration time.Duration
}

Frame represents a single animation frame.

type HorizonalAlignment

type HorizonalAlignment func(x float64, width float64) float64

type Sprite

type Sprite struct {
	X         float64
	Y         float64
	Animation *Animation
	Scale     float64
	Speed     float64
	Angle     int
	Origin    Alignment
	Frame     int
	Paused    bool
	Visible   bool
	Repeat    bool
	// contains filtered or unexported fields
}

func NewSprite

func NewSprite(animation *Animation) *Sprite

func (*Sprite) Draw

func (s *Sprite) Draw(target ebiten.Image)

func (*Sprite) Update

func (s *Sprite) Update()

type SpriteSheetLoader

type SpriteSheetLoader interface {
	// Animation returns the tagged animation with the specified name.
	Animation(name string) (*Animation, error)

	// AllAnimations returns a mapping of all tagged animations and their names.
	AllAnimations() (map[string]*Animation, error)
}

SpriteSheetLoader loads named Animations from a sprite sheet.

type VerticalAlignment

type VerticalAlignment func(y float64, height float64) float64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL