• Functions and constants to access resources.

Static methods

staticatlas(path:String):AtlasResourceReference

  • Constructor-like function with two purposes:

  • Load the specified resource as part of loading the script

  • Return a hash to the run-time version of the resource

    * *Note:** This function can only be called within `@property()`.
    

@:native("create_atlas")staticcreateAtlas(path:String, table:ResourceAtlasInfo):Hash

  • This function creates a new atlas resource that can be used in the same way as any atlas created during build time. The path used for creating the atlas must be unique, trying to create a resource at a path that is already registered will trigger an error. If the intention is to instead modify an existing atlas, use the resource.set_atlas function. Also note that the path to the new atlas resource must have a '.texturesetc' extension, meaning "/path/my_atlas" is not a valid path but "/path/my_atlas.texturesetc" is. When creating the atlas, at least one geometry and one animation is required, and an error will be raised if these requirements are not met. A reference to the resource will be held by the collection that created the resource and will automatically be released when that collection is destroyed. Note that releasing a resource essentially means decreasing the reference count of that resource, and not necessarily that it will be deleted.

Parameters:

path

The path to the resource

table

A table containing info about how to create the texture

Returns:

Returns the atlas resource path

@:native("create_buffer")staticcreateBuffer(path:HashOrString, options:ResourceCreateBufferOptions):Buffer

  • This function creates a new buffer resource that can be used in the same way as any buffer created during build time. The function requires a valid buffer created from either buffer.create or another pre-existing buffer resource. By default, the new resource will take ownership of the buffer lua reference, meaning the buffer will not automatically be removed when the lua reference to the buffer is garbage collected. This behaviour can be overruled by specifying transfer_ownership = false in the argument table. If the new buffer resource is created from a buffer object that is created by another resource, the buffer object will be copied and the new resource will effectively own a copy of the buffer instead. Note that the path to the new resource must have the .bufferc extension, /path/my_buffer is not a valid path but /path/my_buffer.bufferc is. The path must also be unique, attempting to create a buffer with the same name as an existing resource will raise an error.

Parameters:

path

The path to the resource

options

A table containing info about how to create the buffer

Returns:

The resource buffer

@:native("create_sound_data")staticcreateSoundData(path:String, options:ResourceCreateSoundDataOptions):Hash

  • Creates a sound data resource.

Supported formats are .oggc, .opusc and .wavc.

Parameters:

path

the path to the resource. Must not already exist.

options

parameters for the sound data. See ResourceCreateSoundDataOptions

Returns:

the resulting path hash to the resource

@:native("create_texture")staticcreateTexture(path:String, table:ResourceCreateTextureInfo):TextureResourceHandle

  • This function creates a new texture resource that can be used in the same way as any texture created during build time. The path to the new texture resource must have a '.texturec' extension, meaning "/path/my_texture" is not a valid path but "/path/my_texture.texturec" is. The path must also be unique, attempting to create a texture with the same name as an existing resource will raise an error. A reference to the resource will be held by the collection that created the resource and will automatically be released when that collection is destroyed. Note that releasing a resource essentially means decreasing the reference count of that resource, and not necessarily that it will be deleted.

Parameters:

path

The path to the resource

table

A table containing info about how to create the texture

Returns:

A texture resource handle

@:has_untypedstaticinlinecreateTextureAsync(path:String, table:ResourceCreateTextureInfo, ?callback:(CreateTextureRequestId, TextureResourceHandle) ‑> Void):CreateTextureAsyncResult

  • This function creates a new texture resource that can be used in the same way as any texture created during build time. The path to the new texture resource must have a '.texturec' extension, meaning "/path/my_texture" is not a valid path but "/path/my_texture.texturec" is. The path must also be unique, attempting to create a texture with the same name as an existing resource will raise an error. A reference to the resource will be held by the collection that created the resource and will automatically be released when that collection is destroyed. Note that releasing a resource essentially means decreasing the reference count of that resource, and not necessarily that it will be deleted.

Parameters:

path

The path to the resource

table

A table containing info about how to create the texture

callback

Optional callback to be executed when the texture has been created

Returns:

A tuple containing the hash to the resource and the request ID

staticfont(path:String):FontResourceReference

  • Constructor-like function with two purposes:

  • Load the specified resource as part of loading the script

  • Return a hash to the run-time version of the resource

    * *Note:** This function can only be called within `@property()`.
    

@:native("get_atlas")staticgetAtlas(path:HashOrString):ResourceAtlasInfo

  • Get runtime atlas info for a given atlas resource path.

Returns the atlas layout including geometries with rotation flags.

@:native("get_buffer")staticgetBuffer(path:HashOrString):Buffer

  • Gets the buffer from a resource

Parameters:

path

The path to the resource

Returns:

The resource buffer

@:native("get_render_target_info")staticgetRenderTargetInfo(path:EitherType<HashOrString, Int>):ResourceRenderTargetInfo

  • Gets render target info from a render target resource path or a render target handle.

Parameters:

path

the path to the resource or a render target handle

Returns:

info about the render target and its attachments

@:native("get_text_metrics")staticgetTextMetrics(url:Hash, text:String, ?options:Null<ResourceGetTextMetricsOptions>):ResourceTextMetrics

  • Gets the text metrics from a font.

Parameters:

url

The font to get the (unscaled) metrics from

text

Text to measure

options

(optional) A table containing parameters for the text.

@:native("get_texture_info")staticgetTextureInfo(path:EitherType<HashOrString, TextureResourceHandle>):ResourceTextureInfo

  • Gets texture info from a texture resource path or a texture handle.

Parameters:

path

the path to the resource or a texture handle

Returns:

info about the texture

staticload(path:String):Buffer

  • Loads the resource data for a specific resource.

Parameters:

path

The path to the resource

Returns:

the buffer stored on disc

staticmaterial(?path:String):MaterialResourceReference

  • Constructor-like function with two purposes:

  • Load the specified resource as part of loading the script

  • Return a hash to the run-time version of the resource

    * *Note:** This function can only be called within `@property()`.
    

@:native("render_target")staticrenderTarget(path:String):RenderTargetResourceReference

  • Constructor-like function that loads the specified render target resource and returns a hash to its run-time version. Note: This function can only be called within @property().

staticset(path:HashOrString, buffer:Buffer):Void

  • Sets the resource data for a specific resource

Parameters:

path

The path to the resource

The

buffer of precreated data, suitable for the intended resource type

@:native("set_atlas")staticsetAtlas(path:HashOrString, table:ResourceAtlasInfo):Void

  • Sets the atlas resource with the provided atlas data. This can be used to dynamically update an existing atlas resource with new data.

Parameters:

path

The path to the resource

table

A table containing info about the atlas

@:native("set_buffer")staticsetBuffer(path:HashOrString, buffer:Buffer, table:ResourceSetBufferOptions):Void

  • Sets the buffer of a resource.

By default, setting the resource buffer will either copy the data from the incoming buffer object to the buffer stored in the destination resource, or make a new buffer object if the sizes between the source buffer and the destination buffer stored in the resource differs. In some cases, e.g performance reasons, it might be beneficial to just set the buffer object on the resource without copying or cloning.

To achieve this, set the transfer_ownership flag to true in the argument table. Transferring ownership from a lua buffer to a resource with this function works exactly the same as resource.create_buffer: the destination resource will take ownership of the buffer held by the lua reference, i.e the buffer will not automatically be removed when the lua reference to the buffer is garbage collected. Note: When setting a buffer with transfer_ownership = true, the currently bound buffer in the resource will be destroyed.

Parameters:

path

The path to the resource

buffer

The resource buffer

table

options about how to set the buffer

@:native("set_sound")staticsetSound(path:HashOrString, buffer:String):Void

  • Update internal sound resource (wavc/oggc/opusc) with new data.

Parameters:

path

The path to the resource

buffer

A lua string containing the binary sound data

@:native("set_texture")staticsetTexture(path:HashOrString, table:ResourceSetTextureInfo, buffer:Buffer):Void

  • Sets the pixel data for a specific texture.

Parameters:

path

The path to the resource

table

A table containing info about the texture

buffer

The buffer of precreated pixel data NOTE Currently, only 1 mipmap is generated.

statictexture(path:String):TextureResourceReference

  • Constructor-like function with two purposes:

  • Load the specified resource as part of loading the script

  • Return a hash to the run-time version of the resource

    * *Note:** This function can only be called within `@property()`.
    

@:native("tile_source")statictileSource(path:String):TileSourceResourceReference

  • Constructor-like function with two purposes:

  • Load the specified resource as part of loading the script

  • Return a hash to the run-time version of the resource

    * *Note:** This function can only be called within `@property()`.