Documentation ¶
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. 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 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.
func LoadData ¶
LoadData 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 (*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) 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) 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 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.
type SliceKey ¶
SliceKey represents a Slice's size and position in the Aseprite file. An individual Aseprite File can have multiple Slices inside, which can also have multiple frames in which the Slice's position and size changes. The SliceKey's Frame indicates which frame the key is operating on, and should generally also be the same as the index of the SliceKey in the Slice's Keys array.