UNPKG

phaser

Version:

A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.

30 lines (25 loc) 960 B
/** * @author Richard Davey <rich@photonstorm.com> * @copyright 2018 Photon Storm Ltd. * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} */ /** * Positions the Game Object so that the center top of its bounds aligns with the given coordinate. * * @function Phaser.Display.Bounds.SetCenterY * @since 3.0.0 * * @generic {Phaser.GameObjects.GameObject} G - [gameObject,$return] * * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object that will be re-positioned. * @param {number} y - The coordinate to position the Game Object bounds on. * * @return {Phaser.GameObjects.GameObject} The Game Object that was positioned. */ var SetCenterY = function (gameObject, y) { var offsetY = gameObject.height * gameObject.originY; gameObject.y = (y + offsetY) - (gameObject.height * 0.5); return gameObject; }; module.exports = SetCenterY;