spriteutil

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: BSD-3-Clause Imports: 8 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

spriteutil

Just a few things for use with faiface/pixel 2D library

Animated GIF in Pixel

Using github.com/faiface/pixel we can display animated GIF images!

import (
    "github.com/aerth/spriteutil"
)

func run(){
// ...
sprite, err := spriteutil.LoadGif(file)
if err != nil { return err }
sprite.Update(dt)
sprite.Draw(win, pixel.IM)
// ...
}

Image/Font Credits:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTTF

func LoadTTF(rdr io.Reader, size float64, origin pixel.Vec) *text.Text

Types

type AnimatedSprite

type AnimatedSprite struct {
	// contains filtered or unexported fields
}

AnimatedSprite holds gif frames and manages timing. don't forget to call `a.Update(dt)`

func LoadGif

func LoadGif(file io.Reader) (*AnimatedSprite, error)

LoadGif returns an AnimatedSprite

func (*AnimatedSprite) Draw

func (a *AnimatedSprite) Draw(t pixel.Target, m pixel.Matrix)

Draw a gif frame onto a target

func (*AnimatedSprite) Update

func (a *AnimatedSprite) Update(dt float64)

Update gif frame based on time that has passed since last call to Update Get dt in your mainloop like this: `dt = time.Since(last).Seconds()`

Jump to

Keyboard shortcuts

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