PixelDeBurner wrote:
Nevermind, I coded the whole thing again, trying to understand every line of code ( managed to do that ), and it finally works.
I saw that if I bind the tint of light, and use the drawEmbedded function tint works, but if I use only draw, it doesn't.
Can you please explain to me what's the difference between drawEmbedded and draw ?
"draw" is a utility method that does the following: bind a colour filter (or white if none was specified), rotate the image, and render it. drawEmbedded is used to improve performance when you are drawing multiple images that share the same texture -- i.e. tiles in a sprite sheet. Instead of sending every image to the GPU individually, you can "batch" a lot of images in the same draw call with Image.startUse() and endUse(). However, certain things like changing the draw mode and rotating the graphics context won't work within startUse/endUse.
Here's an example of how you might use it:
Code:
img = spriteSheet.getSubImage(0, 0, 32, 32);
img2 = spriteSheet.getSubImage(32, 32, 32, 32);
...
spriteSheet.startUse();
//binds the colour white for all proceeding sprites
Color.white.bind();
img.drawEmbedded(x, y, w, h);
//tint the following sprites blue
Color.blue.bind();
//using Image.setRotation/setAlpha/etc won't work with startUse/endUse
//we have to specify it like this
img.drawEmbedded(x, y, w, h, rotation);
spriteSheet.endUse();
Usually you are fine to use Image.draw over drawEmbedded, but if you want more performance out of your game, you should try using more sprite sheets and more batching.

drawEmbedded isn't as well documented since most people don't need that much performance in a simple 2D game.
pekhe - will check it out..