I’m trying to create an atlas at runtime, here’s my code:
local file = assert(io.open("main/sketch.png", "rb"))
local data = assert(file:read("*a"))
local image = image.load(data)
print("Type: " .. image.type)
print(image.width, image.height)
local tex_params = {
width = image.width,
height = image.height,
type = resource.TEXTURE_TYPE_2D,
format = resource.TEXTURE_FORMAT_RGB
}
local texture_resource = resource.create_texture("/sketch.texturec", tex_params, image.buffer)
local atlas_params = {
texture = texture_resource,
animations = {
{
id = "anim",
width = image.width,
height = image.height,
frame_start = 1,
frame_end = 2
}
},
geometries = {
vertices = {
0, 0,
0, image.height,
image.width, image.height,
image.width, 0
},
uvs = {
0, 0,
0, image.height,
image.width, image.height,
image.width, 0
},
indices = {0, 1, 2, 0, 2, 3}
}
}
local atlas_resource = resource.create_atlas("/sketch_atlas.texturesetc", atlas_params)
I’ve read through it several times and can’t seem to find any issue with the code. Also why does it error on argument 6 when create_atlas
only has 2 arguments?
Here’s the error:
ERROR:SCRIPT: main/main.script:43: bad argument #6 to 'create_atlas' (number expected, got string)
stack traceback:
[C]:-1: in function create_atlas
main/main.script:43: in function <main/main.script:1>
The image type that gets printed is “rgb”. The texture itself seems to be created properly, just not the atlas.