Mesh textures

I got a query. Is it possible to texturize a mesh object with an image object? I tried but failed to do. If its possible can some one give an example code to show how to do it?

@rashedlatif you can set the mesh.texture property to either a string (sprite name) or an image object. For example:

myImage = image(400,400)
-- Fill myImage with something

m = mesh()
m.texture = myImage

Thanks Simeon. That’s exactly how I tried but nothing happened. Now realized where I made mistake. Thanks :slight_smile:

furthermore, @Simeon, is it possible to make this texture more or less transparent?

@Rodolphe i suggest you read the mesh built in documentation. It explains it all. Or ignatz tuto on meshes. But the answer to your question is setColor() function: it will set the transparency of each vertex to what you want.

oh excellent… thanks! I should have read the documentation at least, indeed (I did try setColor() but it didn’t work, it should be something bad in my code then) :slight_smile:

you must setColor for each vector of the mesh (or rect if you use them). Post your code if you cant find your error.

@Jmv38 Or you can use setColors(color) to color ALL the vertices!

good point!

That’s what I did, and it does work now! :slight_smile: