Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I animate sprite sheets larger than 1024x1024?

Asked by 7 years ago
Edited 7 years ago

I'm trying to animate some pokemon. I first tried animating the sprite sheet of chandelure, which failed with some odd graphical issues. I then tried animating diancie, a much smaller sprite sheet, with perfect success. How would I animate a sprite sheet larger than 1024x1024?

local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer.PlayerGui

local totalFrames = 39
local xColumns = 6 -- There are 6 columns of frames, 7 rows of frames
local yRows = 7
local xSize = 96 -- A single frame is 96x96
local ySize = 96

local diancie = Instance.new("ImageLabel")
diancie.Parent = screenGui
diancie.Position = UDim2.new(0.25, 0, 0.5, 0) -- Sets image to the left of the screen
diancie.AnchorPoint = Vector2.new(0.5, 0.5) -- Anchors the image
diancie.Size = UDim2.new(0, xSize, 0, ySize) -- Sets the image's size to frame size
diancie.Image = "rbxgameasset://Images/diancie-sprite-sheet" -- Sets the image location
diancie.BackgroundTransparency = 1 -- Sets background transparency to 100%
diancie.ImageRectSize = Vector2.new(xSize ,ySize) -- Sets a frame to be equal to 96x96

while true do
    local currentFrame = 0
    for yOffset = 0, (yRows - 1) do
        for xOffset = 0, (xColumns - 1) do
            wait(0.05)
            diancie.ImageRectOffset = Vector2.new(xOffset * xSize, yOffset * ySize)
            currentFrame = currentFrame + 1
            if currentFrame == totalFrames then
                break
            end
        end
    end
end

Answer this question