1
\$\begingroup\$

I have a image with transparent background created from photoshop.

enter image description here

I added this to my android game which I am creating using libgdx. But when I add it to that, it is shown with white background like following.

enter image description here

Whats the reason for this? How can I fix this?

\$\endgroup\$

closed as off-topic by DMGregory Dec 19 '18 at 23:29

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about debugging a problem must provide a minimal, complete, verifiable example of the issue so that readers can diagnose it without needing to guess, read all of your code, or engage in extensive back-and-forth dialog. For more information, see this meta thread." – DMGregory
If this question can be reworded to fit the rules in the help center, please edit the question.

0
\$\begingroup\$

You'll want to stick a

batch.enableBlending()

for the sprite inside of the batch.begin() and batch.end(). The reason this works is because what blending does is merge the translucent pixels with the previously drawn ones.

Because blending can incur a performance cost from all the merging magic as opposed to whopping on a straight texture, it's beneficial to simply disable blending unless you're using it yourself.

e.g

batch.begin();
batch.disableBlending();
// draw all the other stuff FIRST to save on performance
batch.enableBlending();
myCoolSprite.draw(Batch);
batch.end();

For more information about this area you can check out This handy old wiki page.

\$\endgroup\$
  • \$\begingroup\$ I still see the same outcome. \$\endgroup\$ – Chamila Wijayarathna Aug 25 '16 at 12:09
  • \$\begingroup\$ Try batch.enableBlending() on its own outside the batch.begin() and batch.end(). \$\endgroup\$ – Huxellberger Aug 25 '16 at 18:36
  • \$\begingroup\$ still it doesn't work \$\endgroup\$ – Chamila Wijayarathna Aug 29 '16 at 12:41
  • 1
    \$\begingroup\$ I think it would be a good idea to add some code to the question then. \$\endgroup\$ – user100681 Feb 2 '18 at 6:26

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