local n=""local M=1 local h=2 local P=M*h local L=256 local V=384 local f=2 assert((numImages*M)*h>=f)local K=.5 assert(K>0)local y=0 local t=0 local O=f/K local a=0 local function T(n)a=math.fmod(a+n,K)t=math.floor(a*O)local M=y y=math.floor(t/P)if M~=y then imageInstance.Image=imageAssetIDs[y+1]end local f=t-y*P local T=math.floor(f/h)local i=f-T*h imageInstance.ImageRectOffset=Vector2.new(i*L,T*V)end Animator.Connection=nil Animator.Init=function()Animator.Connection=(game:GetService("\082\117\110\083\101\114\118\105\099\101")).RenderStepped:Connect(T)end Animator.Stop=function()if Animator.Connection then imageInstance.Image=n Animator.Connection:Disconnect()end end return Animator

local initialTexture = ""

local RowCount = 1
local ColCount = 2
local perImageSpriteCount = RowCount * ColCount
local width = 256
local height = 384

local framesInTotal = 2
assert(numImages * RowCount * ColCount >= framesInTotal)

local animPeriod = 0.5 -- period for the whole animation, in seconds
assert(animPeriod > 0)

local curImageIdx = 0
local curSpriteIdx = 0

local fps = framesInTotal / animPeriod
local accumulatedTime = 0

local function AnimateImageSpriteSheet(dt)
	accumulatedTime = math.fmod(accumulatedTime + dt, animPeriod)
	curSpriteIdx = math.floor(accumulatedTime * fps)

	local prevImageIndex = curImageIdx
	curImageIdx = math.floor(curSpriteIdx / perImageSpriteCount)
	if prevImageIndex ~= curImageIdx then
		imageInstance.Image = imageAssetIDs[curImageIdx + 1]
	end

	local localSpriteIndex = curSpriteIdx - curImageIdx * perImageSpriteCount
	local row = math.floor(localSpriteIndex / ColCount)
	local col = localSpriteIndex - row * ColCount
	imageInstance.ImageRectOffset = Vector2.new(col * width, row * height)
end

Animator.Connection = nil

Animator.Init = function()
	Animator.Connection = game:GetService("RunService").RenderStepped:Connect(AnimateImageSpriteSheet)
end

Animator.Stop = function()
	if Animator.Connection then
		imageInstance.Image = initialTexture
		Animator.Connection:Disconnect()
	end
end


return Animator
