-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
BottomRight.js
38 lines (33 loc) · 1.37 KB
/
BottomRight.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @author Richard Davey <rich@phaser.io>
* @copyright 2013-2024 Phaser Studio Inc.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var GetBottom = require('../../bounds/GetBottom');
var GetRight = require('../../bounds/GetRight');
var SetBottom = require('../../bounds/SetBottom');
var SetRight = require('../../bounds/SetRight');
/**
* Takes given Game Object and aligns it so that it is positioned in the bottom right of the other.
*
* @function Phaser.Display.Align.In.BottomRight
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return]
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be positioned.
* @param {Phaser.GameObjects.GameObject} alignIn - The Game Object to base the alignment position on.
* @param {number} [offsetX=0] - Optional horizontal offset from the position.
* @param {number} [offsetY=0] - Optional vertical offset from the position.
*
* @return {Phaser.GameObjects.GameObject} The Game Object that was aligned.
*/
var BottomRight = function (gameObject, alignIn, offsetX, offsetY)
{
if (offsetX === undefined) { offsetX = 0; }
if (offsetY === undefined) { offsetY = 0; }
SetRight(gameObject, GetRight(alignIn) + offsetX);
SetBottom(gameObject, GetBottom(alignIn) + offsetY);
return gameObject;
};
module.exports = BottomRight;