0
\$\begingroup\$

In the game I'm trying to code I got to have two bodies. One StaticBody and one DynamicBody. I want to have the DynamicBody on top of the StaticBody. Somehow all I get is this:

Bug

Is it possible that the viewports lower, left corner isn't at 0,0? And why can't the DynamicBody get on top of the StaticBody?

\$\endgroup\$
  • \$\begingroup\$ Box2D bodies are aligned from their center, not from lower left corner. It looks you set your smaller sodies position to 0,0 and its center is on 0,0 \$\endgroup\$ – Arda Kara Aug 18 '15 at 10:10
-1
\$\begingroup\$

a box2d rectangle has x and y coordinates with thw center in the center of rectangle... other this, to create a rectangle pay attention to give him halfWidth and halfHeight and not full.

for example, if you want a 2*2 rectangle in left down corner you have to build it with:

x = x+halfWidth y = y+halfHeight halfHeight =1 halfWidth =1

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.