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

44 lines
852 B
JavaScript
Raw Normal View History

2016-02-13 21:06:40 +01:00
/**
* @file ui_label.js
* @author frtk@tetalab
*/
NPGClient.UILabel = function(n, o) {
// obj name
this.name = n !== undefined ? n : '';
// bkg rect
//this.bkg = r !== undefined ? r : new NPGClient.UIRect();
// pos
this.x = o.x !== undefined ? o.x : 0;
this.y = o.y !== undefined ? o.y : 0;
2016-02-14 00:23:22 +01:00
2016-02-13 21:06:40 +01:00
// text
this.text = o.text !== undefined ? o.text : '';
2016-02-14 00:23:22 +01:00
// text style
this.s = o.style !== undefined ? o.style : new NPGClient.UITextStyle();
2016-02-13 21:06:40 +01:00
};
NPGClient.UILabel.prototype = {
// Constructor
constructor: NPGClient.UILabel,
//
draw: function(ctx) {
var self = this;
//self.rect.draw(ctx);
2016-02-14 00:23:22 +01:00
NPGClient.Utils.setTxtStyle(ctx, self.s);
ctx.fillText(self.text, self.x, self.y);
/*
2016-02-13 21:06:40 +01:00
ctx.font = self.font
ctx.fillStyle = self.col;
ctx.fillText(self.text, self.x, self.y);
2016-02-14 00:23:22 +01:00
*/
2016-02-13 21:06:40 +01:00
}
};