Difference between revisions of "Texture.loadAsync"

From GiderosMobile
(removed language stuff)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
<languages />
+
'''Available since:''' Gideros 2021.8.1<br/>
'''<translate>Available since</translate>:''' Gideros 2021.8.1<br/>
+
'''Class:''' [[Texture]]<br/>
'''<translate>Class</translate>:''' [[Special:MyLanguage/Texture|Texture]]<br/>
 
  
=== <translate>Description</translate> ===
+
=== Description ===
 
Asynchronously loads a texture from a file.
 
Asynchronously loads a texture from a file.
 
<source lang="lua">
 
<source lang="lua">
Line 10: Line 9:
 
</source>
 
</source>
  
=== <translate>Parameters</translate> ===
+
=== Parameters ===
'''callback''': (function) <translate>The function will be called with the Texture object as argument or an error as second argument.</translate><br/>
+
'''callback''': (function) the function will be called with the Texture object as argument or an error as second argument.<br/>
'''filename''': (string) <translate>The name of the texture file to be loaded.</translate><br/>
+
'''filename''': (string) the name of the texture file to be loaded.<br/>
'''filtering''': (boolean, default = false) <translate>Whether or not the texture is filtered.</translate><br/>
+
'''filtering''': (boolean, default = false) whether or not the texture is filtered.<br/>
'''options''': (table, optional) <translate>A table that specifies optional paramaters. The following options are supported:</translate><br/>
+
'''options''': (table, optional) a table that specifies optional parameters. The following options are supported:<br/>
  
* '''transparentColor''':<translate>Specify which color stands for transparent, for formats that don't supply an alpha channel such as JPEG</translate>
+
* '''transparentColor''': specifies which color stands for transparent, for formats that don't supply an alpha channel such as JPEG
* '''wrap''':<translate>How to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT.</translate>
+
* '''wrap''': how to treat texels outside the texture. Possible values are Texture.CLAMP and Texture.REPEAT.
* '''format''':<translate>The GPU pixel format for the texture</translate>
+
* '''format''': the GPU pixel format for the texture
* '''extend''':<translate>Wether the texture should be extended to a power of two size. Defaults to true.</translate>
+
* '''extend''': wether the texture should be extended to a power of two size. Defaults to true.
* '''scale''':<translate>The scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1.</translate>
+
* '''scale''': the scale at which this texture was made, if it cannot be determined by a suffix. Defaults to 1.
  
=== <translate>Example</translate> ===
+
=== Example ===
 
<source lang="lua">
 
<source lang="lua">
 
Texture.loadAsync(function (texture, error)
 
Texture.loadAsync(function (texture, error)
Line 28: Line 27:
 
end,"image.png", true, {wrap = Texture.REPEAT})
 
end,"image.png", true, {wrap = Texture.REPEAT})
 
</source>
 
</source>
 
  
 
{{Texture}}
 
{{Texture}}

Revision as of 22:21, 15 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 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 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})