Added looping support for when tilesPerFrame is not evenly divisible into total number of tiles