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

Author Topic: Box2DX  (Read 2136 times)

0 Members and 1 Guest are viewing this topic.

Dolfik

  • Newbie
  • *
  • Posts: 5
    • View Profile
Box2DX
« on: November 14, 2013, 10:35:37 am »
Hi all. How to synchronize coordinates Box2DX and SFML? And how do i can know how many pixels equals one meter?
P.S. I load tile map and objects from tmx, and i need to create the body of the object coordinates
« Last Edit: November 14, 2013, 10:44:44 am by Dolfik »

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Box2DX
« Reply #1 on: November 14, 2013, 11:04:35 am »
For the pixels, you look at the sprite textures you made, measure the height of a human sprite in pixels, depending on the type of person depicted you divide it by a number between 0.3 and 2.4, and then you know how many pixels is a meter. :P
I did not use Box2D, but you should be able to convert the vectors easily by assigning the components from a SFML Vector2 to a Box2D vector and maybe applying a scale factor and do same the other way around, too.
« Last Edit: November 14, 2013, 11:09:51 am by wintertime »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Box2DX
« Reply #2 on: November 14, 2013, 11:35:21 am »
You just need to sync the position of the body and the sprite.

Also don't map pixels to meters, but a range of pixels to a meter. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything