сенсор игрока рабтает

This commit is contained in:
2021-08-12 15:17:14 +03:00
parent fde0a9ed9d
commit 21a892188c
4 changed files with 39 additions and 25 deletions

View File

@@ -30,7 +30,6 @@ function РучноеТело(события) {
// 1.
this.тело1 = Matter.Bodies.rectangle(125, 300, 40, 40, { isSensor: true });
//Matter.Composite.add(мир.физика.движок.world, this.тело1);
this.элемент1 = document.createElement("div");
document.getElementById("корень").appendChild(this.элемент1);
@@ -43,8 +42,7 @@ function РучноеТело(события) {
this.элемент1.style.setProperty("z-index", "100");
// 2.
this.тело2 = Matter.Bodies.rectangle(55, 300, 40, 40, {});
//Matter.Composite.add(мир.физика.движок.world, this.тело2);
this.тело2 = Matter.Bodies.rectangle(55, 300, 40, 40, { inertia: Infinity });
this.элемент2 = document.createElement("div");
document.getElementById("корень").appendChild(this.элемент2);
@@ -56,12 +54,25 @@ function РучноеТело(события) {
this.элемент2.style.setProperty("background", "url(р/отладка/основа.jpg)");
this.элемент2.style.setProperty("z-index", "100");
/*
Matter.Composite.add(мир.физика.движок.world, this.тело1);
Matter.Composite.add(мир.физика.движок.world, this.тело2);
мир.объекты.тела["рт"] = this.тело2;
this.тело = this.тело2;
*/
// Compound.
this.тело = Matter.Body.create({
parts: [this.тело1, this.тело2],
inertia: Infinity,
});
Matter.Composite.add(мир.физика.движок.world, this.тело);
мир.объекты.тела["рт"] = this.тело;
мир.объекты.тела["рт1"] = this.тело1;
мир.объекты.имена[this.тело1.id] = "рт1";
мир.объекты.тела["рт2"] = this.тело2;
мир.объекты.имена[this.тело2.id] = "рт2";
};
this.обновить = function()