SFML community forums

General => General discussions => Topic started by: jyothi on March 18, 2016, 01:01:00 pm

Title: Displaying an image over the other image using SFML library in CPP
Post by: jyothi on March 18, 2016, 01:01:00 pm
Hi,
I am working on game using SFML library.
I am trying to display image(new) on the another image(previous) by mouse click. Whenever I click on the particular position where I want to display, the new image is display on the blank background clearing previous image. new image is not overlapping on previous image.
Please help me out in this issue.

Thanks in advance.

Title: Re: Displaying an image over the other image using SFML library in CPP
Post by: Satus on March 18, 2016, 01:15:33 pm
Does second image have transparent background?
Title: Re: Displaying an image over the other image using SFML library in CPP
Post by: jyothi on March 18, 2016, 02:10:54 pm
first image size is (1024, 768) and second image is (33, 35)
Title: Re: Displaying an image over the other image using SFML library in CPP
Post by: Nexus on March 18, 2016, 02:30:12 pm
How does that answer Satus' question? ???

Use PNG images (with an alpha channel), and make sure the images are actually transparent. Draw them with the default blend mode (sf::BlendAlpha).

And please read this carefully: http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368
Title: Re: Displaying an image over the other image using SFML library in CPP
Post by: Hapax on March 18, 2016, 05:20:25 pm
I am trying to display image(new) on the another image(previous)
[...]
new image is not overlapping on previous image.
I don't think your question is clear. Is new in a completely different area from previous?
If one is "clearing" (not being drawn) without being overlapped, you must be stopping drawing it.

Is it possible that you don't have
window.clear();
window.draw(previousImage);
window.display();
every frame?