SOLVED: setFixedRotation(false) seems to be ignored

New to Moai? Get started here with our best tips and tutorials.

Moderator: DanielWolf

SOLVED: setFixedRotation(false) seems to be ignored

Postby ivan » Sat Apr 07, 2012 10:39 am

UPD: OK, so setFixedRotation indeed is no longer supported by Box2D. Instead, one should set the moment of inertia to something other than the default 0 (using MOAIBox2DBody:setMassData) to enable the rotation. I think it would be reasonable to mark the setFixedRotation function as deprecated in the API docs as it is quite confusing.
---
I am just starting out with Box2D, and I cannot cause a body to rotate.

I am doing something like this:

world = MOAIBox2DWorld.new ()
world:setGravity ( 0, 0 )
world:setUnitsToMeters ( 1/30 )
layer:setBox2DWorld ( world )

dynamicBody = world:addBody ( MOAIBox2DBody.DYNAMIC )
dynamicBody:addRect(-30, -30, 30, 30)
dynamicBody:setFixedRotation(false)
dynamicBody:applyAngularImpulse (200)

Upon further inspection it seems that setFixedRotation is ignored and isFixedRotation always returns true. Why could that happen?
ivan
 
Posts: 1
Joined: Sat Apr 07, 2012 10:33 am

Re: SOLVED: setFixedRotation(false) seems to be ignored

Postby BladeOfOdin » Thu Aug 23, 2012 4:23 pm

i ran into something like this recently. It was because the fixture being added didn't have it's density set not because setFixedRotation doesn't work anymore [it does work].

so something like this
Code: Select all
  1.  

  2. fixture:setDensity ( 1 )

  3.  



and in your case
Code: Select all
  1.  

  2. dynamicBody:addRect(-30, -30, 30, 30)

  3.  



would become
Code: Select all
  1.  

  2. local fixture = dynamicBody:addRect(-30, -30, 30, 30)

  3. fixture:setDensity ( 1 )

  4.  

User avatar
BladeOfOdin
 
Posts: 1
Joined: Thu Aug 23, 2012 4:18 pm


Return to Questions and Tips

Who is online

Users browsing this forum: No registered users and 0 guests

cron

x