react-simple-game-engine
Version:
[WIP] not able to use in currently. <!-- Document cumming soon... -->
76 lines (75 loc) • 2.86 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { Bodies } from "matter-js";
import { copyProperties } from "../../utils";
import { Entity } from "./entity";
var CircleEntity = /** @class */ (function (_super) {
__extends(CircleEntity, _super);
function CircleEntity() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(CircleEntity.prototype, "edge", {
get: function () {
var _a = this, position = _a.position, radius = _a.radius;
var left = position.x - radius;
var right = position.x + radius;
var top = position.y - radius;
var bottom = position.y + radius;
return { left: left, right: right, top: top, bottom: bottom };
},
enumerable: false,
configurable: true
});
CircleEntity.prototype.getSpriteWidthHeight = function () {
return {
width: this.radius * 2,
height: this.radius * 2,
};
};
CircleEntity.prototype.onInitial = function () {
return {
transform: {
radius: 1,
},
};
};
CircleEntity.prototype.onCreateBody = function (enabledPhysicBody, _a, options) {
var x = _a.x, y = _a.y, transform = __rest(_a, ["x", "y"]);
copyProperties(this, transform);
if (enabledPhysicBody) {
return Bodies.circle(x, y, this.radius, options);
}
return {
position: {
x: x,
y: y,
},
};
};
return CircleEntity;
}(Entity));
export { CircleEntity };