在Phaser中使用Matter.js从SVG创建物理刚体的技术咨询
在Phaser中使用Matter.js从SVG创建物理刚体的技术咨询
嘿,我现在在Phaser里用Matter.js做开发,遇到了点状况,先跟你唠唠我的操作流程:
我在preload函数里把SVG文件当作XML来加载:
this.load.xml("xml-pipe-bottom", "assets/svg/shape_pipe_b.svg");
接着我创建了物理刚体,同时把SVG转成了精灵:
const shapeBody = this.matter.add.fromSVG( 0, 0, this.cache.xml.get(xmlKey) ) shapeBody.ignoreGravity = true; const shape = this.matter.add.sprite(400, 400, svgKey) .setIgnoreGravity(true) .setExistingBody(shapeBody)
现在Matter的调试模式已经开启了,不过……(后续内容没写完,暂时先说到这儿)
备注:内容来源于stack exchange,提问作者NeoGER89




