我可以像精灵一样缩放 box2d 中的形状吗? [英] Can I scale a shape in box2d as sprite do?

查看:16
本文介绍了我可以像精灵一样缩放 box2d 中的形状吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我们一直使用cocos2d中的函数,我可以随时缩放我的精灵.我可以在box2d中做同样的事情吗?例如,我创建了一个圆形的身体,然后我想把它放大.

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.

我在创建圆后尝试重新分配 m_radius,但不起作用.

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

推荐答案

如果您只是将 shape.m_radius 分配给一个新值,它将不起作用.

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

您需要引用与您为对象创建的 b2Fixture 关联的形状对象:

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;

希望这会有所帮助.

这篇关于我可以像精灵一样缩放 box2d 中的形状吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆