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\$
1
  • \$\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, 2015 at 10:10

1 Answer 1

-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\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .