|
@@ -128,7 +128,7 @@ export default {
|
|
|
// item_type: 'entite',
|
|
|
// id: this.entites[i].id
|
|
|
// }))
|
|
|
- parts.push(Matter.Bodies.circle(this.entites[i].display.pos.x, this.entites[i].display.pos.y, 2, {
|
|
|
+ parts.push(Matter.Bodies.circle(this.entites[i].display.pos.x, this.entites[i].display.pos.y, 0.8, {
|
|
|
item_type: 'entite',
|
|
|
id: this.entites[i].entite.id,
|
|
|
isSensor: true
|
|
@@ -292,6 +292,9 @@ export default {
|
|
|
});
|
|
|
Matter.Composite.add(this.matterEngine.world, [this.body, this.constraint]);
|
|
|
});
|
|
|
+ // recreate the matter engine event to get it a the end of the events stack
|
|
|
+ Matter.Events.off(this.matterEngine, "afterUpdate", this.onAfterEngineUpdate);
|
|
|
+ Matter.Events.on(this.matterEngine, "afterUpdate", this.onAfterEngineUpdate);
|
|
|
} else {
|
|
|
// closing
|
|
|
if(this.constraint){
|
|
@@ -334,11 +337,6 @@ export default {
|
|
|
|
|
|
this.pos = this.body.position;
|
|
|
|
|
|
- // this.ctx.clearRect(
|
|
|
- // this.pos.x - this.ray*this.scale, this.pos.y - this.ray*this.scale,
|
|
|
- // this.ray*this.scale*2, this.ray*this.scale*2
|
|
|
- // );
|
|
|
-
|
|
|
if (this.opened) {
|
|
|
// BOUSSOLE
|
|
|
// exterieur circle
|
|
@@ -413,30 +411,26 @@ export default {
|
|
|
|
|
|
if (this.opened) {
|
|
|
// place all entities points
|
|
|
- for (let i = 0; i < this.entites.length; i++) {
|
|
|
- let entite = this.entites[i];
|
|
|
- // console.log('entite', entite);
|
|
|
- this.ctx.beginPath();
|
|
|
- this.ctx.arc(this.pos.x+entite.display.pos.x*this.scale, this.pos.y+entite.display.pos.y*this.scale, 5, 0, 2 * Math.PI, false);
|
|
|
- this.ctx.strokeStyle = "#F00";
|
|
|
- this.ctx.stroke();
|
|
|
- }
|
|
|
- // OR
|
|
|
+ // using entities array
|
|
|
+ // for (let i = 0; i < this.entites.length; i++) {
|
|
|
+ // let entite = this.entites[i];
|
|
|
+ // // console.log('entite', entite);
|
|
|
+ // this.ctx.beginPath();
|
|
|
+ // this.ctx.arc(this.pos.x+entite.display.pos.x*this.scale, this.pos.y+entite.display.pos.y*this.scale, 5, 0, 2 * Math.PI, false);
|
|
|
+ // this.ctx.strokeStyle = "#F00";
|
|
|
+ // this.ctx.stroke();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // OR using entitées matter bodies
|
|
|
for (let i = 0; i < this.body.parts.length; i++) {
|
|
|
- // let entite = this.entites[i];
|
|
|
- if (this.body.parts[i].item_type === 'entity') {
|
|
|
+ if (this.body.parts[i].item_type === 'entite') {
|
|
|
let part = this.body.parts[i];
|
|
|
- // console.log('part', part);
|
|
|
- // console.log(`part pos x:${part.position.x} y:${part.position.y} || entity pos x:${this.pos.x+this.entites_byid[part.id].display.pos.x*this.scale} y:${this.pos.y+this.entites_byid[part.id].display.pos.y*this.scale}`);
|
|
|
this.ctx.beginPath();
|
|
|
- // this.ctx.arc(this.pos.x+entite.display.pos.x*this.scale, this.pos.y+entite.display.pos.y*this.scale, 2, 0, 2 * Math.PI, false);
|
|
|
- this.ctx.arc(this.body.parts[i].position.x, this.body.parts[i].position.y, 2*this.scale, 0, 2 * Math.PI, false);
|
|
|
- this.ctx.strokeStyle = "#000";
|
|
|
- this.ctx.stroke();
|
|
|
-
|
|
|
+ this.ctx.arc(this.body.parts[i].position.x, this.body.parts[i].position.y, 0.3*this.scale, 0, 2 * Math.PI, false);
|
|
|
+ this.ctx.fillStyle = "#000";
|
|
|
+ this.ctx.fill();
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// concernement id @center
|