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

Author Topic: Displaying a Sprite on a View  (Read 2389 times)

0 Members and 1 Guest are viewing this topic.

Williamson

  • Newbie
  • *
  • Posts: 16
    • View Profile
Displaying a Sprite on a View
« 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

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Displaying a Sprite on a View
« Reply #1 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?

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Displaying a Sprite on a View
« Reply #2 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

bullno1

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Displaying a Sprite on a View
« Reply #3 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.

Williamson

  • Newbie
  • *
  • Posts: 16
    • View Profile
Displaying a Sprite on a View
« Reply #4 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!

 

anything