1
\$\begingroup\$

I have a small .PNG file. I load it with:

  picSmiley = love.graphics.newImage("salamander.png");

and I draw it with:

love.graphics.draw(picSmiley, objects.ball.body:getX(), 
        objects.ball.body:getY(), math.rad(rotation), 1, 1, 40 / 2, 22 / 2);

Nothing else should influence it. The background color should not matter, as the image has an alpha channel. Despite being red, however, my image draws with a murky green color.

The Sprite.

Only the color is wrong. How do I fix it?

Wrong (the salamander is on the grey block):

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ could you provide an image showing your original .png, and a version of how it renders? \$\endgroup\$
    – Gnemlock
    Dec 11 '16 at 22:28
  • \$\begingroup\$ I have added a screenshot of the problem \$\endgroup\$
    – ZirconCode
    Dec 11 '16 at 22:47
  • \$\begingroup\$ All pngs I draw seem to be experiencing this problem. They become darker and sometimes greener... \$\endgroup\$
    – ZirconCode
    Dec 12 '16 at 0:12
1
\$\begingroup\$

Set the color to white before calling the draw method:

love.graphics.setColor(255,255,255,255);
love.graphics.draw(picSmiley, objects.ball.body:getX(), 
    objects.ball.body:getY(), math.rad(rotation), 1, 1, 40 / 2, 22 / 2);
\$\endgroup\$
1
\$\begingroup\$

More specifically, the drawing color set by love.graphics.setColor acts as a kind of mask, and stays until it is overridden by another call to love.graphics.setColor.

So you may have to save the old color, set it to white, draw your salamander, then restore it so the rest of your graphics is drawn properly.

But as the post if months old, I believe you already know that ^-^

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.