r3-legacy/src/game-lib-api-mouse.js

62 lines
1.1 KiB
JavaScript

/**
* API Mouse
* @param id
* @param name
* @param x
* @param y
* @param parentEntity
* @constructor
*/
GameLib.API.Mouse = function(
id,
name,
x,
y,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(parentEntity)) {
parentEntity = null;
}
this.parentEntity = parentEntity;
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Mouse (' + this.id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(x)) {
x = 0;
}
this.x = x;
if (GameLib.Utils.UndefinedOrNull(y)) {
y = 0;
}
this.y = y;
};
GameLib.API.Mouse.prototype = Object.create(GameLib.Component.prototype);
GameLib.API.Mouse.prototype.constructor = GameLib.API.Mouse;
/**
* Returns an API mouse from an Object mouse
* @param objectMouse
* @constructor
*/
GameLib.API.Mouse.FromObject = function (objectMouse) {
return new GameLib.API.Mouse(
objectMouse.id,
objectMouse.name,
objectMouse.x,
objectMouse.y,
objectMouse.parentEntity
)
};