Skip to content

Commit

Permalink
Sprite api: Added loading from gifs
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinW1998 committed Aug 18, 2015
1 parent be85a1f commit 12c8b39
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions LuaScriptsLibExt/sprite.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,20 @@ function AnimationSetFactory.fromSubImages(imgs)
return animationSet
end

function AnimationSetFactory.fromGif(path)
local typeOfPath = type(path)
if(typeOfPath ~= "string")then
error("Arg #1 path expected string (got " .. typeOfPath .. ")", 2)
end

local gifFrames, frameSpeed = Graphics.loadAnimatedImage(path)
if(#gifFrames == 0)then
return nil
end

return AnimationSetFactory.fromImages(gifFrames), frameSpeed
end



-- SPRITE CLASS BEGIN
Expand Down Expand Up @@ -379,6 +393,10 @@ function SpriteFactory.animationFromImages(...)
return AnimationSetFactory.fromImages(...)
end

function SpriteFactory.animationFromGif(...)
return AnimationSetFactory.fromGif(...)
end

function SpriteFactory.animationFromSubImages(...)
return AnimationSetFactory.fromSubImages(...)
end
Expand Down

0 comments on commit 12c8b39

Please sign in to comment.