Difference between revisions of "TexturePack.new"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Class:''' [[TexturePack]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/TexturePack|TexturePack]]<br/>
+
 
=== <translate>Description</translate> ===
+
=== Description ===
<translate><br />
+
Creates a new '''TexturePack''' object. This function creates the texture pack at runtime.
Creates a new [[Special:MyLanguage/TexturePack|TexturePack]] object. This function creates the texture pack at runtime.<br />
+
<syntaxhighlight lang="lua">
<br /></translate>
+
TexturePack.new(textures,padding,filtering,options)
<source lang="lua">
+
</syntaxhighlight>
TexturePack.new(textures,padding,filtering,options)
+
 
</source>
+
=== Parameters ===
=== <translate>Parameters</translate> ===
+
'''textures''': (table) file names of textures<br/>
'''textures''': (table) <translate>file names of textures.</translate> <br/>
+
'''padding''': (number) the spacing between textures in pixels '''optional'''<br/>
'''padding''': (number) <translate>the spacing between textures in pixels</translate> <br/>
+
'''filtering''': (boolean, default = false) whether or not the texture is filtered, that is smoothing the image '''optional'''<br/>
'''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate> <br/>
+
'''options''': (table) a table that specifies optional parameters '''optional'''. Currently, "transparentColor" and "format" fields are supported<br/>
'''options''': (table, optional) <translate>A table that specifies optional paramaters. Currently, &quot;transparentColor&quot; and &quot;format&quot fields are supported.</translate> <br/>
+
 
 +
=== 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)
 +
</syntaxhighlight>
 +
 
 +
 
 +
----
 +
 
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Class:''' [[TexturePack]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/TexturePack|TexturePack]]<br/>
+
 
=== <translate>Description</translate> ===
+
=== Description ===
<translate><br />
+
Creates a new '''TexturePack''' object. This function loads the pre-packed texture atlas created by "'''Gideros Texture Packer'''" tool.
Creates a new [[Special:MyLanguage/TexturePack|TexturePack]] object. This function loads the pre-packed texture atlas created by &quot;Gideros Texture Packer&quot; tool.<br />
+
<syntaxhighlight lang="lua">
<br /></translate>
+
TexturePack.new(txtfile,imagefile,filtering,options)
<source lang="lua">
+
</syntaxhighlight>
TexturePack.new(txtfile,imagefile,filtering,options)
+
 
</source>
+
=== Parameters ===
=== <translate>Parameters</translate> ===
+
'''txtfile''': (string) '''Gideros Texture Packer''' text file path<br/>
'''txtfile''': (string) <translate></translate> <br/>
+
'''imagefile''': (string) '''Gideros Texture Packer''' image file path<br/>
'''imagefile''': (string) <translate></translate> <br/>
+
'''filtering''': (boolean, default = false) whether or not the texture is filtered, that is smoothing the image '''optional'''<br/>
'''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate> <br/>
+
'''options''': (table) a table that specifies optional parameters '''optional'''. Currently, "transparentColor" and "format" fields are supported<br/>
'''options''': (table, optional) <translate>A table that specifies optional paramaters. Currently, &quot;transparentColor&quot; and &quot;format&quot fields are supported.</translate> <br/>
+
 
 +
{{TexturePack}}

Latest revision as of 14:33, 13 July 2023

Available since: Gideros 2011.6
Class: TexturePack

Description

Creates a new TexturePack object. This function creates the texture pack at runtime.

TexturePack.new(textures,padding,filtering,options)

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

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)




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.

TexturePack.new(txtfile,imagefile,filtering,options)

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