You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.13 16:08:00