Table of Contents
17. Table texture¶
A table texture inherit from renderizable and normally have one animation. Also the animation has a shader table by default which can be accessed by getShader method.
17.1. texture methods¶
17.1.1. texture new¶
- new(string * world, number * x, number * y, number * z)¶
Create a new instance of a texture passing the world desired (detail) and position.
- Parameters
string – world can be
2ds
,2dw
or3d
.number – x position (optional).
number – y position (optional).
number – z position (optional).
- Returns
texture table.
Example:
tTex = texture:new('2dw') --note that texture inherits from renderizable
tTex:setPos(100,100,-1)
17.1.2. texture load¶
- load(string file_name, number * width, number * height)¶
Load a texture from file at any format listed at images supported types.
The number
width
andheight
(optional) are the frame size.- Parameters
string – file name from texture.
number – width frame (optional).
number – height frame (optional).
boolean – alpha force to use or not (default is
true
)(optional).
- Returns
boolean result.
Example:
tTexture = texture:new('2ds')
if tTexture:load('mario.png') then
print('Successfully loaded texture:','mario.png')
else
print('Failed to loaded texture:','mario.png')
end
Note
17.1.3. texture setSize¶
- setSize(number width, number height)¶
Resize the frame size from texture.
- Parameters
number – width from frame.
number – height from frame.
Example:
tTex = texture:new('2dw') --note that texture inherits from renderizable
tTex:setPos(100,100,-1)
tTex:setSize(50,50)
Note
Always the image will adapt to the frame size.
17.2. Creating a texture programmatically¶
Here an example how to create a texture programmatically using the engine to do that.
Please check the page creating texture