物理引擎中链条形状根据对应贴图轮廓获取顶点是怎么实现的呢

resetPointsByContour: CC_EDITOR && function () {
    var PhysicsUtils = Editor.require('scene://utils/physics');
    PhysicsUtils.resetPoints(this, {threshold: this.threshold, loop: this.loop});
}

求问,在creator中PhysicsChainCollider形状根据对应贴图轮廓获取顶点是怎么实现的呢?
创建后会直接根据sprite组件贴图自动生成对应外轮廓的顶点坐标,有指到这个工具的源码或者这种做法的思路吗?

大佬99小孩子吧

我这里的做法是先把图片拖入ccc编辑器,用编辑器自带的生成点数据,把数据导出成json,游戏运行时根据图片读取json赋值给points。
如果你图片的贴图只有百来张我觉得可以考虑下我这种方式。

也是一种方法,我还想着在游戏运行时动态获取,不知道行不行

同求!这个PhysicsUtils从哪可以看到?

var PhysicsUtils = Editor.require('scene://utils/physics');
PhysicsUtils.resetPoints(polygonCollider, {threshold: polygonCollider.threshold});
1赞

这是一种 h5 上的 图片边缘提取算法的。
https://blog.csdn.net/frabbit_on_fire/article/details/90027113

可以考虑像他这样去做。

选择开发者工具,或者Alt+Ctrl+I进入。
看Sources面板的Sources子面板,展开top/(no domain) 然后找到这里,点开就可以看了

非常感谢!

https://www.emanueleferonato.com/2013/03/13/from-png-to-box2d-first-attempt/

请问一下你这个是什么版本,我用2.2.2版本点开这个文件是空白的,不让看