Search code examples
cocos2d-iphonebox2dscale

Can I scale a shape in box2d as sprite do?


As we always use the function in cocos2d,I can scale my sprite whenever I want.Can I do the same thing in box2d?For example, I created a circle shaped body,then I want to make it bigger.

I tried reassign the m_radius after I created a circle,but not work.


Solution

  • If you are simply assigning shape.m_radius to a new value, it will not work.

    You need to reference the shape object associated with the b2Fixture that you created for your object:

    fixture->GetShape()->m_radius = new_radius/PTM_RATIO;
    

    Hope this helps.