Skip to content

Supercharge your Aseprite Workflow with custom scripts and a Go module - Now works with embedded assets, too.

License

Notifications You must be signed in to change notification settings

andygeiss/aseprite-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aseprite-GO

Go Report Card

Supercharge your Aseprite Workflow with custom scripts and a Go module - Now works with embedded assets, too.

Adam shared some bits and pieces that he uses all the time in Aseprite to speed up his workflow on YouTube.

He and others provided custom scripts which could be used to split a single spritesheet into multiple files by using the tags.

With this Go module you can automatically extract the generated spritesheets and use it in your Go project.

Install the scripts

Copy the .lua files from the plugins folder to your Aspeprite scripts folder and use the Rescan (F5) function.

Scripts

Open example project

Open the sprites folder with Aseprite and open the player.aseprite file.

This spritesheet contains an idle and walk animation facing the up, down, left and right direction. player

Now use the script menu in Aseprite to execute export_tags_to_sheets which creates a corresponding .json and .png file for each tag.

Read the spritesheets with Go

func main() {
    path := filepath.Join("sprites")
    sprites, _ := aseprite.LoadSpritesheet(path)

    frames := sprites["player-idle-down"] // get access to the frames of the animation
    
    duration := frames[0].DurationMs // get the duration in milliseconds
    pos_x := frames[0].PosX // get x and y position in the spritesheet
    pos_y := frames[0].PosY
    png := filepath.Join("sprites", "player-idle-down.png") // spritesheet is always key + .png
}

Now everytime you change something in Aseprite the spritesheets could be immediatly used after using the export scripts!

Support for embedded assets

Since Go 1.16 we have the embed package which enables us to include our assets into the binary. You could read the Spritesheets from there by using the LoadSpritesheetEmbed function.

//go:embed sprites
var sprites embed.FS

func main() {
    path := filepath.Join("sprites")
    sprites, _ := aseprite.LoadSpritesheetEmbed(path, sprites)
    ...
}

About

Supercharge your Aseprite Workflow with custom scripts and a Go module - Now works with embedded assets, too.

Resources

License

Stars

Watchers

Forks

Packages

No packages published