2017-01-09 15:20:48 +01:00
|
|
|
/**
|
|
|
|
* API Mouse
|
|
|
|
* @param id
|
|
|
|
* @param name
|
|
|
|
* @param x
|
|
|
|
* @param y
|
2017-01-19 17:50:11 +01:00
|
|
|
* @param parentEntity
|
2017-01-09 15:20:48 +01:00
|
|
|
* @constructor
|
|
|
|
*/
|
|
|
|
GameLib.API.Mouse = function(
|
|
|
|
id,
|
|
|
|
name,
|
|
|
|
x,
|
2017-01-19 17:50:11 +01:00
|
|
|
y,
|
|
|
|
parentEntity
|
2017-01-09 15:20:48 +01:00
|
|
|
) {
|
|
|
|
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;
|
|
|
|
|
2017-12-04 13:23:15 +01:00
|
|
|
GameLib.API.Component.call(
|
|
|
|
this,
|
|
|
|
GameLib.Component.MOUSE,
|
|
|
|
parentEntity
|
|
|
|
);
|
2017-01-09 15:20:48 +01:00
|
|
|
};
|
|
|
|
|
2017-01-19 17:50:11 +01:00
|
|
|
GameLib.API.Mouse.prototype = Object.create(GameLib.Component.prototype);
|
|
|
|
GameLib.API.Mouse.prototype.constructor = GameLib.API.Mouse;
|
|
|
|
|
2017-01-09 15:20:48 +01:00
|
|
|
/**
|
|
|
|
* Returns an API mouse from an Object mouse
|
|
|
|
* @param objectMouse
|
|
|
|
* @constructor
|
|
|
|
*/
|
2017-06-14 14:21:57 +02:00
|
|
|
GameLib.API.Mouse.FromObject = function (objectMouse) {
|
2017-01-09 15:20:48 +01:00
|
|
|
return new GameLib.API.Mouse(
|
|
|
|
objectMouse.id,
|
|
|
|
objectMouse.name,
|
|
|
|
objectMouse.x,
|
2017-01-19 17:50:11 +01:00
|
|
|
objectMouse.y,
|
|
|
|
objectMouse.parentEntity
|
2017-01-09 15:20:48 +01:00
|
|
|
)
|
|
|
|
};
|