|
| 1 | +/** |
| 2 | + * @author samme |
| 3 | + * @copyright 2019 Photon Storm Ltd. |
| 4 | + * @license {@link https://opensource.org/licenses/MIT|MIT License} |
| 5 | + */ |
| 6 | + |
| 7 | +var ALIGN_CONST = require('../const'); |
| 8 | + |
| 9 | +var AlignToMap = []; |
| 10 | + |
| 11 | +AlignToMap[ALIGN_CONST.BOTTOM_CENTER] = require('./BottomCenter'); |
| 12 | +AlignToMap[ALIGN_CONST.BOTTOM_LEFT] = require('./BottomLeft'); |
| 13 | +AlignToMap[ALIGN_CONST.BOTTOM_RIGHT] = require('./BottomRight'); |
| 14 | +AlignToMap[ALIGN_CONST.LEFT_BOTTOM] = require('./LeftBottom'); |
| 15 | +AlignToMap[ALIGN_CONST.LEFT_CENTER] = require('./LeftCenter'); |
| 16 | +AlignToMap[ALIGN_CONST.LEFT_TOP] = require('./LeftTop'); |
| 17 | +AlignToMap[ALIGN_CONST.RIGHT_BOTTOM] = require('./RightBottom'); |
| 18 | +AlignToMap[ALIGN_CONST.RIGHT_CENTER] = require('./RightCenter'); |
| 19 | +AlignToMap[ALIGN_CONST.RIGHT_TOP] = require('./RightTop'); |
| 20 | +AlignToMap[ALIGN_CONST.TOP_CENTER] = require('./TopCenter'); |
| 21 | +AlignToMap[ALIGN_CONST.TOP_LEFT] = require('./TopLeft'); |
| 22 | +AlignToMap[ALIGN_CONST.TOP_RIGHT] = require('./TopRight'); |
| 23 | + |
| 24 | +/** |
| 25 | + * Takes a Game Object and aligns it next to another, at the given position. |
| 26 | + * The alignment used is based on the `position` argument, which is a `Phaser.Display.Align` property such as `LEFT_CENTER` or `TOP_RIGHT`. |
| 27 | + * |
| 28 | + * @function Phaser.Display.Align.To.QuickSet |
| 29 | + * @since 3.22.0 |
| 30 | + * |
| 31 | + * @generic {Phaser.GameObjects.GameObject} G - [child,$return] |
| 32 | + * |
| 33 | + * @param {Phaser.GameObjects.GameObject} child - The Game Object that will be positioned. |
| 34 | + * @param {Phaser.GameObjects.GameObject} alignTo - The Game Object to base the alignment position on. |
| 35 | + * @param {integer} position - The position to align the Game Object with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`. |
| 36 | + * @param {number} [offsetX=0] - Optional horizontal offset from the position. |
| 37 | + * @param {number} [offsetY=0] - Optional vertical offset from the position. |
| 38 | + * |
| 39 | + * @return {Phaser.GameObjects.GameObject} The Game Object that was aligned. |
| 40 | + */ |
| 41 | +var QuickSet = function (child, alignTo, position, offsetX, offsetY) |
| 42 | +{ |
| 43 | + return AlignToMap[position](child, alignTo, offsetX, offsetY); |
| 44 | +}; |
| 45 | + |
| 46 | +module.exports = QuickSet; |
0 commit comments