Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(2 edits) (+3)
 This is a simple frame animation code. It still needs polishing. I have another version of this code that works better, but it loses a lot of performance.
 The code below is for performance... I don't know how to make something lighter than this yet..
--
do

 
  local catSprites = {}
  for i = 0, 99 do
    --
    local frameName = string.format("frame_%03d_delay-0.01s.png", i)
    catSprites[i] = ModUtilities.GetSpriteReference(CurrentModGuid, frameName)
  end


  local unityCoro3utine


  
  function catSpecialEffect(value, item0)
    local itemGuid = item0.GetUniqueGuid()
    local targetPath = "/Room/GhostBackground"


    if value and item0.IsEquipped() then
      
      function Coroutine()
        while true do
        
          for i = 0, 99 do
            if catSprites[i] then
              TextureOverriderManager.RoomManager.SetSprite(itemGuid, targetPath, catSprites[i])
            end
         
            coroutine.yield(ModUtilities.WaitForSeconds(0.1))
          end
        end
      end
      unityCoroutine = ModUtilities.StartCoroutine(Coroutine)
    else
 
      if unityCoroutine then
        ModUtilities.StopCoroutine(unityCoroutine)
        unityCoroutine = nil
      end
      TextureOverriderManager.RoomManager.RestoreSprite(itemGuid, targetPath)
    end
  end