Difference between revisions of "Texture.loadAsync"
From GiderosMobile
(Created page with "__NOTOC__ <languages /> '''<translate>Available since</translate>:''' Gideros 2021.8.1<br/> '''<translate>Class</translate>:''' Texture<br/> ==...") |
|||
Line 11: | Line 11: | ||
=== <translate>Parameters</translate> === | === <translate>Parameters</translate> === | ||
− | '''callback''': (function) <translate>The function will be called with the Texture object as argument.</translate><br/> | + | '''callback''': (function) <translate>The function will be called with the Texture object as argument or an error as second argument.</translate><br/> |
'''filename''': (string) <translate>The name of the texture file to be loaded.</translate><br/> | '''filename''': (string) <translate>The name of the texture file to be loaded.</translate><br/> | ||
'''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate><br/> | '''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate><br/> | ||
Line 24: | Line 24: | ||
=== <translate>Example</translate> === | === <translate>Example</translate> === | ||
<source lang="lua"> | <source lang="lua"> | ||
− | Texture.loadAsync(function (texture) | + | 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}) |
Revision as of 16:16, 6 September 2021
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 paramaters. The following options are supported:
- transparentColor:Specify 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 Texture.CLAMP and Texture.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})