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

Author Topic: how does translate work?  (Read 1305 times)

0 Members and 1 Guest are viewing this topic.

stavsen

  • Newbie
  • *
  • Posts: 5
    • View Profile
how does translate work?
« on: February 08, 2018, 09:56:46 pm »
Hi
I've got a sprite which im drawing to the screen with a transform

what im consfused about it that my windows width is 600 px
and i called the transforms translate function, parsing (300, 0)
so i expected my sprite to be drawn in the middle of the screen (+the width of the sprite)
but it goes way off the screen?

And when i parse, say, (200,0) it moves almost to the end of the window ? even though its width is 600 ?

whats going on ?

doesn't translate "move" the transform by the pixels parsed in ?
i looked in the documentation, but it only says that the values parsed to translate are the offsets? but it it in pixels? or is it relative to the screen size?
« Last Edit: February 08, 2018, 10:04:01 pm by stavsen »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: how does translate work?
« Reply #1 on: February 08, 2018, 11:46:23 pm »
What do you mean with "parsed"?

So what's your code?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: how does translate work?
« Reply #2 on: February 08, 2018, 11:49:11 pm »
The values used in translation are effectively in the current view's co-ordinate system when drawing the drawable object.
So, the translated position of a drawable is based on the view, which may have a size different to the window's pixel size.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*