TexturePack:getTextureRegion: Difference between revisions

From GiderosMobile
No edit summary
m Text replacement - "</source>" to "</syntaxhighlight>"
 
(2 intermediate revisions by 2 users not shown)
Line 5: Line 5:
=== Description ===
=== Description ===
Returns the texture region for the given texture name.
Returns the texture region for the given texture name.
<source lang="lua">
<syntaxhighlight lang="lua">
(TextureRegion) = TexturePack:getTextureRegion(texturename)
(TextureRegion) = TexturePack:getTextureRegion(texturename)
</source>
</syntaxhighlight>


=== Parameters ===
=== Parameters ===
'''texturename''': (string) texture name<br/>
'''texturename''': (string) packed texture path<br/>


=== Return values ===
=== Return values ===
Line 16: Line 16:


=== Example ===
=== Example ===
<source lang="lua">
<syntaxhighlight lang="lua">
local pack = TexturePack.new({"gfx/1.png", "gfx/2.png", "gfx/3.png", "gfx/4.png"})
local pack = TexturePack.new({"gfx/1.png", "gfx/2.png", "gfx/3.png", "gfx/4.png"})


Line 23: Line 23:
local region3 = pack:getTextureRegion("gfx/3.png")
local region3 = pack:getTextureRegion("gfx/3.png")
local region4 = pack:getTextureRegion("gfx/4.png")
local region4 = pack:getTextureRegion("gfx/4.png")
</source>
</syntaxhighlight>


{{TexturePack}}
{{TexturePack}}

Latest revision as of 13:33, 13 July 2023

Available since: Gideros 2011.6
Class: TexturePack

Description

Returns the texture region for the given texture name.

(TextureRegion) = TexturePack:getTextureRegion(texturename)

Parameters

texturename: (string) packed texture path

Return values

Returns (TextureRegion) TextureRegion by specified name

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")