The PlaceOnLine Action now supports ease functions

This commit is contained in:
Robert Kowalski 2024-01-31 15:34:19 -05:00
parent fd1ab35419
commit a48db68b53
2 changed files with 15 additions and 3 deletions

View file

@ -17,6 +17,7 @@
* The `Renderer.Canvas` and `Renderer.WebGL` will now only be included in the build file if the corresponding feature flags `CANVAS_RENDERER` and/or `WEBGL_RENDERER` are set to `true`. For Canvas only builds this saves a lot of space in the build (thanks @samme) * The `Renderer.Canvas` and `Renderer.WebGL` will now only be included in the build file if the corresponding feature flags `CANVAS_RENDERER` and/or `WEBGL_RENDERER` are set to `true`. For Canvas only builds this saves a lot of space in the build (thanks @samme)
* You can now specify an `autoResize` boolean in the `RenderTargetConfig` which is passed to the Render Targets when they are created by a pipeline. * You can now specify an `autoResize` boolean in the `RenderTargetConfig` which is passed to the Render Targets when they are created by a pipeline.
* The `UtilityPipeline` now sets `autoResize` to `true` in its Render Target Config, so that the global `fullFrame` and `halfFrame` Render Targets will automatically resize if the renderer changes. * The `UtilityPipeline` now sets `autoResize` to `true` in its Render Target Config, so that the global `fullFrame` and `halfFrame` Render Targets will automatically resize if the renderer changes.
* `Actions.PlaceOnLine` now has an added an `ease` parameter which accepts a string from the EaseMap or a custom ease function to allow for different distrubutions along a line. (thanks @sB3p)
# Bug Fixes # Bug Fixes

View file

@ -5,9 +5,11 @@
*/ */
var GetPoints = require('../geom/line/GetPoints'); var GetPoints = require('../geom/line/GetPoints');
var GetEasedPoints = require('../geom/line/GetEasedPoints');
/** /**
* Positions an array of Game Objects on evenly spaced points of a Line. * Positions an array of Game Objects on evenly spaced points of a Line.
* If the ease parameter is supplied, it will space the points based on that easing function along the line.
* *
* @function Phaser.Actions.PlaceOnLine * @function Phaser.Actions.PlaceOnLine
* @since 3.0.0 * @since 3.0.0
@ -16,12 +18,21 @@ var GetPoints = require('../geom/line/GetPoints');
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action. * @param {(array|Phaser.GameObjects.GameObject[])} items - An array of Game Objects. The contents of this array are updated by this Action.
* @param {Phaser.Geom.Line} line - The Line to position the Game Objects on. * @param {Phaser.Geom.Line} line - The Line to position the Game Objects on.
* * @param {(string|function)} [ease] - An optional ease to use. This can be either a string from the EaseMap, or a custom function.
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/ */
var PlaceOnLine = function (items, line) var PlaceOnLine = function (items, line, ease)
{ {
var points = GetPoints(line, items.length); var points;
if (ease)
{
points = GetEasedPoints(line, ease, items.length);
}
else
{
points = GetPoints(line, items.length);
}
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {