Difference between revisions of "TexturePack.new"
m |
m (Text replacement - "<source" to "<syntaxhighlight") |
||
Line 5: | Line 5: | ||
=== Description === | === Description === | ||
Creates a new '''TexturePack''' object. This function creates the texture pack at runtime. | Creates a new '''TexturePack''' object. This function creates the texture pack at runtime. | ||
− | < | + | <syntaxhighlight lang="lua"> |
TexturePack.new(textures,padding,filtering,options) | TexturePack.new(textures,padding,filtering,options) | ||
</source> | </source> | ||
Line 17: | Line 17: | ||
=== Example === | === Example === | ||
'''Store all images in a folder to a table for use in TexturePack''' | '''Store all images in a folder to a table for use in TexturePack''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
local lfs = require "lfs" | local lfs = require "lfs" | ||
Line 49: | Line 49: | ||
=== Description === | === Description === | ||
Creates a new '''TexturePack''' object. This function loads the pre-packed texture atlas created by "'''Gideros Texture Packer'''" tool. | Creates a new '''TexturePack''' object. This function loads the pre-packed texture atlas created by "'''Gideros Texture Packer'''" tool. | ||
− | < | + | <syntaxhighlight lang="lua"> |
TexturePack.new(txtfile,imagefile,filtering,options) | TexturePack.new(txtfile,imagefile,filtering,options) | ||
</source> | </source> |
Revision as of 14:31, 13 July 2023
Available since: Gideros 2011.6
Class: TexturePack
Description
Creates a new TexturePack object. This function creates the texture pack at runtime. <syntaxhighlight lang="lua"> TexturePack.new(textures,padding,filtering,options) </source>
Parameters
textures: (table) file names of textures
padding: (number) the spacing between textures in pixels optional
filtering: (boolean, default = false) whether or not the texture is filtered, that is smoothing the image optional
options: (table) a table that specifies optional parameters optional. Currently, "transparentColor" and "format" fields are supported
Example
Store all images in a folder to a table for use in TexturePack <syntaxhighlight lang="lua"> local lfs = require "lfs"
local list = {}
function attrdir(path) for file in lfs.dir(path) do if file ~= "." and file ~= ".." then local f = path..'/'..file local attr = lfs.attributes(f) if attr.mode == "file" then table.insert(list, f) end end end end attrdir("gfx/hero") -- folder to fetch images from
--local tp = TexturePack.new({"gfx/hero/HQ_Trooper_all.png", "gfx/hero/caverman.png", "gfx/hero/test01.png"}) local tp = TexturePack.new(list) local bmp = Bitmap.new(tp:getTextureRegion("gfx/hero/caverman.png")) stage:addChild(bmp) </source>
Available since: Gideros 2011.6
Class: TexturePack
Description
Creates a new TexturePack object. This function loads the pre-packed texture atlas created by "Gideros Texture Packer" tool. <syntaxhighlight lang="lua"> TexturePack.new(txtfile,imagefile,filtering,options) </source>
Parameters
txtfile: (string) Gideros Texture Packer text file path
imagefile: (string) Gideros Texture Packer image file path
filtering: (boolean, default = false) whether or not the texture is filtered, that is smoothing the image optional
options: (table) a table that specifies optional parameters optional. Currently, "transparentColor" and "format" fields are supported