Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrAnimationExists = errors.New("animation already exists in animator instance")
ErrAnimationExists is an error returned if an Animation already exists in the animator instance.
var ErrAnimationNotFound = errors.New("animation was not found")
ErrAnimationNotFound is an error returned if an Animation called by string is not found in the animator instance.
Functions ¶
This section is empty.
Types ¶
type Animation ¶
type Animation struct { // StartFrame is the frame's starting x and y location, width and height. StartFrame Frame // FrameCount the number of frames for a particular animation. FrameCount int // Delay is the number of ticks it takes for each frame of the animation to pass. Delay float64 // Direction is the Direction the spritesheet should be read. // This should be either Horizontal or Vertical. Direction Direction // contains filtered or unexported fields }
Animation defines a spritesheet's animation.
func (*Animation) FrameHeight ¶
FrameHeight returns the height of the frame.
func (*Animation) FrameWidth ¶
FrameWidth returns the width of the frame.
type Animator ¶
type Animator interface { // Add will add an animation to the map of the animator instance. // // If an animation already exists in the map this function will // return an ErrAnimationExists error. Add(animationName string, animation *Animation) error // Play will play the animation, iterating through each frame. // // This function should be called every frame in your update function. // // If the animation name passed is not found in the animator's map an // ErrAnimationNotFound error is returned. Play(animationName string) error // Pause will stop an animation from playing until the next call to Resume. Pause() // Resume will start an animation until the next call to Pause. // // Note: you must still call the `Play()` method to iterate through the // frames of an animation. Resume() // Reset will reset an animation back to it's startFrame Reset() // Animation returns the currently selected animation. // // If no animation has been set using the Play() method // a zero valued Animation will be returned. Animation() *Animation // Paused returns true if the animator's current animation is paused, otherwise it returns false. Paused() bool // AnimationTicks returns the number of ticks it takes to perform a full animation sequence. AnimationTicks() float64 }
Animator is an interface that acts as a handler for animations.
type Direction ¶
type Direction int
Direction repestents the Direction in which the animation is read from a spritesheet.
type Frame ¶
type Frame struct {
X, Y, Width, Height int
}
Frame represents a frame of an animation as a rectangle.
type Origin ¶
type Origin int
Origin repesents the x, y drawing point of the sprite.
This means if the x, y location of the origin is TopLeft the sprite's image will be drawn to the destination image from the TopLeft corner of the image.
If the origin is centered, the sprite will be drawn to the destination image from the center of the sprite's image.
TopLeft ──┐ Origin │ │ ┌── Center │ │ Origin │ │ o─────┼──────┐ │ │ │ │ │ │ │ o │ │ │ │ │ └────────────┘
type Sprite ¶
type Sprite struct { // Texture is the sprite's image. Texture *ebiten.Image // Position is the sprites location on screen. Position Vector // Animator can be used to add animations to your sprite. Animator Animator // UpdateFunc handles your sprites update logic. This function should be // called in Ebitengine's Game Upadate() method. UpdateFunc func() error // Origin repesents the origin point of the sprite. Origin Origin // Color will fill the sprite with a give color. // This is mostly used for prototyping. Color color.Color // Scale represents the scale of the sprite. Scale Vector // contains filtered or unexported fields }
Sprite represents any visible image on the game screen.
func (*Sprite) Draw ¶
func (s *Sprite) Draw(dst *ebiten.Image)
Draw draws the sprite at the sprites current location.
func (*Sprite) FlipHorizontal ¶
FlipHorizontal will flip a sprite horizontally.
func (*Sprite) FlipVertical ¶
FlipVertical will flip a sprite vertically if flipped is set to true.