два ручных тела
This commit is contained in:
@@ -18,27 +18,41 @@ function РучноеТело(события) {
|
|||||||
var физика = {
|
var физика = {
|
||||||
inertia: Infinity,
|
inertia: Infinity,
|
||||||
};
|
};
|
||||||
this.тело = Matter.Bodies.rectangle(1200, 300, 40, 40, физика);
|
// 1.
|
||||||
Matter.Composite.add(мир.физика.движок.world, this.тело);
|
this.тело1 = Matter.Bodies.rectangle(1200, 300, 40, 40, физика);
|
||||||
|
Matter.Composite.add(мир.физика.движок.world, this.тело1);
|
||||||
|
|
||||||
this.элемент = document.createElement("div");
|
this.элемент1 = document.createElement("div");
|
||||||
document.getElementById("корень").appendChild(this.элемент);
|
document.getElementById("корень").appendChild(this.элемент1);
|
||||||
this.элемент.id = `рт`;
|
this.элемент1.style.position = "absolute";
|
||||||
this.элемент.style.position = "absolute";
|
this.элемент1.style.display = "block";
|
||||||
this.элемент.style.display = "block";
|
this.элемент1.style.transformOrigin = "center";
|
||||||
this.элемент.style.transformOrigin = "center";
|
this.элемент1.style.width = `40px`;
|
||||||
this.элемент.style.width = `40px`;
|
this.элемент1.style.height = `40px`;
|
||||||
this.элемент.style.height = `40px`;
|
this.элемент1.style.setProperty("background", "url(р/отладка/основа.jpg)");
|
||||||
this.элемент.style.setProperty("background", "url(р/отладка/основа.jpg)");
|
|
||||||
|
// 2.
|
||||||
|
this.тело2 = Matter.Bodies.rectangle(1150, 300, 40, 40, физика);
|
||||||
|
Matter.Composite.add(мир.физика.движок.world, this.тело2);
|
||||||
|
|
||||||
|
this.элемент2 = document.createElement("div");
|
||||||
|
document.getElementById("корень").appendChild(this.элемент2);
|
||||||
|
this.элемент2.style.position = "absolute";
|
||||||
|
this.элемент2.style.display = "block";
|
||||||
|
this.элемент2.style.transformOrigin = "center";
|
||||||
|
this.элемент2.style.width = `40px`;
|
||||||
|
this.элемент2.style.height = `40px`;
|
||||||
|
this.элемент2.style.setProperty("background", "url(р/отладка/основа.jpg)");
|
||||||
};
|
};
|
||||||
|
|
||||||
this.обновить = function()
|
this.обновить = function()
|
||||||
{
|
{
|
||||||
if (!this.тело)
|
if (!this.тело1)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
мир.синхронизироватьЭлементТело(this.элемент, this.тело);
|
мир.синхронизироватьЭлементТело(this.элемент1, this.тело1);
|
||||||
|
мир.синхронизироватьЭлементТело(this.элемент2, this.тело2);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Конструктор.
|
// Конструктор.
|
||||||
|
|||||||
Reference in New Issue
Block a user