Im creating info-panel (kiosk) app for client. How to handle large 1920x1080 background images in Defold? There is alot of them, over 100 images and placing them all into Atlas crashes engine.
What is preferred way to include and handle all those large images in Defold?
If you are using gui nodes then perhaps use image.load() and gui.new_texture(). Example: Load texture
Instead of loading from html5 you can include all of the images in the game archive or as individual files next to the game archive: Working with files
Use an atlas with a single 1920x1080 image and then load the background image you need and replace it in the atlas.
I decided to go with image.load() and gui.new_texture() method and it works with my other code:
local function set_background_image(texture_id, image_filename)
background_node = gui.get_node("info_screen_background")
-- check if image file exists
local file_exists = lfs.attributes(image_filename, "mode") == "file"
if not file_exists then
gui.set_texture(background_node, "background")
print("Background image file does not exist.")
else
local file = io.open(image_filename, "rb")
local bytes = file:read("*a")
local background_image = image.load(bytes)
math.randomseed(os.time())
_texture_id = texture_id .. "_" .. math.random()
if gui.new_texture(_texture_id, background_image.width, background_image.height, background_image.type, background_image.buffer) then
gui.set_texture(background_node, _texture_id)
print("Set new texture")
else
gui.delete_texture(_texture_id)
gui.set_texture(background_node, "background")
print("Unable to create texture")
end
end
end
However, Im interested about memory management. When image is loaded, does it stay in memory and should I delete it with gui.delete_texture after being replaced with other image?