Erstellen Sie Physikkörper aus SVG in Phaser mit Materie.jsJavaScript

Javascript-Forum
Anonymous
 Erstellen Sie Physikkörper aus SVG in Phaser mit Materie.js

Post by Anonymous »

Ich lade ein SVG als XML in der Vorspannungsfunktion: < /p>

Code: Select all

this.load.xml("xml-pipe-bottom", "assets/svg/shape_pipe_b.svg");
< /code>
und erstellen Sie einen Körper und den SVG als Sprite: < /p>
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)
Materie Debugg ist aktiviert und sieht so aus:

Die SVG ist nur das SVG -SVG. Der Erzeuger ist immer der gleiche. class = "snippet-code-html Lang-html PrettyPrint-Override">

Code: Select all






id="rect1"
style="fill:#000000;stroke-width:0.264583"
d="M 50.000049,0 A 50,50 0 0 1 0,50.000049 h 50.000049 z"/>














Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post