UNPKG

@moderrkowo/jsgl

Version:

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

73 lines (72 loc) 2.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GameObject = void 0; /* eslint-disable @typescript-eslint/no-empty-function */ /* eslint-disable @typescript-eslint/no-unused-vars */ var Transform_1 = require("../structs/Transform"); /** * Represents plain GameObject * @group Game Objects * @author Tymon Woźniak * @class */ var GameObject = /** @class */ (function () { /** * Constructs new GameObject. * @constructor */ function GameObject() { this.id = crypto.getRandomValues(new Uint32Array(4)).join('-'); this.enabled = true; this.name = undefined; this.tag = undefined; this.sortingOrder = 0; this.transform = new Transform_1.Transform(0, 0, 1, 1, 0); } /** * Invoked at game object spawn. * @method * @param event - {@link GameObjectSpawnEvent} * @virtual * @example * Start(event){ * console.log('I have been spawned!'); * } */ GameObject.prototype.Start = function (event) { }; /** * Invoked at game object destroy. * @method * @param event - {@link GameObjectDestroyEvent} * @virtual * @example * Destroy(event){ * console.log('I have been destroyed!'); * } */ GameObject.prototype.Destroy = function (event) { }; /** * Invoked at every frame. * @method * @param event - {@link TickEvent} * @virtual * @example * Update(event){ * this.transform.translate(new JSGL.Vector2(1, 0).multiply(event.deltaTime)); * } */ GameObject.prototype.Update = function (event) { }; /** * Invoked at last update in every frame. * @method * @param event - {@link TickEvent} * @virtual * @example * Update(event){ * this.transform.translate(new JSGL.Vector2(1, 0).multiply(event.deltaTime)); * } */ GameObject.prototype.FixedUpdate = function (event) { }; return GameObject; }()); exports.GameObject = GameObject;