I’d like to dynamically create a mini-map for my game. Is there any way to create a sprite on-the-fly so to speak? I only want something simple as in setting the pixels for the walls and solid scenery and transparent for everything else.
You can’t do that with sprites, but GUI nodes can be used. See http://www.defold.com/ref/gui/#gui.set_texture_data:texture-width-height-type-buffer
3 Likes
That looks like just what I need - thanks!
2 Likes
You could also have a look at this thread:
6 Likes
Yup! Just be careful when you make the texture string- since you have to append strings for each bit of pixel data a ton of times, the complexity of making the texture can grow quickly. If you’re making a higher resolution texture, I’d recommend using some sort of string builder to keep the game’s performance smooth.
1 Like
String concatenation (using …) can become quite expensive. For a large amount of strings it might be better to do table.concat(strings, "")
instead. And perhaps also do it over several frames.
3 Likes