Documentation ¶
Index ¶
- Constants
- func Nop(anim *Animation, loops int)
- func Pause(anim *Animation, loops int)
- func PauseAtEnd(anim *Animation, loops int)
- func PauseAtStart(anim *Animation, loops int)
- type Animation
- func (anim *Animation) Clone() *Animation
- func (anim *Animation) Draw(screen *ebiten.Image, img *ebiten.Image, opts *DrawOptions)
- func (anim *Animation) Durations() []time.Duration
- func (anim *Animation) FlipH()
- func (anim *Animation) FlipV()
- func (anim *Animation) GoToFrame(position int)
- func (anim *Animation) Pause()
- func (anim *Animation) PauseAtEnd()
- func (anim *Animation) PauseAtStart()
- func (anim *Animation) Position() int
- func (anim *Animation) Resume()
- func (anim *Animation) Size() (int, int)
- func (anim *Animation) Status() Status
- func (anim *Animation) Timer() time.Duration
- func (anim *Animation) TotalDuration() time.Duration
- func (anim *Animation) Update(elapsedTime time.Duration)
- type DrawOptions
- type Grid
- type OnLoop
- type Status
Constants ¶
const ( Playing = iota Paused )
Variables ¶
This section is empty.
Functions ¶
func PauseAtEnd ¶
PauseAtEnd pauses the animation and set the position to the last frame.
func PauseAtStart ¶
PauseAtStart pauses the animation and set the position to the first frame.
Types ¶
type Animation ¶
type Animation struct {
// contains filtered or unexported fields
}
Animation represents an animation created from specified frames and an *ebiten.Image
func NewAnimation ¶
NewAnimation returns a new animation object
durations is a time.Duration or a []time.Duration or a map[string]time.Duration. When it's a time.Duration, it represents the duration of all frames in the animation. When it's a []time.Duration, it can represent different durations for different frames. You can specify durations for all frames individually, like this: []time.Duration { 100 * time.Millisecond, 100 * time.Millisecond } or you can specify durations for ranges of frames: map[string]time.Duration { "1-2": 100 * time.Millisecond, "3-5": 200 * time.Millisecond }.
func (*Animation) Draw ¶
func (anim *Animation) Draw(screen *ebiten.Image, img *ebiten.Image, opts *DrawOptions)
Draw draws the animation with the specified option parameters.
func (*Animation) GoToFrame ¶
GoToFrame sets the position of the animation and sets the timer at the start of the frame.
func (*Animation) PauseAtEnd ¶
func (anim *Animation) PauseAtEnd()
PauseAtEnd pauses the animation and set the position to the last frame.
func (*Animation) PauseAtStart ¶
func (anim *Animation) PauseAtStart()
PauseAtStart pauses the animation and set the position to the first frame.
func (*Animation) Position ¶
Position returns the current position of the frame. The position counts from 1 (not 0).
func (*Animation) TotalDuration ¶
TotalDuration returns the total duration of the animation.
type DrawOptions ¶
type DrawOptions struct {
X, Y float64
Rotate float64
ScaleX, ScaleY float64
OriginX, OriginY float64
}
DrawOptions represents the option for Animation.Draw(). For shortcut, DrawOpts() function can be used.
func DrawOpts ¶
func DrawOpts(x, y float64, args ...float64) *DrawOptions
DrawOpts returns DrawOptions pointer with specified settings. The paramters are x, y, rotate (in radian), scaleX, scaleY originX, originY. If scaleX and ScaleY is not specified the default value will be 1.0, 1.0. If OriginX and OriginY is not specified the default value will be 0, 0
type Grid ¶
type Grid struct {
// contains filtered or unexported fields
}
Grid represents a grid
func NewGrid ¶
NewGrid returns a new grid with specified frame size, image size, and offsets (left, top).
Grids have only one purpose: To build groups of quads of the same size as easily as possible.
They need to know only 2 things: the size of each frame and the size of the image they will be applied to.
Grids are just a convenient way of getting frames from a sprite. Frames are assumed to be distributed in rows and columns. Frame 1,1 is the one in the first row, first column.
func (*Grid) GetFrames ¶
GetFrames accepts an arbitrary number of parameters. They can be either numbers or strings.
Each two numbers are interpreted as quad coordinates in the format (column, row). This way, grid:getFrames(3,4) will return the frame in column 3, row 4 of the grid.
There can be more than just two: grid:getFrames(1,1, 1,2, 1,3) will return the frames in {1,1}, {1,2} and {1,3} respectively.
type OnLoop ¶
OnLoop is callback function which representing one of the animation methods. it will be called every time an animation "loops".
It will have two parameters: the animation instance, and how many loops have been elapsed.
The value would be Nop (No operation) if there's nothing to do except for looping the animation.
The most usual value (apart from none) is the string 'pauseAtEnd'. It will make the animation loop once and then pause and stop on the last frame.