Sprite sheets can be very useful for bypassing Roblox’s limits regarding detailed GUI animations, but most creators tend to avoid them due to them being hard to set up.
This module is my attempt to bypass this issue by packing this feature into a single easily manipulable class. The module itself only contains a single .new function which returns a SpriteClip object, to which any Instance with an “Image” property can be assigned.
There is no limit to how many sprite sheets can be run at the same time; however, the module will iterate through all created SpriteClips, so remember to use :Destroy() when they are no longer required.
The documentation is also found in the module.
Properties: <Instance> Adornee Def: nil Desc: The image Instance to work on. <string> SpriteSheet Def: nil Desc: The asset URL of the sprite sheet. Check value below. <bool> InheritSpriteSheet Def: true Desc: Whether the SpriteSheet value will automatically take the Image value of a GUI object when the Adornee is set. <number> CurrentFrame Def: 1 <Vector2> SpriteSizePixel Def: (100,100) Desc: Size of individual sprite in pixels <Vector2> SpriteOffsetPixel Def: (0,0) Desc: Offset between sprites <Vector2> EdgeOffsetPixel Def: (0,0) Desc: Offset from sprite sheet's edge <number> SpriteCount Def: 25 Desc: Global sprite count <number> SpriteCountX Def: 5 Desc: Horizontal sprite count <number> FrameRate Def: 15 Desc: Framerate that gets turned into FrameTime, needs to be a divisor of 60 <number> FrameTime Def: 4 Desc: How many frames to skip-1 <bool> Looped Def: true Desc: If the CurrentFrame will reset after each cycle <bool> State Def: false Desc: Whether the animation is playing Functions: (<bool>success) :Play() Desc: Sets the State property to true (<bool>success) :Pause() Desc: Sets the State property to false (<bool>success) :Stop() Desc: Pauses the animation and resets the frames () :Advance(<number>count) Desc: Increments animation by 1 frame () :Destroy() Desc: Removes the animation from the list and clears its metatable. (<SpriteClip>clone) :Clone() Desc: Creates a new SpriteClip with the same properties as the original. Doesn't copy Adornee.
NOTE: Roblox will automatically resize large images, so you will have to download the asset after uploading to check the real resolution.
A ScreenGui model as an example of usage:
SpriteClipExample.rbxm (7.1 KB)
I found an error that would cause the first frame to get skipped after one cycle. I reuploaded the module as a new asset to avoid potentially breaking any existing games and updated the example model.
Roblox changed the link used to download assets. There are many threads describing how to do this that are obsolete. Use this link instead: