Asset

Simple wrapper for the asset class.
Return to Index
static new ( string asset_name )
__gc ( )
__eq ( am.asset rhs ) -> ( boolean )
name ( ) -> ( string )
texture ( integer index = 0 ) -> ( am.texture )
texture ( am.texture texture , integer index = 0 ) -> ( am.asset , am.code )
texture ( string filename , integer index = 0 ) -> ( am.asset , am.code )
add_texture ( am.texture texture ) -> ( am.asset , am.code )
add_texture ( string filename ) -> ( am.asset , am.code )
remove_texture ( string filename ) -> ( am.asset )
remove_texture ( am.texture texture ) -> ( am.asset )
has_texture ( string filename ) -> ( boolean )
has_texture ( am.texture texture ) -> ( boolean )
remove_all_textures ( ) -> ( am.asset )
total_textures ( ) -> ( integer )
total_texture_windows ( ) -> ( integer )
total_texture_windows ( integer total_texture_windows ) -> ( am.asset )
texture_window ( ) -> ( table )
texture_window ( table values ) -> ( am.asset )
texture_window_pixel ( ) -> ( table )
texture_window_pixel ( table values ) -> ( am.asset )
num_frames ( ) -> ( integer , integer )
num_frames ( integer frame_x , integer frame_y , boolean calc_total_frames = true ) -> ( am.asset )
frame_rate ( ) -> ( number )
frame_rate ( number frame_rate ) -> ( am.asset )
width ( ) -> ( number )
height ( ) -> ( number )
repeat_xy ( ) -> ( boolean , boolean )
repeat_xy ( boolean repeat_x , boolean repeat_y ) -> ( am.asset )
scale_nine ( ) -> ( table )
scale_nine ( table values , boolean calc_state = false ) -> ( am.asset )
scale_nine ( table values , string state ) -> ( am.asset )
scale_nine_state ( ) -> ( string )
scale_nine_state ( string state ) -> ( am.asset )
texture_window_animation ( ) -> ( boolean )
texture_window_animation ( boolean texture_window_animation ) -> ( am.asset )
static new ( string asset_name )
Creates a new asset using the given asset name.
Parameters:
string asset_name : Name of the asset.
__gc ( )
Releases the reference counter on the asset.
__eq ( am.asset rhs ) -> ( boolean )
Compares this asset with another asset object.
Parameters:
am.asset rhs : The other sprite to compare with.
Returns:
boolean : True if they are the same object.
name ( ) -> ( string )
Returns the name of this asset that was defined when the asset was created.
Returns:
string : The name of this asset.
texture ( integer index = 0 ) -> ( am.texture )
Returns the texture at the given index. Defaults to getting the first texture.
Parameters:
integer index = 0 : The index of the texture to get.
Returns:
am.texture : The found texture or nil if there is no texture at that index.
texture ( am.texture texture , integer index = 0 ) -> ( am.asset , am.code )
Sets the texture at the given index. Defaults to setting the first texture.
Parameters:
am.texture texture : The texture to set.
integer index = 0 : The index to set the texture at.
Returns:
am.asset : This
am.code : Success.
texture ( string filename , integer index = 0 ) -> ( am.asset , am.code )
Sets the texture by filename at the given index. Defaults to setting the first texture.
Parameters:
string filename : The path to the texture.
integer index = 0 : The index to set the texture at.
Returns:
am.asset : This
am.code : Return code for loading the texture.
success The texture loaded the new file successfully.
file_not_found Texture didn't load because the file could not be found.
texture_load_failed Texture didn't load because there was an issue with the file.
add_texture ( am.texture texture ) -> ( am.asset , am.code )
Adds a texture to the list of texture on this asset.
Parameters:
am.texture texture : The texture to add.
Returns:
am.asset : This
am.code : Success
add_texture ( string filename ) -> ( am.asset , am.code )
Attempts to add a texture to the list of textures on this asset by texture name.
Parameters:
string filename : The path to load the texture from.
Returns:
am.asset : This
am.code : Return code for loading the texture.
success The texture loaded the new file successfully.
file_not_found Texture didn't load because the file could not be found.
texture_load_failed Texture didn't load because there was an issue with the file.
remove_texture ( string filename ) -> ( am.asset )
Removes the texture based off the filename used to load that texture.
Parameters:
string filename : The filename the texture was loaded from.
Returns:
am.asset : This
remove_texture ( am.texture texture ) -> ( am.asset )
Removes the given texture from the asset list.
Parameters:
am.texture texture : The texture to remove.
Returns:
am.asset : This
has_texture ( string filename ) -> ( boolean )
Check if the asset contains the texture based off the filename used to load that texture.
Parameters:
string filename : The filename the texture was loaded from.
Returns:
boolean : True if there was a texture found that used the given filename.
has_texture ( am.texture texture ) -> ( boolean )
Checks if the asset contains the given texture.
Parameters:
am.texture texture : The texture to check for.
Returns:
boolean : True if the texture was found.
remove_all_textures ( ) -> ( am.asset )
Removes all the textures from the asset.
Returns:
am.asset : This
total_textures ( ) -> ( integer )
Returns the number of textures associated with this asset.
Returns:
integer : The number of textures.
total_texture_windows ( ) -> ( integer )
Returns the number of texture windows this asset can use.
Returns:
integer : The number of texture windows.
total_texture_windows ( integer total_texture_windows ) -> ( am.asset )
Sets the number of texture windows this asset will use. This is related to the number of frames set (see num_frames). For example is the number of frames is set to 4, 4, then the maximum number of frames the texture can be split up into is 16 and by default the total number of texture windows is set to 16, however if the graphic is only made up of 14 frames but still in a 4x4 grid then you will need to set this to 14.
Parameters:
integer total_texture_windows : The total number of texture windows to use.
Returns:
am.asset : This.
texture_window ( ) -> ( table )
Returns a table with values that correspond with the UV coordinates that defines the subwindow within the texture. This subwindow allows a section of a texture to be used instead of the whole texture. The table contains the following values: "left_x", "right_x", "top_y" and "bottom_y"
Returns:
table : Table containing the UV coordinates.
texture_window ( table values ) -> ( am.asset )
Sets the texture window rectangle for this asset from a table. Each value should be treated like a UV coordinate. The table is expected to have the values for "left_x", "right_x", "top_y" and "bottom_y". If these values are not defined, left_x and top_y default to 0 and right_x and bottom_y will default to 1.
Parameters:
table values : Table of values to set the UV coordinates to.
Returns:
am.asset : This
texture_window_pixel ( ) -> ( table )
Returns a table of values that correspond with the pixel coordinates that define the subwindow within the texture. This subwindow allows a section of a texture to be used instead of the whole texture. This function will fail if a texture has not been set onto the asset. We may lift this restriction in future if it is required. The table contains the following values: "left_x", "right_x", "top_y" and "bottom_y"
Returns:
table : x The x position of the rectangle
texture_window_pixel ( table values ) -> ( am.asset )
Sets the texture window rectangle for this asset from a table. Each value should be treated like a pixel coordinate. This function will fail if a texture has not been set onto the asset. We may lift this restriction in future if it is required. The table is expected to have the values for "left_x", "right_x", "top_y" and "bottom_y". If these values are not defined, left_x and top_y default to 0 and right_x and bottom_y will default to the texture width.
Parameters:
table values : A table of values defining the texture window in pixel coordinates.
Returns:
am.asset : This
num_frames ( ) -> ( integer , integer )
Returns the number of frames the asset has in the x and y directions. These frames are in relation to the assets texture window.
Returns:
integer : The number of x frames.
integer : The number of y frames.
num_frames ( integer frame_x , integer frame_y , boolean calc_total_frames = true ) -> ( am.asset )
Sets the number of frames the asset has in the x and y directions. These frames are in relation to the assets texture window.
Parameters:
integer frame_x : The number of x frames.
integer frame_y : The number of y frames.
boolean calc_total_frames = true : When true the total texture windows will be calculated as frame_x * frame_y.
Returns:
am.asset : This
frame_rate ( ) -> ( number )
Returns the frame rate of the asset graphic. The defines how quickly the animation progresses. If the framerate is set to zero (or below) it is assumed that this asset has no animation. The frame rate is defined in frames per second. See subwindow_animation for types of animation.
Returns:
number : The frame rate.
frame_rate ( number frame_rate ) -> ( am.asset )
Sets the frame rate of the asset. The frame rate is defined as how many frames per second. See subwindow_animation for types of animation.
Parameters:
number frame_rate : The frame rate.
Returns:
am.asset : This
width ( ) -> ( number )
Returns the width of the asset in pixels. This takes into account the subwindow size and the number of frames.
Returns:
number : The width of the asset graphic.
height ( ) -> ( number )
Returns the height of the asset in pixels. This takes into account the subwindow size and the number of frames.
Returns:
number : The height of the asset graphic.
repeat_xy ( ) -> ( boolean , boolean )
Returns the flags for how the asset textures are repeated in the x and y directions.
Returns:
boolean : If the texture will repeat along the x direction.
boolean : If the texture will repeat along the y direction.
repeat_xy ( boolean repeat_x , boolean repeat_y ) -> ( am.asset )
Sets the flags for how the texture repreats.
Parameters:
boolean repeat_x : If the texture will repeat along the x direction.
boolean repeat_y : If the texture will repeat along the y direction.
Returns:
am.asset : This
scale_nine ( ) -> ( table )
Returns a table with values that define the inner borders of a scale nine system. Scale nine allows for an asset to be stretched only whilst keep the outer edge unstretched. The table contains the following values: "left_x", "right_x", "top_y" and "bottom_y"
Returns:
table : A table that defines the inner borders of a scale nine system in pixels.
scale_nine ( table values , boolean calc_state = false ) -> ( am.asset )
Sets the inner borders of a scale nine system. Scale nine allows for an asset to be stretched only whilst keep the outer edge unstretched. The table is expected to have the values for "left_x", "right_x", "top_y" and "bottom_y". If these values are not defined, the values are left unset. These values are used in connection with the scale nine state, which defines if the scale nine system is to be turned off or used in horizontal, verticle or both modes. When automatically calculated the state it determined by which values are defined, if only left_x and right_x are set then it's determined to be horizontal, same with top_y and bottom_y. If all are set then it's set to both. And if none are set then scale nine is turned off.
Parameters:
table values : A table of values defining the scale nine inner borders in pixels.
boolean calc_state = false : When true the scale nine state will be automatically calculated from the values given.
Returns:
am.asset : This
scale_nine ( table values , string state ) -> ( am.asset )
Sets the inner borders of a scale nine system. Scale nine allows for an asset to be stretched only whilst keep the outer edge unstretched. The table is expected to have the values for "left_x", "right_x", "top_y" and "bottom_y". If these values are not defined, the values are left unset. These values are used in connection with the scale nine state, which defines if the scale nine system is to be turned off or used in horizontal, verticle or both modes. The valid values for setting the scale nine state are "none", "verticle", "horizontal" and "both".
Parameters:
table values : A table of values defining the scale nine inner borders in pixels.
string state : The scale nine state to set.
Returns:
am.asset : This
scale_nine_state ( ) -> ( string )
Returns the scale nine state. This state is used to determine how the scale nine inner borders are used. Can return the following values: "none", "horizontal", "verticle" or "both"
Returns:
string : The scale nine state.
scale_nine_state ( string state ) -> ( am.asset )
Sets the scale nine state by name. This state is used to determine how the scale nine inner borders are used.
none Scale nine is turned off.
horizontal Only the left_x and right_x values are used and the asset is stretched horizontally.
vertical Only the top_y and bottom_y values are used and the asset is stretched vertically.
both All 4 values are used and the asset can be stretched both horizontally and vertically.
Parameters:
string state : The state to set the scale nine system to.
Returns:
am.asset : This.
texture_window_animation ( ) -> ( boolean )
Returns if the animation for this asset is based on texture windows.
Returns:
boolean : True if this asset animates along the texture windows.
texture_window_animation ( boolean texture_window_animation ) -> ( am.asset )
Sets how the asset deals with animation. For assets that have a frame rate of zero this value is ignored. When true, the current frame defines which texture window is used to display. So for an asset with num_frames set to 4, 4, it will have a total of 16 sub texture windows to animate over. When false the current frame defines which texture out of the list of all textures added to this asset to use when animating.
Parameters:
boolean texture_window_animation : The type of animation for this asset.
Returns:
am.asset : This.