UNPKG

@moderrkowo/jsgl

Version:

Client-side JavaScript library for creating web 2D games. Focusing at objective game.

56 lines (55 loc) 1.96 kB
"use strict"; 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 __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.Sprite = void 0; var ClickableGameObject_1 = require("./ClickableGameObject"); var RotationStyle_1 = require("../enums/RotationStyle"); /** * Represents sprite game object * @group Game Objects */ var Sprite = /** @class */ (function (_super) { __extends(Sprite, _super); function Sprite() { var _this = _super !== null && _super.apply(this, arguments) || this; /** * Sprite rotation style */ _this.rotationStyle = RotationStyle_1.RotationStyle.allAround; return _this; } /** * Calls `event.game.Update()` at spawn * @override */ Sprite.prototype.Start = function (event) { event.game.Update(); }; /** * Calls sprite render on drawing * @override */ Sprite.prototype.OnDraw = function (event) { if (this.texture === undefined) return; if (this.visible) { event.renderer.drawSprite(this); } }; return Sprite; }(ClickableGameObject_1.ClickableGameObject)); exports.Sprite = Sprite;