Documentation ¶
Overview ¶
Package goaseprite is an Aseprite JSON loader written in Golang.
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) GetSlice(sliceName string) *Slice
- func (asf *File) HasAnimation(animName string) bool
- func (asf *File) HasSlice(sliceName string) bool
- 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 Layer
- type Slice
- type SliceKey
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. Start and End are the starting and ending frame of the Animation. Direction is a string, and can be assigned one of the playback constants.
type File ¶
type File struct { ImagePath string Path string FrameWidth int32 FrameHeight int32 Frames []Frame Animations []Animation Layers []Layer 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. ImagePath is the absolute path to the image as reported by the exported Aseprite JSON data. Path is the string used to open the File if it was opened with the Open() function; otherwise, it's blank.
func Open ¶
Open will use os.Open() to open the Aseprite JSON file path specified to return a *goaseprite.File, relative to the current working directory. This can be your starting point. Files created with Open() will put the JSON filepath used in the returned File's Path field.
func ReadFile ¶
ReadFile returns a *goaseprite.File for a given file handle, in case you are opening the file yourself from another source (i.e. using the mobile asset package). This can also be your starting point,
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) GetSlice ¶
GetSlice returns a Slice that has the name specified. Note that a File can have multiple Slices by the same name.
func (*File) HasAnimation ¶
HasAnimation returns true if the File has an Animation of the specified name.
func (*File) HitTag ¶
HitTag returns if the File's playback just touched a tag by the specified name.
func (*File) HitTags ¶
HitTags returns a list of tags the File just touched by the file's playback on this frame.
func (*File) LeftTag ¶
LeftTag returns if the File's playback just left a tag by the specified name.
func (*File) LeftTags ¶
LeftTags returns a list of tags the File's playback just passed through on the last frame.
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 currently touching.
type Frame ¶
Frame contains timing and position information for the frame on the spritesheet. Note that Duration is in seconds.
type Layer ¶
Layer contains details regarding the layers exported from Aseprite, including the layer's name (string), opacity (0-255), and blend mode (string).
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.