Documentation ¶
Overview ¶
Package goaseprite is an Aseprite JSON loader written in Golang.
The package is basically written around using goaseprite.Load() to load in your exported file's JSON data, and then using that to play and get the data necessary to display the animations.
Index ¶
- Constants
- type Animation
- type File
- func (asf *File) FinishedAnimation() bool
- func (asf *File) GetAnimation(animName string) *Animation
- func (asf *File) GetFrameXY() (int32, int32)
- func (asf *File) HitTag(tagName string) bool
- func (asf *File) HitTags() []string
- func (asf *File) IsPlaying(animName string) bool
- func (asf *File) LeftTag(tagName string) bool
- func (asf *File) LeftTags() []string
- func (asf *File) Play(animName string)
- func (asf *File) TouchingTag(tagName string) bool
- func (asf *File) TouchingTags() []string
- func (asf *File) Update(deltaTime float32)
- type Frame
- type Slice
Constants ¶
const ( // PlayForward plays animations forward PlayForward = "forward" // PlayBackward plays animations backwards PlayBackward = "reverse" // PlayPingPong plays animation forward then backward PlayPingPong = "pingpong" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Animation ¶
Animation contains details regarding each animation from Aseprite. This also represents a tag in Aseprite and in goaseprite. Direction is a string, and can be assigned one of the playback constants.
type File ¶
type File struct { ImagePath string FrameWidth int32 FrameHeight int32 Frames []Frame Animations []Animation CurrentAnimation *Animation CurrentFrame int32 PrevFrame int32 PlaySpeed float32 Playing bool Slices []Slice // contains filtered or unexported fields }
File contains all properties of an exported aseprite file.
func Load ¶
Load parses and returns an File for a supplied JSON exported from Aseprite. This is your starting point. goaseprite is set up to read JSONs for sprite sheets exported with the Hash type.
func LoadBytes ¶
LoadBytes parses and returns an File from JSON exported from Aseprite. An alternative to Load(filePath) when no file-system is available (jsgo.io, for example) ase.ImagePath will be empty
func (*File) FinishedAnimation ¶
FinishedAnimation returns true if the animation is finished playing. When playing forward or backward, it returns true on the frame that the File loops the animation (assuming the File gets Update() called every game frame). When playing using ping-pong, this function will return true when a full loop is finished (when the File plays forwards and then backwards, and loops again).
func (*File) GetAnimation ¶
GetAnimation returns a pointer to an Animation of the desired name. If it can't be found, it will return `nil`.
func (*File) GetFrameXY ¶
GetFrameXY returns the current frame's X and Y coordinates on the source sprite sheet for drawing the sprite.
func (*File) HitTag ¶
HitTag returns if the File's playback just touched a tag by the specified name.
func (*File) LeftTag ¶
LeftTag returns if the File's playback just left a tag by the specified name.
func (*File) TouchingTag ¶
TouchingTag returns if the File's playback is touching a tag by the specified name.
func (*File) TouchingTags ¶
TouchingTags returns a list of tags the playback is touching.
type Frame ¶
Frame contains timing and position information for the frame on the spritesheet. Note that Duration is in seconds.
type Slice ¶
Slice represents a Slice (rectangle) that was defined in Aseprite and exported in the JSON file. Data by default is blank, but can be specified on export from Aseprite to be whatever you need it to be. Note that StartingFrame is what frame of the Aseprite file the animation started on, but in the future this will probably change if actual animation capability is added to slices.