Can I scale a shape in box2d as sprite do?

故事扮演 提交于 2019-12-01 13:14:03

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/9075359/can-i-scale-a-shape-in-box2d-as-sprite-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!