Improved performance when displaying dynamic icons (e.g. collectibles, trinkets,...)
This commit is contained in:
1 parent
802fe2514f
commit
027ebb8dbd
1 file changed
+12
-5
+12
-5
@@ -55,6 +55,7 @@ local nullVector = Vector(0,0)
|
|||||||
local game = Game()
|
local game = Game()
|
||||||
local maxCardID = REPENTANCE and 97 or 54
|
local maxCardID = REPENTANCE and 97 or 54
|
||||||
local maxPillID = REPENTANCE and 14 or 13
|
local maxPillID = REPENTANCE and 14 or 13
|
||||||
|
local dynamicSpriteCache = {} -- used to store sprite objects of collectible icons etc.
|
||||||
|
|
||||||
-- Adds a description for a collectible. Optional parameters: itemName, language
|
-- Adds a description for a collectible. Optional parameters: itemName, language
|
||||||
function EID:addCollectible(id, description, itemName, language)
|
function EID:addCollectible(id, description, itemName, language)
|
||||||
@@ -527,11 +528,17 @@ function EID:createItemIconObject(str)
|
|||||||
if item == nil then
|
if item == nil then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
local spriteDummy = Sprite()
|
if dynamicSpriteCache[str] then
|
||||||
spriteDummy:Load("gfx/eid_inline_icons.anm2", true)
|
return dynamicSpriteCache[str]
|
||||||
spriteDummy:ReplaceSpritesheet(1, item.GfxFileName)
|
else
|
||||||
spriteDummy:LoadGraphics()
|
local spriteDummy = Sprite()
|
||||||
return {"ItemIcon",0,11,8,-2,-2,spriteDummy}
|
spriteDummy:Load("gfx/eid_inline_icons.anm2", true)
|
||||||
|
spriteDummy:ReplaceSpritesheet(1, item.GfxFileName)
|
||||||
|
spriteDummy:LoadGraphics()
|
||||||
|
local newDynamicSprite = {"ItemIcon",0,11,8,-2,-2,spriteDummy}
|
||||||
|
dynamicSpriteCache[str] = newDynamicSprite
|
||||||
|
return newDynamicSprite
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Returns the icon for a given transformation name or ID
|
-- Returns the icon for a given transformation name or ID
|
||||||
|
|||||||
Reference in new issue
Block a user