Skip to content

Commit

Permalink
Fix of unset check and new removeConstraint function
Browse files Browse the repository at this point in the history
  • Loading branch information
ByronStar committed Mar 13, 2023
1 parent ce2fa7e commit 31590fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions classes/Block.js
Expand Up @@ -148,6 +148,19 @@ class Block extends BlockCore {
return contraint;
}

/**
* Remove a constraint of this block to another block.
* @param {contraint} constraint
* @memberof Block
*/
removeConstraint(contraint) {
const idx = this.constraints.indexOf(constraint)
if (idx > -1) {
this.constraints.splice(idx, 1)
Matter.World.remove(constraint)
}
}

/**
* Adds a block to an internal collisions array, to check whether this block colides with another block
* @param {block} block
Expand Down
2 changes: 1 addition & 1 deletion classes/PolygonFromSVG.js
Expand Up @@ -83,7 +83,7 @@ class PolygonFromSVG extends Block {

addBodyVertices(vertices) {
this.body = Matter.Bodies.fromVertices(0, 0, Matter.Vertices.scale(vertices, this.attributes.scale, this.attributes.scale), this.options);
if (this.attributes.x) {
if (typeof this.attributes.x !== undefined) {
Matter.Body.setPosition(this.body, this.attributes);
} else {
Matter.Body.setPosition(this.body, this.getCenter(vertices));
Expand Down

0 comments on commit 31590fc

Please sign in to comment.