Difference between revisions of "Texture.loadAsync"
From GiderosMobile
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | + | '''Available since:''' Gideros 2021.8.1<br/> | |
− | ''' | + | '''Class:''' [[Texture]]<br/> |
− | ''' | ||
− | === | + | === Description === |
Asynchronously loads a texture from a file. | Asynchronously loads a texture from a file. | ||
− | < | + | <syntaxhighlight lang="lua"> |
Texture.loadAsync(callback,filename,filtering,options) | Texture.loadAsync(callback,filename,filtering,options) | ||
− | </ | + | </syntaxhighlight> |
− | === | + | === Parameters === |
− | '''callback''': (function) | + | '''callback''': (function) the function will be called with the Texture object as argument or an error as second argument.<br/> |
− | '''filename''': (string) | + | '''filename''': (string) the name of the texture file to be loaded.<br/> |
− | '''filtering''': (boolean, default = false) | + | '''filtering''': (boolean, default = false) whether or not the texture is filtered.<br/> |
− | '''options''': (table, optional) | + | '''options''': (table, optional) a table that specifies optional parameters. The following options are supported:<br/> |
− | * '''transparentColor''': | + | * '''transparentColor''': specifies which color stands for transparent, for formats that don't supply an alpha channel such as JPEG |
− | * '''wrap''': | + | * '''wrap''': how to treat texels outside the texture. Possible values are TextureBase.CLAMP and TextureBase.REPEAT |
− | * '''format''': | + | * '''format''': the GPU pixel format for the texture |
− | * '''extend''': | + | * '''extend''': wether the texture should be extended to a power of two size. Defaults to true |
− | * '''scale''': | + | * '''scale''': the scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1 |
− | === | + | === Example === |
− | < | + | <syntaxhighlight lang="lua"> |
Texture.loadAsync(function (texture, error) | Texture.loadAsync(function (texture, error) | ||
stage:addChild(Bitmap.new(texture)) | stage:addChild(Bitmap.new(texture)) | ||
end,"image.png", true, {wrap = Texture.REPEAT}) | end,"image.png", true, {wrap = Texture.REPEAT}) | ||
− | </ | + | </syntaxhighlight> |
− | |||
{{Texture}} | {{Texture}} |
Latest revision as of 14:33, 20 July 2024
Available since: Gideros 2021.8.1
Class: Texture
Description
Asynchronously loads a texture from a file.
Texture.loadAsync(callback,filename,filtering,options)
Parameters
callback: (function) the function will be called with the Texture object as argument or an error as second argument.
filename: (string) the name of the texture file to be loaded.
filtering: (boolean, default = false) whether or not the texture is filtered.
options: (table, optional) a table that specifies optional parameters. The following options are supported:
- transparentColor: specifies which color stands for transparent, for formats that don't supply an alpha channel such as JPEG
- wrap: how to treat texels outside the texture. Possible values are TextureBase.CLAMP and TextureBase.REPEAT
- format: the GPU pixel format for the texture
- extend: wether the texture should be extended to a power of two size. Defaults to true
- scale: the scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1
Example
Texture.loadAsync(function (texture, error)
stage:addChild(Bitmap.new(texture))
end,"image.png", true, {wrap = Texture.REPEAT})