/** * Runtime mouse for updating instance objects * @param graphics GameLib.D3.Graphics * @param apiMouse GameLib.API.Mouse * @constructor */ GameLib.Mouse = function (graphics, apiMouse) { this.graphics = graphics; this.graphics.isNotThreeThrow(); if (GameLib.Utils.UndefinedOrNull(apiMouse)){ apiMouse = {}; } if (apiMouse instanceof GameLib.Mouse) { return apiMouse; } GameLib.API.Mouse.call( this, apiMouse.id, apiMouse.name, apiMouse.x, apiMouse.y, apiMouse.parentEntity ); this.instance = this.createInstance(); }; GameLib.Mouse.prototype = Object.create(GameLib.API.Mouse.prototype); GameLib.Mouse.prototype.constructor = GameLib.Mouse; /** * Creates an instance mouse * @param update * @returns {*} */ GameLib.Mouse.prototype.createInstance = function(update) { var instance = null; if (update) { instance = this.instance; } return instance; }; /** * Updates the instance vector, calls updateInstance on the parent object */ GameLib.Mouse.prototype.updateInstance = function() { this.createInstance(true); }; /** * Converts runtime vector to API Vector * @returns {GameLib.API.Mouse} */ GameLib.Mouse.prototype.toApiMouse = function() { return new GameLib.API.Mouse( this.id, this.name, this.x, this.y, this.parentEntity ); };