nodePong/client/lib/ui/objects/ui_object.js

78 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-02-14 07:06:40 +11:00
/**
2016-02-16 10:47:28 +11:00
* @file ui_object.js
2016-02-14 07:06:40 +11:00
* @author frtk@tetalab
*/
2016-02-16 10:47:28 +11:00
//
2016-02-14 07:06:40 +11:00
2016-02-16 10:47:28 +11:00
NPGClient.UIObject = function(o) {
2016-02-14 07:06:40 +11:00
2016-02-16 10:47:28 +11:00
this._x = (o.x !== undefined) ? o.x : 0; // x position
this._y = (o.y !== undefined) ? o.y : 0; // y position
this._theta = (o.theta !== undefined) ? o.theta : 0; // theta wrt horizon
2016-02-14 07:06:40 +11:00
};
2016-02-16 10:47:28 +11:00
/**
*
*/
2016-02-14 07:06:40 +11:00
NPGClient.UIObject.prototype = {
2016-02-16 10:47:28 +11:00
// Constructor
constructor: NPGClient.UIObject,
//set/get
x: function(data) {
var self = this;
if (data !== undefined) {
self._x = data;
} else {
return self._x;
2016-02-14 07:06:40 +11:00
}
2016-02-16 10:47:28 +11:00
},
//set/get
y: function(data) {
var self = this;
if (data !== undefined) {
self._y = data;
} else {
return self._y;
}
},
//
moveTo: function(x, y) {
var self = this;
self._x = x;
self._y = y;
},
//
translateXY: function(x, y) {
var self = this;
self._x += x;
self._y += y;
},
//
translateX: function(x) {
this._x += x;
},
//
translateY: function(y) {
this._y += y;
},
//
rotate: function(x, y, t) {
},
};