Hi, i am new with Polygons and trying to update the position of a Polygon Body, so it can be reused on a different location in the game. I am creating an infinite parcour with polygons.
Currently creating a polygon with the next following line:
this.current = this.scene.matter.add.polygon(x, y, this.sides, this.radius, this.options);
When the methode setPosition(newX, newY)
is called, the following errormessage appears Uncaught TypeError: this.current.setPosition is not a function
.
Does anyone know if it is possible to reuse polygon’s or can they be destroy when they are no longer neccesary?
These are some other things I tried that have failed:
this.current.position.x = x;
this.current.position.y = y;
this.current.positionPrev.x = x;
this.current.positionPrev.y = y;
this.current.parent.position.x = x;
this.current.parent.position.y = y;
this.current.parent.positionPrev.x = x;
this.current.parent.positionPrev.y = y;