Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
How I get all regions of a texturepack? — Gideros Forum

How I get all regions of a texturepack?

edited January 2014 in General questions
I noticed that TexturePack method getTextureRegion takes a string as argument.

If I don't know the contents of the TexturePack, how I get all its regions? (ie: so I can load .txt files that I did not create and use them)
I make games for children: http://www.kidoteca.com

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited January 2014
    Unfortunately no integrated way, but you could always parse the .txt files, something like that:
    function getPackTextures(packname)
        local textures = {}
        local file = io.open(packname..".txt")
        if file then
            local parsed
            for line in file:lines() do
                parsed = line:split(", ")) 
                textures[#textures+1] = parsed[1]
            end
            -- now variable textures contains all texture names from pack
        else
            print("no pack found")
        end
        return textures
    end
  • Alright, I will use that for now.

    But can a internal function be added for this? I found it is just silly you cannot query what regions exist!
    I make games for children: http://www.kidoteca.com
Sign In or Register to comment.