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

Author Topic: Get Sprite Screen position  (Read 3036 times)

0 Members and 1 Guest are viewing this topic.

DarkGlitch

  • Newbie
  • *
  • Posts: 11
    • View Profile
Get Sprite Screen position
« on: December 06, 2012, 10:59:17 am »
Like the title says. A way to easily retrieve an object/sprite's screen location. This would be invaluable for stuff like making a quadtree. If this already exists, my Google-fu needs work. I have found a way to do it if I'm understanding this topic correctly (http://en.sfml-dev.org/forums/index.php?topic=5846.msg39044#msg39044), however a new function would be very nice. Other than that, SFML is amazing from what I've seen so far. Thanks for reading.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Get Sprite Screen position
« Reply #1 on: December 06, 2012, 11:02:52 am »
See the new function RenderTarget::mapCoordsToPixel that was implemented recently.

But how does this help with a quadtree? You should be able to do all your calculations in world coordinates.
Laurent Gomila - SFML developer

DarkGlitch

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Get Sprite Screen position
« Reply #2 on: December 06, 2012, 10:50:26 pm »
I was told (somewhere else) that I would need to use a quadtree to handle collision detection, or at least control how often I use the detection function for objects that are currently on the screen in a 2D game. I would need to know where stuff is on the screen, not the world for that, at least that's how I understood it.

I guess I will have to use 2.0 now. No more procrastination for me XD.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Get Sprite Screen position
« Reply #3 on: December 06, 2012, 11:07:37 pm »
Checking what's visible on screen doesn't mean that you have to do it in screen coordinates. What's visible on screen is an area of the 2D world, and a very precise one: the rectangle defined by the current view.
Laurent Gomila - SFML developer

cire

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Re: Get Sprite Screen position
« Reply #4 on: December 06, 2012, 11:09:55 pm »
If you tell the graphics system to draw something somewhere, do you then need to ask the graphics system where you told it to draw?  Maybe it would make more sense to remember what you told it.

Do moving objects that are not drawn on the screen stop moving and lose the ability to collide with other objects?

Quadtrees are usually defined in terms of world coordinates.

DarkGlitch

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Get Sprite Screen position
« Reply #5 on: December 06, 2012, 11:13:58 pm »
I see...

I'm still learning. Thanks for the tips. I haven't started to code a quadtree yet. Still researching how it's done.

 

anything