nodePong/client/lib/ui/objects/ui_menu.js
2016-02-14 04:37:31 +01:00

50 lines
892 B
JavaScript

/**
* @file ui_menu.js
* @author frtk@tetalab
*/
NPGClient.UIMenu = function(n, o) {
// obj name
this.name = n !== undefined ? n : '';
// type (vertical/horizontal)
this.type = o.type !== undefined ? o.type : '';
// pos
this.x = o.x !== undefined ? o.x : 0;
this.y = o.y !== undefined ? o.y : 0;
// item list
this.items = [];
//
};
NPGClient.UIMenu.prototype = {
// Constructor
constructor: NPGClient.UIMenu,
//
addItem: function(t) {
var self = this;
self.itemsList.push(t);
},
//
draw: function(ctx) {
var self = this;
var y = self.y
if (self.items !== undefined && self.items.length > 0) {
for (var i = 0; i < self.items.length; i++) {
ctx.font = self.items[i].font;
ctx.fillStyle = self.items[i].col;
ctx.fillText(self.text, self.x, self.y);
}
}
},
};