Difference between revisions of "TexturePack:getTextureRegion"

From GiderosMobile
Line 16: Line 16:
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Example'''<br/>
 
'''Example'''<br/>
<source lang="lua">local pack = TexturePack.new({&quot;gfx/1.png&quot;, &quot;gfx/2.png&quot;, &quot;gfx/3.png&quot;, &quot;gfx/4.png&quot;})
+
<source lang="lua">local pack = TexturePack.new({"gfx/1.png", "gfx/2.png", "gfx/3.png", "gfx/4.png"})
  
local region1 = pack:getTextureRegion(&quot;gfx/1.png&quot;)
+
local region1 = pack:getTextureRegion("gfx/1.png")
local region2 = pack:getTextureRegion(&quot;gfx/2.png&quot;)
+
local region2 = pack:getTextureRegion("gfx/2.png")
local region3 = pack:getTextureRegion(&quot;gfx/3.png&quot;)
+
local region3 = pack:getTextureRegion("gfx/3.png")
local region4 = pack:getTextureRegion(&quot;gfx/4.png&quot;)</source>
+
local region4 = pack:getTextureRegion("gfx/4.png")</source>

Revision as of 15:46, 26 June 2019


Available since: Gideros 2011.6
Class: TexturePack

Description


Returns the texture region of texture pack.

(TextureRegion) = TexturePack:getTextureRegion(texturename)

Parameters

texturename: (string)

Return values

Returns (TextureRegion) TextureRegion by specified name

Examples

Example

local pack = TexturePack.new({"gfx/1.png", "gfx/2.png", "gfx/3.png", "gfx/4.png"})

local region1 = pack:getTextureRegion("gfx/1.png")
local region2 = pack:getTextureRegion("gfx/2.png")
local region3 = pack:getTextureRegion("gfx/3.png")
local region4 = pack:getTextureRegion("gfx/4.png")