![]() ![]() OnTagExit func(tag * Tag) // OnTagExit gets called when exiting a tag from inside of it (i.e. if not playing a tag and then it gets played, this gets called, or if you're playing a tag and you pass through another tag). OnTagEnter func(tag * Tag) // OnTagEnter gets called when entering a tag from "outside" of it (i.e. OnFrameChange func() // OnFrameChange gets called when the playing animation / tag changes frames. For a ping-pong animation, this is a full forward + back cycle. Callbacks OnLoop func() // OnLoop gets called when the playing animation / tag does a complete loop. PrevFrameIndex int // The previous frame in the playback. FrameIndex int // The current frame of the File's animation / tag playback. CurrentTag * Tag // The currently playing animation. PlaySpeed float32 // The playback speed altering this can be used to globally slow down or speed up animation playback. Slices * Slice // A slice of the Slices present in the file. ![]() Tags map* Tag // A map of Tags, with their names being the keys. Frames * Frame // The animation Frames present in the File. FrameWidth, FrameHeight int32 // Width and height of the frames in the File. Width, Height int32 // Overall width and height of the File. ImagePath string // Path to the image associated with the Aseprite file (exampleSprite.png). Path string // Path to the file (exampleSprite.json) blank if the *File was loaded using Read(). That's roughly it! Additional NotesĪs for dependencies, GoAseprite makes use of tidwall's nice gjson package. You also have the ability to use File.OnLoop, File.OnFrameChange, File.OnTagEnter, and File.OnTagExit callbacks to trigger events when an animation's state changes, for example. Img, _, err := ebitenutil.NewImageFromFile()įunc (game *Game) Draw(screen *ebiten.Image) Sprite: goaseprite.Open("16x16Deliveryman.json"), Here'a quick example, using ebiten for rendering: package main Assuming a tag with a blank name ("") doesn't exist in your Aseprite file, goaseprite will create a default animation with that name, allowing you to easily play all of the frames in sequence. Call File.CurrentFrame() to get the current frame, which gives you the X and Y position of the current frame on the sprite sheet. You can call File.Play() to play a tag / animation, and use the File.Update() function with an argument of delta time (the time between the previous frame and the current one) to update the animation. It's from here that you control your animation. From this, you'll get a *goaseprite.File, which represents an Aseprite file. To do this, you'll call goaseprite.Open() with a string argument of where to find the Aseprite JSON data file, or manually pass the bytes to goaseprite.Read(). Then you'll want to load the Aseprite data. The values should be set to Hash with Frame Tags and Slices (optionally) on. You export a sprite sheet and its corresponding JSON data file from Aseprite (Ctrl+E). Goaseprite is a JSON loader for Aseprite files for Golang.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |