So, i’ve seen alot of posts about people asking how to use sprite sheets.
Sprite sheets are a bit of a hassle, and can make code messy. So, thats why I made this module to make things more easier, and cleaner.
Code example:
local player = require(script:WaitForChild("SpritePlayer"))
local img = script.Parent
--You can use NewControllerManual and NewControlerImages as well. More info below about them.
local anim = player.NewController(img,false,{
FPS = 13;
RectSize = Vector2.new(330,330);
Increments = Vector2.new(341,335);
Colums = 3;
Rows = 3;
Loop = true;
})
anim:Play()
Module link here:
Infomation:
Arguments:
local img = ImageLabel/ImageButton
local controller = module.NewController(img,
{
FPS = How many frames per second are played
RectSize = ImageRectSize;
Increments = Vector2.new(X increment,Y increment)
Colums = Amount of colums
Rows = Amount of rows
Loop = true to loop it, false to not.
Start = The starting imagerectoffset, make nil if you dont want a starting postion
Ignore = {
{Numbers of the sprite postions to ignore (etc if you put one, it skips the first one.), The colum that is where its ignored}
}
}
)
local img = ImageLabel/ImageButton
local controller = module.NewControllerManual(img,
{
FPS = How many frames per second are played
Data = {
{RectOffset (optional),RectSize (optional),imagelabel size (optional)}
}
Loop = true to loop it, false to not.
}
local img = ImageLabel/ImageButton
local controller = module.NewControllerImages(img,
{
FPS = How many frames per second are played
Data = {
"image1";
"image2"
}
Loop = true to loop it, false to not.
}
Usage:
local player = require(whatever)
local img = script.Parent
local anim = player.NewController(img,ismanual,{
data
})
anim:AdjustSpeed(1) 1 is defualt, 2 is 2x the fps, has to be run before its playing
the two below are self explanatory
anim:Play()
anim:Stop()
anim:Update(ismanual,data) update the data
Example game: