| 57 | * @category Objects > BBText |
| 58 | */ |
| 59 | export class BBTextRuntimeObject |
| 60 | extends gdjs.RuntimeObject |
| 61 | implements gdjs.OpacityHandler |
| 62 | { |
| 63 | _opacity: float; |
| 64 | |
| 65 | _text: string; |
| 66 | |
| 67 | /** color in format [r, g, b], where each component is in the range [0, 255] */ |
| 68 | _color: integer[]; |
| 69 | _fontFamily: string; |
| 70 | _fontSize: float; |
| 71 | |
| 72 | _wrapping: boolean = false; |
| 73 | _wrappingWidth: float = 250; |
| 74 | |
| 75 | _textAlign: string; |
| 76 | _verticalTextAlignment: string; |
| 77 | |
| 78 | _renderer: gdjs.BBTextRuntimeObjectRenderer; |
| 79 | |
| 80 | // While this should rather be exposed as a property for all objects, honor the "visible" |
| 81 | // property that is specific to this object. |
| 82 | hidden: boolean; |
| 83 | |
| 84 | /** |
| 85 | * @param instanceContainer The container the object belongs to. |
| 86 | * @param objectData The object data used to initialize the object |
| 87 | */ |
| 88 | constructor( |
| 89 | instanceContainer: gdjs.RuntimeInstanceContainer, |
| 90 | objectData: BBTextObjectData, |
| 91 | instanceData?: InstanceData |
| 92 | ) { |
| 93 | super(instanceContainer, objectData, instanceData); |
| 94 | // @ts-ignore - parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string. |
| 95 | this._opacity = parseFloat(objectData.content.opacity); |
| 96 | this._text = objectData.content.text; |
| 97 | this._color = gdjs.rgbOrHexToRGBColor(objectData.content.color); |
| 98 | this._fontFamily = objectData.content.fontFamily; |
| 99 | // @ts-ignore - parseFloat should not be required, but GDevelop 5.0 beta 92 and below were storing it as a string. |
| 100 | this._fontSize = parseFloat(objectData.content.fontSize); |
| 101 | this._textAlign = objectData.content.align; |
| 102 | this._verticalTextAlignment = |
| 103 | objectData.content.verticalTextAlignment || 'top'; |
| 104 | this.hidden = !objectData.content.visible; |
| 105 | |
| 106 | this._renderer = new gdjs.BBTextRuntimeObjectRenderer( |
| 107 | this, |
| 108 | instanceContainer |
| 109 | ); |
| 110 | |
| 111 | // *ALWAYS* call `this.onCreated()` at the very end of your object constructor. |
| 112 | this.onCreated(); |
| 113 | } |
| 114 | |
| 115 | override getRendererObject() { |
| 116 | return this._renderer.getRendererObject(); |
nothing calls this directly
no outgoing calls
no test coverage detected