TexturePack:getRegionsNames

From GiderosMobile
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Available since: Gideros 2021.9
Class: TexturePack

Description

Returns a list of all texture names in this pack.

(table) = TexturePack:getRegionsNames(texturename)

Parameters

texturename: (string) texture path

Return values

Returns (table) list of texture names in this pack

Example

-- pack all the deco images (TexturePack) for perf
local bgtpt = {} -- background texture pack table
local bgtptx = {} -- background texture pack table x
local fgtpt = {} -- foreground texture pack table
local fgtptx = {} -- foreground texture pack table x
for i = 1, #tm.layers do
	local layer = tm.layers[i]
	if layer.name:match("bg_deco_images") then
		if layer.name:sub(#layer.name) == "x" then
			for i = 1, #layer.objects do
				bgtptx[#bgtptx+1] = tilesetimages[layer.objects[i].gid].path
			end
		else
			for i = 1, #layer.objects do
				bgtpt[#bgtpt+1] = tilesetimages[layer.objects[i].gid].path
			end
		end
	elseif layer.name:match("fg_deco_images") then
		if layer.name:sub(#layer.name) == "x" then
			for i = 1, #layer.objects do
				fgtptx[#fgtptx+1] = tilesetimages[layer.objects[i].gid].path
			end
		else
			for i = 1, #layer.objects do
				fgtpt[#fgtpt+1] = tilesetimages[layer.objects[i].gid].path
			end
		end
	end
end

local bgtp = TexturePack.new(bgtpt, nil, nil, { format=TextureBase.RGBA4444, } )
local bgtpx = TexturePack.new(bgtptx, nil, nil, { format=TextureBase.RGBA4444, } )
local fgtp = TexturePack.new(fgtpt, nil, nil, { format=TextureBase.RGBA4444, } )
local fgtpx = TexturePack.new(fgtptx, nil, nil, { format=TextureBase.RGBA4444, } )
if #bgtp:getRegionsNames() > 0 then print(bgtp:getSize()) end
if #bgtpx:getRegionsNames() > 0 then print(bgtpx:getSize()) end
if #fgtp:getRegionsNames() > 0 then print(fgtp:getSize()) end
if #fgtpx:getRegionsNames() > 0 then print(fgtpx:getSize()) end