Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Displaying an image over the other image using SFML library in CPP  (Read 3333 times)

0 Members and 1 Guest are viewing this topic.

jyothi

  • Newbie
  • *
  • Posts: 2
    • View Profile
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.


Satus

  • Guest
Re: Displaying an image over the other image using SFML library in CPP
« Reply #1 on: March 18, 2016, 01:15:33 pm »
Does second image have transparent background?

jyothi

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Displaying an image over the other image using SFML library in CPP
« Reply #2 on: March 18, 2016, 02:10:54 pm »
first image size is (1024, 768) and second image is (33, 35)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Displaying an image over the other image using SFML library in CPP
« Reply #3 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
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Displaying an image over the other image using SFML library in CPP
« Reply #4 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?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

 

anything