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

38 lines
712 B
JavaScript
Raw Normal View History

2016-02-14 07:06:40 +11: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 10:23:22 +11:00
2016-02-14 07:06:40 +11:00
// text
this.text = o.text !== undefined ? o.text : '';
2016-02-14 10:23:22 +11:00
// text style
this.s = o.style !== undefined ? o.style : new NPGClient.UITextStyle();
2016-02-14 07:06:40 +11:00
};
NPGClient.UILabel.prototype = {
// Constructor
constructor: NPGClient.UILabel,
//
draw: function(ctx) {
var self = this;
2016-02-14 14:37:31 +11:00
NPGClient.Utils.setTxtStyle(ctx, self.s);
ctx.fillText(self.text, self.x, self.y);
2016-02-14 07:06:40 +11:00
}
};