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
  • stringworld can be 2ds, 2dw or 3d.

  • numberx position (optional).

  • numbery position (optional).

  • numberz 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 and height (optional) are the frame size.

Parameters
  • stringfile name from texture.

  • numberwidth frame (optional).

  • numberheight frame (optional).

  • booleanalpha 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

The load method will search in all known path.
You can add a path to search by the method addPath.

17.1.3. texture setSize

setSize(number width, number height)

Resize the frame size from texture.

Parameters
  • numberwidth from frame.

  • numberheight 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