Jump to content

  • Log In with Google      Sign In   
  • Create Account

Box2d object x y location


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 GameGeezer   Members   -  Reputation: 788

Like
0Likes
Like

Posted 15 June 2011 - 07:57 PM

In box2d what is the relationship of body.getPosition().x and y and the body? Are the values corresponding to the center of the body, the top right, or some other location?

Sponsor:

#2 bluwind   Members   -  Reputation: 181

Like
0Likes
Like

Posted 17 June 2011 - 12:12 AM

Misread question - incorrect answer given :D

Rob

#3 scgames   Members   -  Reputation: 1981

Like
0Likes
Like

Posted 17 June 2011 - 11:18 AM

That would be the top left buddy

I don't believe that's correct - what leads you to believe the position of a body corresponds to the top left?

Generally, there will be two things associated with a body: a shape (or shapes), and a visual representation. It's common for these to match (roughly, at least), but they don't have to.

Regarding the shape, IIRC, there are a few options available, such as circles and convex polygons. Generally, the position will correspond to the center of the shape (more or less), although you could probably create an 'off-center' polygon where the position corresponded to some other point.

Regarding the visual, you can position the visual wherever you want with respect to the position of the body. Typically though, the positioning of the visual will roughly match that of the shape or shapes associated with the body.

#4 SriLumpa   Members   -  Reputation: 198

Like
1Likes
Like

Posted 17 June 2011 - 12:26 PM

The position is just "where the body is", the body's "origin". It is not a particular center, physically nor geometrically.
When you add shapes to your body, you place them relative to the body's "origin". You can place all shapes on the right if you want, the origin does not have to be at the center or whatever.

This said, the methods for creating a circle or a box shape will have those shapes centered on the body's origin by default.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS