SpritePlayer - For all your sprite sheet needs!

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:

12 Likes

Cool for 2D games. like for walking animations, idle and , now we can make gifs in Roblox!

but can you make it like this:

local template = {
Frames = {
[1] = imgid
[2] = imgid
}
fps = 15
loop = true
}
1 Like

Ah, sure! I see you want to use images. I will add that in a future update.

1 Like

Updated the module, allows you to use images now!

Thanks to @geometrical for the idea.

Check the list of arguments and usage for new info on how to use the updated module.

Does this support the function of chaining images(when one image cycles through it switches to the next one)?

No, but i’m planning to add it!
Thanks for your suggestion, I will add it in a future update.

Right now, though, you can do that using :Stop() and :Start() function to restart and changing the Image of the imagelabel after stopping it and before starting it

1 Like