I have an image, where I have a round soft white feathered ball in the center of it. I plan to use it for my lighting in my 2D game.
I could not find any proper way to drawing lighting with many colors, look at my question here Slick2D/LWJGL Drawing coloured lights problem
However, I did find a way to change the colors of the light, and blend it with OpenGL to the tiled map.
I am just stuck with one problem, when I use Graphics#drawFlash(float, float, float, float, Color)
and add an alpha lower than 1.0f
, the color will be gone, and the image will go back to it's real color (white ball).
Example when I don't add alpha:
this.lightSurface.drawFlash(x, y, w, h, new Color(55, 14, 255));
And examplew when I add an alpha:
this.lightSurface.drawFlash(x, y, w, h, new Color(55, 14, 255, 0.6f));
This is my whole draw method:
public void render(GameContainer c, Graphics g) throws SlickException {
for (int i = 0; i < this.lights.size(); i++) {
Light light = this.lights.get(i);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
int w = (int) (this.getWidth() * light.getScale());
int h = (int) (this.getHeight() * light.getScale());
int x = (int) (light.getX() - w / 2f);
int y = (int) (light.getX() - h / 2f);
this.lightSurface.drawFlash(x, y, w, h, new Color(55, 14, 255, 0.6f));
this.map.render(g);
g.setDrawMode(Graphics.MODE_NORMAL);
}
g.setDrawMode(Graphics.MODE_NORMAL);
}
this.map.render(g)
is just 2 for loops and draw tiles.
Why is it doing that? is there a way to hack around it?