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

77 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-01-09 15:20:48 +01:00
/**
* Runtime Mouse
* @param apiMouse
* @returns {GameLib.Mouse}
2017-01-09 15:20:48 +01:00
* @constructor
*/
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 = {};
}
if (apiMouse instanceof GameLib.Mouse) {
return apiMouse;
}
2017-01-09 15:20:48 +01:00
GameLib.API.Mouse.call(
this,
apiMouse.id,
apiMouse.name,
apiMouse.x,
2017-01-19 17:50:11 +01:00
apiMouse.y,
apiMouse.parentEntity
2017-01-09 15:20:48 +01:00
);
2017-06-16 18:45:25 +02:00
GameLib.Component.call(
this,
GameLib.Component.COMPONENT_MOUSE
);
2017-01-09 15:20:48 +01:00
};
2017-01-19 17:50:11 +01:00
GameLib.Mouse.prototype = Object.create(GameLib.API.Mouse.prototype);
GameLib.Mouse.prototype.constructor = GameLib.Mouse;
2017-01-09 15:20:48 +01:00
/**
* createInstance
2017-01-09 15:20:48 +01:00
*/
GameLib.Mouse.prototype.createInstance = function() {
2017-10-23 14:52:35 +02:00
this.instance = true;
GameLib.Component.prototype.createInstance.call(this);
2017-01-09 15:20:48 +01:00
};
/**
* updateInstance
* @param property
2017-01-09 15:20:48 +01:00
*/
GameLib.Mouse.prototype.updateInstance = function(property) {
if (GameLib.Utils.UndefinedOrNull(property)) {
console.warn('unknown property update for Mouse: ' + property);
}
2017-01-09 15:20:48 +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,
this.x,
2017-01-19 17:50:11 +01:00
this.y,
this.parentEntity
2017-01-09 15:20:48 +01:00
);
};
/**
* GameLib.Mouse from Object
* @param objectMouse
* @returns {GameLib.Mouse}
* @constructor
*/
GameLib.Mouse.prototype.FromObject = function(objectMouse) {
return new GameLib.Mouse(
GameLib.API.Mouse.FromObject(objectMouse)
);
};