|
| 1 | +var Text = require('./Text'); |
| 2 | +var GetAdvancedValue = require('../../../utils/object/GetAdvancedValue'); |
| 3 | +var BuildGameObject = require('../../BuildGameObject'); |
| 4 | + |
| 5 | +var BuildFromConfig = function (state, config) |
| 6 | +{ |
| 7 | + // style Object = { |
| 8 | + // font: [ 'font', '16px Courier' ], |
| 9 | + // backgroundColor: [ 'backgroundColor', null ], |
| 10 | + // fill: [ 'fill', '#fff' ], |
| 11 | + // stroke: [ 'stroke', '#fff' ], |
| 12 | + // strokeThickness: [ 'strokeThickness', 0 ], |
| 13 | + // shadowOffsetX: [ 'shadow.offsetX', 0 ], |
| 14 | + // shadowOffsetY: [ 'shadow.offsetY', 0 ], |
| 15 | + // shadowColor: [ 'shadow.color', '#000' ], |
| 16 | + // shadowBlur: [ 'shadow.blur', 0 ], |
| 17 | + // shadowStroke: [ 'shadow.stroke', false ], |
| 18 | + // shadowFill: [ 'shadow.fill', false ], |
| 19 | + // align: [ 'align', 'left' ], |
| 20 | + // maxLines: [ 'maxLines', 0 ], |
| 21 | + // fixedWidth: [ 'fixedWidth', false ], |
| 22 | + // fixedHeight: [ 'fixedHeight', false ], |
| 23 | + // rtl: [ 'rtl', false ] |
| 24 | + // } |
| 25 | + |
| 26 | + var content = GetAdvancedValue(config, 'text', ''); |
| 27 | + var style = GetAdvancedValue(config, 'style', null); |
| 28 | + |
| 29 | + var text = new Text(state, 0, 0, content, style); |
| 30 | + |
| 31 | + BuildGameObject(state, text, config); |
| 32 | + |
| 33 | + // Text specific config options: |
| 34 | + |
| 35 | + text.autoRound = GetAdvancedValue(config, 'autoRound', true); |
| 36 | + text.resolution = GetAdvancedValue(config, 'resolution', 1); |
| 37 | + |
| 38 | + return text; |
| 39 | +}; |
| 40 | + |
| 41 | +module.exports = BuildFromConfig; |
0 commit comments