Hello im trying to set a sprite to a runtime created atlas, which is created from an image downloaded from the web at runtime, and this works. However when i try to set a sprite that has 2 custom samplers in the material it gives this error
the property 'ART' of 'art#sprite' must be a number
This is my sprite
And material
And code
local buffer = image.load_buffer(http_res.response, { flip_vertically: true })
local atlasHash = createAtlasFromBuffer(buffer)
go.set("art#sprite", "ART", atlasHash) -- errors here
Note that this code works fine but the stencil image sampler is scaled wrong
local buffer = image.load_buffer(http_res.response, { flip_vertically: true })
local atlasHash = createAtlasFromBuffer(buffer)
go.set("art#sprite", "image", atlasHash) -- no error
Atlas creation function (in typescript)
export function createAtlasFromBuffer(id: string, img: ImageRes) {
const width = img.width;
const height = img.height;
const tex = {
width,
height,
type: graphics.TEXTURE_TYPE_2D,
format: graphics.TEXTURE_FORMAT_RGBA,
// x: -img.width / 2,
// y: -img.height / 2,
};
const texture = resource.create_texture(`#${id}.texturec`, tex, img.buffer);
const atlasParams = {
texture: texture,
animations: [
{
id: "item",
width: width,
height: height,
frame_start: 1,
frame_end: 2,
},
],
geometries: [
{
width: width,
height: height,
pivot_x: 0.5,
pivot_y: 0.5,
vertices: [0, height, 0, 0, width, 0, width, height],
uvs: [0, height, 0, 0, width, 0, width, height],
indices: [0, 1, 2, 0, 2, 3],
},
],
};
const atlas = resource.create_atlas(`#${id}.texturesetc`, atlasParams);
return atlas;
}