box2D.CreateObject() not obeying image size

24 views
Skip to first unread message

Glitch

unread,
Aug 15, 2013, 2:06:42 PM8/15/13
to fantom...@googlegroups.com
OK. What am I missing here?


Local ball:ftObject
ball
= eng.CreateImage("ball.png", x, y)
ball
.SetScale(0.5)
ball
.SetColType(ftEngine.ctCircle)
ball
.SetID(123)

world
.CreateObject(ball)


Now, herein lies a problem. The b2D object is twice the size of the image. It doesn't seem to effect it if I make the collision type a box, but then when has a ball been square?

Am I missing something inherently obvious here? Any help appreciated. :)

Glitch

unread,
Aug 16, 2013, 9:13:22 AM8/16/13
to fantom...@googlegroups.com
So I looked the the cftBox2D.monkey code. Appears there's something amiss with how you are calculating the radius of a circle. So by making a tiny change to the CreateObject method this seems to fix the over-sized Box2D circle.

shapeC = New b2CircleShape(tmpObj.GetHeight()/2/m_physScale)

Slap me down if I'm wrong :)

Michael Hartlef

unread,
Aug 16, 2013, 12:41:49 PM8/16/13
to fantom...@googlegroups.com
Nah, but thanks. Will test it and fix it.

Glitch

unread,
Aug 16, 2013, 2:29:35 PM8/16/13
to fantom...@googlegroups.com
You superstar!

Michael Hartlef

unread,
Aug 17, 2013, 5:28:26 PM8/17/13
to fantom...@googlegroups.com
Thanks, you are to kind! :-)

Michael Hartlef

unread,
Aug 18, 2013, 8:46:46 AM8/18/13
to fantom...@googlegroups.com
Ok, the problem was that I have calculated the radius of the corner edges. I have changed that now and it should be fixed.

Glitch

unread,
Aug 18, 2013, 9:44:07 AM8/18/13
to fantom...@googlegroups.com
Great stuff, I no longer have big balls!
Reply all
Reply to author
Forward
0 new messages