Files
mjs/667.ручноетело.js

47 lines
1.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function РучноеТело(события) {
this.создать = function() {
события.подписать(this);
};
this.обработатьСобытие = function(событие) {
if (событие != "игрок начал прыжок")
{
return;
}
события.отписать(this);
this.настроить();
};
this.настроить = function()
{
var физика = {
inertia: Infinity,
};
this.тело = Matter.Bodies.rectangle(1200, 300, 40, 40, физика);
Matter.Composite.add(мир.физика.движок.world, this.тело);
this.элемент = document.createElement("div");
document.getElementById("корень").appendChild(this.элемент);
this.элемент.id = `рт`;
this.элемент.style.position = "absolute";
this.элемент.style.display = "block";
this.элемент.style.transformOrigin = "center";
this.элемент.style.width = `40px`;
this.элемент.style.height = `40px`;
this.элемент.style.setProperty("background", "url(р/отладка/основа.jpg)");
};
this.обновить = function()
{
if (!this.тело)
{
return;
}
мир.синхронизироватьЭлементТело(this.элемент, this.тело);
};
// Конструктор.
this.создать();
}