r3-legacy/src/game-lib-d3-api-text.js

67 lines
1.4 KiB
JavaScript

/**
* Raw Text API object - should always correspond with the Text Schema
* @param id
* @param name
* @param offset
* @param font
* @param fillStyle
* @param value
* @param parentCanvas
* @param parentEntity
* @constructor
*/
GameLib.D3.API.Text = function(
id,
name,
offset,
font,
fillStyle,
value,
parentCanvas,
parentEntity
) {
if (GameLib.Utils.UndefinedOrNull(id)) {
id = GameLib.Utils.RandomId();
}
this.id = id;
if (GameLib.Utils.UndefinedOrNull(name)) {
name = 'Text (' + id + ')';
}
this.name = name;
if (GameLib.Utils.UndefinedOrNull(offset)) {
offset = new GameLib.API.Vector2(0,0);
}
this.offset = offset;
if (GameLib.Utils.UndefinedOrNull(font)) {
font = '10pt Arial';
}
this.font = font;
if (GameLib.Utils.UndefinedOrNull(fillStyle)) {
fillStyle = '#ffffff';
}
this.fillStyle = fillStyle;
if (GameLib.Utils.UndefinedOrNull(value)) {
value = 'Hello';
}
this.value = value;
if (GameLib.Utils.UndefinedOrNull(parentCanvas)) {
parentCanvas = null;
}
this.parentCanvas = parentCanvas;
GameLib.API.Component.call(
this,
GameLib.Component.TEXT,
parentEntity
);
};
GameLib.D3.API.Text.prototype = Object.create(GameLib.API.Component.prototype);
GameLib.D3.API.Text.prototype.constructor = GameLib.D3.API.Text;