UNPKG

phaser3-rex-plugins

Version:
58 lines (42 loc) 1.68 kB
import Columns from '../gameobjects/columns/Columns.js'; import CreateTitleLabel from './utils/CreateTitleLabel.js'; import CreateBackground from './utils/CreateBackground.js'; const GetValue = Phaser.Utils.Objects.GetValue; var CreateColumns = function (tweaker, config, style) { if (!config) { config = {}; } if (!style) { style = {}; } var scene = tweaker.scene; // background var background = CreateBackground(scene, (config.background || {}), (style.background || {})); // title var title = CreateTitleLabel(scene, undefined, style.title); // columns, each column has a tweaker panel var tweakerConfig = { root: tweaker.root, styles: tweaker.styles, } var columnConfigArray = GetValue(config, 'columns', 2); if (typeof (columnConfigArray) === 'number') { var columnCount = columnConfigArray; columnConfigArray = []; for (var i = 0, cnt = columnCount; i < cnt; i++) { columnConfigArray.push({}) } } for (var i = 0, cnt = columnConfigArray.length; i < cnt; i++) { var columnConfig = columnConfigArray[i]; tweakerConfig.width = GetValue(columnConfig, 'width', 0) var tweakerChild = tweaker.createTweaker(tweakerConfig); columnConfig.child = tweakerChild; } var columns = new Columns(scene, { title: title, columns: columnConfigArray, background: background, space: style.space, alignTitle: style.root.alignTitle }); scene.add.existing(columns); return columns; } export default CreateColumns;