2017-01-09 15:20:48 +01:00
|
|
|
/**
|
2017-12-02 11:49:27 +01:00
|
|
|
* Runtime Mouse
|
|
|
|
* @param apiMouse
|
|
|
|
* @returns {GameLib.Mouse}
|
2017-01-09 15:20:48 +01:00
|
|
|
* @constructor
|
|
|
|
*/
|
2017-12-02 11:49:27 +01:00
|
|
|
GameLib.Mouse = function (apiMouse) {
|
2017-01-09 15:20:48 +01:00
|
|
|
|
2017-02-21 18:55:18 +01:00
|
|
|
if (GameLib.Utils.UndefinedOrNull(apiMouse)){
|
|
|
|
apiMouse = {};
|
|
|
|
}
|
|
|
|
|
2018-01-07 12:58:15 +01:00
|
|
|
GameLib.API.Mouse.call(
|
2017-01-09 15:20:48 +01:00
|
|
|
this,
|
|
|
|
apiMouse.id,
|
|
|
|
apiMouse.name,
|
2018-02-20 16:40:14 +01:00
|
|
|
apiMouse.parentEntity,
|
2017-01-09 15:20:48 +01:00
|
|
|
apiMouse.x,
|
2018-02-20 16:40:14 +01:00
|
|
|
apiMouse.y
|
2017-01-09 15:20:48 +01:00
|
|
|
);
|
|
|
|
|
2017-12-04 13:23:15 +01:00
|
|
|
GameLib.Component.call(this);
|
2017-01-09 15:20:48 +01:00
|
|
|
};
|
|
|
|
|
2018-01-07 12:40:16 +01:00
|
|
|
GameLib.Mouse.prototype = Object.create(GameLib.Component.prototype);
|
2017-01-19 17:50:11 +01:00
|
|
|
GameLib.Mouse.prototype.constructor = GameLib.Mouse;
|
|
|
|
|
2017-01-09 15:20:48 +01:00
|
|
|
/**
|
2017-12-02 11:49:27 +01:00
|
|
|
* createInstance
|
2017-01-09 15:20:48 +01:00
|
|
|
*/
|
2017-12-02 11:49:27 +01:00
|
|
|
GameLib.Mouse.prototype.createInstance = function() {
|
2018-01-19 15:04:54 +01:00
|
|
|
this.instance = {};
|
2017-10-23 14:52:35 +02:00
|
|
|
GameLib.Component.prototype.createInstance.call(this);
|
2017-01-09 15:20:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2017-12-02 11:49:27 +01:00
|
|
|
* updateInstance
|
|
|
|
* @param property
|
2017-01-09 15:20:48 +01:00
|
|
|
*/
|
2017-12-02 11:49:27 +01:00
|
|
|
GameLib.Mouse.prototype.updateInstance = function(property) {
|
2018-01-19 15:04:54 +01:00
|
|
|
|
2018-02-08 13:57:15 +01:00
|
|
|
if (
|
|
|
|
property === 'x' ||
|
|
|
|
property === 'y'
|
|
|
|
) {
|
2018-01-19 15:04:54 +01:00
|
|
|
this.instance.x = this.x;
|
|
|
|
this.instance.y = this.y;
|
2018-02-08 13:57:15 +01:00
|
|
|
return;
|
2017-12-02 11:49:27 +01:00
|
|
|
}
|
2018-01-19 15:04:54 +01:00
|
|
|
|
2018-02-08 13:57:15 +01:00
|
|
|
GameLib.Component.prototype.updateInstance.call(this, property);
|
|
|
|
|
2017-01-09 15:20:48 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2017-12-02 11:49:27 +01:00
|
|
|
* Converts GameLib.Mouse vector to GameLib.API.Mouse
|
2017-01-09 15:20:48 +01:00
|
|
|
* @returns {GameLib.API.Mouse}
|
|
|
|
*/
|
2017-05-16 14:51:57 +02:00
|
|
|
GameLib.Mouse.prototype.toApiObject = function() {
|
2017-01-09 15:20:48 +01:00
|
|
|
return new GameLib.API.Mouse(
|
|
|
|
this.id,
|
|
|
|
this.name,
|
2018-02-20 16:40:14 +01:00
|
|
|
GameLib.Utils.IdOrNull(this.parentEntity),
|
2017-01-09 15:20:48 +01:00
|
|
|
this.x,
|
2018-02-20 16:40:14 +01:00
|
|
|
this.y
|
2017-01-09 15:20:48 +01:00
|
|
|
);
|
|
|
|
};
|