Tiny fixes on TextRuntimeObject and its renderers

This commit is contained in:
Florian Rival
2016-03-05 14:38:11 +01:00
parent 0f990cc913
commit c9a0cc9afd
3 changed files with 5 additions and 9 deletions

View File

@@ -4,7 +4,7 @@ gdjs.TextRuntimeObjectCocosRenderer = function(runtimeObject, runtimeScene)
this._text = new cc.LabelTTF(" ", "Arial", 38);
this._text.disableStroke();
var renderer = runtimeScene.getLayer("").getRenderer();
renderer.addRendererObject(this._text, runtimeObject.getZOrder());
this._convertYPosition = renderer.convertYPosition;
@@ -25,7 +25,6 @@ gdjs.TextRuntimeObjectCocosRenderer.prototype.ensureUpToDate = function() {
gdjs.TextRuntimeObjectCocosRenderer.prototype.updateStyle = function() {
this._text.setFontSize(this._object._characterSize);
this._text.setFontName(this._object._fontName);
this._text.setFontFillColor(cc.color(this._object._color[0],
this._object._color[1], this._object._color[2]));
this._text.setFontName(this._object._fontName);

View File

@@ -28,12 +28,12 @@ gdjs.TextRuntimeObjectPixiRenderer.prototype.ensureUpToDate = function() {
};
gdjs.TextRuntimeObjectPixiRenderer.prototype.updateStyle = function() {
style = {align:"left"};
var fontName = "\"gdjs_font_" + this._object._fontName + "\"";
var style = { align:"left" };
style.font = "";
if ( this._object._italic ) style.font += "italic ";
if ( this._object._bold ) style.font += "bold ";
//if ( this._object._underlined ) style.font += "underlined "; Not supported :/
style.font += this._object._characterSize+"px"+" "+this._object._fontName;
style.font += this._object._characterSize + "px " + fontName;
style.fill = "rgb("+this._object._color[0]+","+this._object._color[1]+","+this._object._color[2]+")";
this._text.style = style;
};

View File

@@ -16,14 +16,11 @@ gdjs.TextRuntimeObject = function(runtimeScene, objectData)
gdjs.RuntimeObject.call(this, runtimeScene, objectData);
this._characterSize = objectData.characterSize;
this._fontName = "Arial";
this._fontName = objectData.font || 'Arial';
this._bold = objectData.bold;
this._italic = objectData.italic;
this._underlined = objectData.underlined;
this._color = [objectData.color.r, objectData.color.g, objectData.color.b];
if ( objectData.font !== "" ) {
this._fontName = "\"gdjs_font_"+objectData.font+"\"";
}
this._str = objectData.string;