SFML community forums

Help => Graphics => Topic started by: Williamson on November 30, 2008, 01:00:42 pm

Title: Displaying a Sprite on a View
Post by: Williamson on November 30, 2008, 01:00:42 pm
Hello!
My name is Williamson, and I am currently making an MMO using SFML.
However, I have encountered a difficulty, which is that I dont know how to display a Sprite on a View, or at least in a way which makes it appear to be on the View. (like the interface in Age of Empires, which contains buttons and stuff like that)
Is this possible?
Thank you for any answers!
Williamson
Title: Displaying a Sprite on a View
Post by: Imbue on November 30, 2008, 11:38:55 pm
Just draw the sprite last so it's drawn on top.

Or are you looking for something else?
Title: Displaying a Sprite on a View
Post by: Wizzard on December 01, 2008, 04:44:08 am
I don't really understand what you mean, but I will take a wild guess and say you're trying to draw immobile objects on top of a moving view/world.

Here is an example of how to draw relative to the GUI (assuming you have not edited App's default View):
Code: [Select]
       App.SetView(View);                 // Draw relative to the world
        App.Draw(Map);                     // Draw the map
        App.SetView(App.GetDefaultView()); // Draw relative to the GUI
        App.Draw(Interface);               // Draw the GUI
Title: Displaying a Sprite on a View
Post by: bullno1 on December 01, 2008, 05:19:35 am
I know what he means. He wants to draw sprites as GUI so that no matter how the view moves, the sprite's position on the screen doesn't change.

I think Wizzard's code does it.
Title: Displaying a Sprite on a View
Post by: Williamson on December 01, 2008, 07:32:51 pm
Thanks!
Ill give it a try as soon as possible
Williamson

[EDIT:] Thanks Wizzard! It does exactly what I wanted now!