This commit is contained in:
svipal 2020-04-10 20:40:52 +02:00
parent 8665e08f13
commit 854589ddbe
1499 changed files with 518809 additions and 317404 deletions

38
.gitignore vendored
View file

@ -1,20 +1,20 @@
# System and IDE files # System and IDE files
Thumbs.db Thumbs.db
.DS_Store .DS_Store
.idea .idea
.vscode .vscode
*.suo *.suo
*.sublime-project *.sublime-project
*.sublime-workspace *.sublime-workspace
# Vendors # Vendors
node_modules/ node_modules/
# Build # Build
/npm-debug.log /npm-debug.log
build/ build/
out/ out/
scripts/tsgen/test/bin/ scripts/tsgen/test/bin/
scripts/tsgen/test/output.txt scripts/tsgen/test/output.txt
plugins/spine/spine-runtimes/ plugins/spine/spine-runtimes/

File diff suppressed because it is too large Load diff

1262
README.md

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

203022
dist/phaser-facebook-instant-games.js vendored Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

23714
dist/phaser.js vendored

File diff suppressed because it is too large Load diff

2
dist/phaser.min.js vendored

File diff suppressed because one or more lines are too long

11246
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,88 +1,88 @@
{ {
"name": "phaser", "name": "phaser",
"version": "3.23.0-beta1", "version": "3.23.0-beta1",
"release": "Ginro", "release": "Ginro",
"description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.", "description": "A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers.",
"author": "Richard Davey <rich@photonstorm.com> (http://www.photonstorm.com)", "author": "Richard Davey <rich@photonstorm.com> (http://www.photonstorm.com)",
"homepage": "http://phaser.io", "homepage": "http://phaser.io",
"bugs": "https://github.com/photonstorm/phaser/issues", "bugs": "https://github.com/photonstorm/phaser/issues",
"license": "MIT", "license": "MIT",
"licenseUrl": "http://www.opensource.org/licenses/mit-license.php", "licenseUrl": "http://www.opensource.org/licenses/mit-license.php",
"main": "./src/phaser.js", "main": "./src/phaser.js",
"types": "./types/phaser.d.ts", "types": "./types/phaser.d.ts",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://photonstorm@github.com/photonstorm/phaser.git" "url": "https://photonstorm@github.com/photonstorm/phaser.git"
}, },
"scripts": { "scripts": {
"beta": "npm publish --tag beta", "beta": "npm publish --tag beta",
"help": "node scripts/help.js", "help": "node scripts/help.js",
"build": "webpack --config config/webpack.config.js", "build": "webpack --config config/webpack.config.js",
"watch": "webpack --watch --config config/webpack.config.js", "watch": "webpack --watch --config config/webpack.config.js",
"buildfb": "webpack --config config/webpack.fb.config.js", "buildfb": "webpack --config config/webpack.fb.config.js",
"watchfb": "webpack --config config/webpack.fb.config.js --watch", "watchfb": "webpack --config config/webpack.fb.config.js --watch",
"dist": "webpack --config config/webpack.dist.config.js", "dist": "webpack --config config/webpack.dist.config.js",
"distT": "webpack --config config/webpack.dist.config.js && npm run toT", "distT": "webpack --config config/webpack.dist.config.js && npm run toT",
"toT": "@powershell Copy-Item ./dist/phaser.min.js ../phasertest/phaser.min.js", "toT": "@powershell Copy-Item ./dist/phaser.min.js ../phasertest/phaser.min.js",
"toT2": "@powershell Copy-Item ./dist/phaser.js ../phasertest/phaser.min.js", "toT2": "@powershell Copy-Item ./dist/phaser.js ../phasertest/phaser.min.js",
"distfb": "webpack --config config/webpack.fb.dist.config.js", "distfb": "webpack --config config/webpack.fb.dist.config.js",
"distfull": "npm run dist && npm run distfb", "distfull": "npm run dist && npm run distfb",
"plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js", "plugin.cam3d": "webpack --config plugins/camera3d/webpack.config.js",
"plugin.spine": "webpack --config plugins/spine/webpack.config.js", "plugin.spine": "webpack --config plugins/spine/webpack.config.js",
"plugin.spine.dist": "webpack --config plugins/spine/webpack.auto.dist.config.js", "plugin.spine.dist": "webpack --config plugins/spine/webpack.auto.dist.config.js",
"plugin.spine.watch": "webpack --config plugins/spine/webpack.auto.config.js --watch --display-modules", "plugin.spine.watch": "webpack --config plugins/spine/webpack.auto.config.js --watch --display-modules",
"plugin.spine.dev": "webpack --config plugins/spine/webpack.auto.config.js", "plugin.spine.dev": "webpack --config plugins/spine/webpack.auto.config.js",
"plugin.spine.canvas.dist": "webpack --config plugins/spine/webpack.canvas.dist.config.js", "plugin.spine.canvas.dist": "webpack --config plugins/spine/webpack.canvas.dist.config.js",
"plugin.spine.canvas.watch": "webpack --config plugins/spine/webpack.canvas.config.js --watch --display-modules", "plugin.spine.canvas.watch": "webpack --config plugins/spine/webpack.canvas.config.js --watch --display-modules",
"plugin.spine.canvas.dev": "webpack --config plugins/spine/webpack.canvas.config.js", "plugin.spine.canvas.dev": "webpack --config plugins/spine/webpack.canvas.config.js",
"plugin.spine.webgl.dist": "webpack --config plugins/spine/webpack.webgl.dist.config.js", "plugin.spine.webgl.dist": "webpack --config plugins/spine/webpack.webgl.dist.config.js",
"plugin.spine.webgl.watch": "webpack --config plugins/spine/webpack.webgl.config.js --watch --display-modules", "plugin.spine.webgl.watch": "webpack --config plugins/spine/webpack.webgl.config.js --watch --display-modules",
"plugin.spine.webgl.dev": "webpack --config plugins/spine/webpack.webgl.config.js", "plugin.spine.webgl.dev": "webpack --config plugins/spine/webpack.webgl.config.js",
"plugin.spine.full": "npm run plugin.spine.dev && npm run plugin.spine.canvas.dev && npm run plugin.spine.webgl.dev", "plugin.spine.full": "npm run plugin.spine.dev && npm run plugin.spine.canvas.dev && npm run plugin.spine.webgl.dev",
"plugin.spine.full.dist": "npm run plugin.spine.dist && npm run plugin.spine.canvas.dist && npm run plugin.spine.webgl.dist", "plugin.spine.full.dist": "npm run plugin.spine.dist && npm run plugin.spine.canvas.dist && npm run plugin.spine.webgl.dist",
"lint": "eslint --config .eslintrc.json \"src/**/*.js\"", "lint": "eslint --config .eslintrc.json \"src/**/*.js\"",
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix", "lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",
"sloc": "node-sloc \"./src\" --include-extensions \"js\"", "sloc": "node-sloc \"./src\" --include-extensions \"js\"",
"bundleshaders": "node scripts/bundle-shaders.js", "bundleshaders": "node scripts/bundle-shaders.js",
"postinstall": "node scripts/support.js", "postinstall": "node scripts/support.js",
"build-tsgen": "cd scripts/tsgen && tsc", "build-tsgen": "cd scripts/tsgen && tsc",
"tsgen": "cd scripts/tsgen && jsdoc -c jsdoc-tsd.conf.json", "tsgen": "cd scripts/tsgen && jsdoc -c jsdoc-tsd.conf.json",
"test-ts": "cd scripts/tsgen/test && tsc > output.txt", "test-ts": "cd scripts/tsgen/test && tsc > output.txt",
"ts": "npm run tsgen && npm run test-ts", "ts": "npm run tsgen && npm run test-ts",
"tsdev": "npm run build-tsgen && npm run tsgen && npm run test-ts" "tsdev": "npm run build-tsgen && npm run tsgen && npm run test-ts"
}, },
"keywords": [ "keywords": [
"2d", "2d",
"HTML5", "HTML5",
"WebGL", "WebGL",
"canvas", "canvas",
"game", "game",
"javascript", "javascript",
"physics", "physics",
"tweens", "tweens",
"typescript", "typescript",
"web audio" "web audio"
], ],
"devDependencies": { "devDependencies": {
"clean-webpack-plugin": "^0.1.19", "clean-webpack-plugin": "^0.1.19",
"dts-dom": "^3.3.0", "dts-dom": "^3.3.0",
"eslint": "^4.19.1", "eslint": "^4.19.1",
"eslint-plugin-es5": "^1.3.1", "eslint-plugin-es5": "^1.3.1",
"fs-extra": "^6.0.1", "fs-extra": "^6.0.1",
"jsdoc": "^3.6.3", "jsdoc": "^3.6.3",
"node-sloc": "^0.1.11", "node-sloc": "^0.1.11",
"remove-files-webpack-plugin": "^1.1.3", "remove-files-webpack-plugin": "^1.1.3",
"typescript": "^3.4.5", "typescript": "^3.4.5",
"uglifyjs-webpack-plugin": "^1.3.0", "uglifyjs-webpack-plugin": "^1.3.0",
"vivid-cli": "^1.1.2", "vivid-cli": "^1.1.2",
"webpack": "^4.23.0", "webpack": "^4.23.0",
"webpack-cli": "^3.1.1", "webpack-cli": "^3.1.1",
"webpack-shell-plugin": "^0.5.0" "webpack-shell-plugin": "^0.5.0"
}, },
"dependencies": { "dependencies": {
"eventemitter3": "^3.1.0", "eventemitter3": "^3.1.0",
"exports-loader": "^0.7.0", "exports-loader": "^0.7.0",
"imports-loader": "^0.8.0", "imports-loader": "^0.8.0",
"path": "^0.12.7" "path": "^0.12.7"
} }
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,73 +1,73 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Collision Types - Determine if and how entities collide with each other. * Collision Types - Determine if and how entities collide with each other.
* *
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
* collisions, both entities are moved. LITE or PASSIVE entities don't collide * collisions, both entities are moved. LITE or PASSIVE entities don't collide
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs. * with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined. * FIXED collisions is undefined.
* *
* @namespace Phaser.Physics.Impact.COLLIDES * @namespace Phaser.Physics.Impact.COLLIDES
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @since 3.0.0 * @since 3.0.0
*/ */
module.exports = { module.exports = {
/** /**
* Never collides. * Never collides.
* *
* @name Phaser.Physics.Impact.COLLIDES.NEVER * @name Phaser.Physics.Impact.COLLIDES.NEVER
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
NEVER: 0, NEVER: 0,
/** /**
* Lite collision. * Lite collision.
* *
* @name Phaser.Physics.Impact.COLLIDES.LITE * @name Phaser.Physics.Impact.COLLIDES.LITE
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
LITE: 1, LITE: 1,
/** /**
* Passive collision. * Passive collision.
* *
* @name Phaser.Physics.Impact.COLLIDES.PASSIVE * @name Phaser.Physics.Impact.COLLIDES.PASSIVE
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
PASSIVE: 2, PASSIVE: 2,
/** /**
* Active collision. * Active collision.
* *
* @name Phaser.Physics.Impact.COLLIDES.ACTIVE * @name Phaser.Physics.Impact.COLLIDES.ACTIVE
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
ACTIVE: 4, ACTIVE: 4,
/** /**
* Fixed collision. * Fixed collision.
* *
* @name Phaser.Physics.Impact.COLLIDES.FIXED * @name Phaser.Physics.Impact.COLLIDES.FIXED
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
FIXED: 8 FIXED: 8
}; };

View file

@ -1,358 +1,358 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
var DefaultDefs = require('./DefaultDefs'); var DefaultDefs = require('./DefaultDefs');
/** /**
* @classdesc * @classdesc
* [description] * [description]
* *
* @class CollisionMap * @class CollisionMap
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @constructor * @constructor
* @since 3.0.0 * @since 3.0.0
* *
* @param {integer} [tilesize=32] - [description] * @param {integer} [tilesize=32] - [description]
* @param {array} [data] - [description] * @param {array} [data] - [description]
*/ */
var CollisionMap = new Class({ var CollisionMap = new Class({
initialize: initialize:
function CollisionMap (tilesize, data) function CollisionMap (tilesize, data)
{ {
if (tilesize === undefined) { tilesize = 32; } if (tilesize === undefined) { tilesize = 32; }
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.CollisionMap#tilesize * @name Phaser.Physics.Impact.CollisionMap#tilesize
* @type {integer} * @type {integer}
* @default 32 * @default 32
* @since 3.0.0 * @since 3.0.0
*/ */
this.tilesize = tilesize; this.tilesize = tilesize;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.CollisionMap#data * @name Phaser.Physics.Impact.CollisionMap#data
* @type {array} * @type {array}
* @since 3.0.0 * @since 3.0.0
*/ */
this.data = (Array.isArray(data)) ? data : []; this.data = (Array.isArray(data)) ? data : [];
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.CollisionMap#width * @name Phaser.Physics.Impact.CollisionMap#width
* @type {number} * @type {number}
* @since 3.0.0 * @since 3.0.0
*/ */
this.width = (Array.isArray(data)) ? data[0].length : 0; this.width = (Array.isArray(data)) ? data[0].length : 0;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.CollisionMap#height * @name Phaser.Physics.Impact.CollisionMap#height
* @type {number} * @type {number}
* @since 3.0.0 * @since 3.0.0
*/ */
this.height = (Array.isArray(data)) ? data.length : 0; this.height = (Array.isArray(data)) ? data.length : 0;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.CollisionMap#lastSlope * @name Phaser.Physics.Impact.CollisionMap#lastSlope
* @type {integer} * @type {integer}
* @default 55 * @default 55
* @since 3.0.0 * @since 3.0.0
*/ */
this.lastSlope = 55; this.lastSlope = 55;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.CollisionMap#tiledef * @name Phaser.Physics.Impact.CollisionMap#tiledef
* @type {object} * @type {object}
* @since 3.0.0 * @since 3.0.0
*/ */
this.tiledef = DefaultDefs; this.tiledef = DefaultDefs;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.CollisionMap#trace * @method Phaser.Physics.Impact.CollisionMap#trace
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {number} x - [description]
* @param {number} y - [description] * @param {number} y - [description]
* @param {number} vx - [description] * @param {number} vx - [description]
* @param {number} vy - [description] * @param {number} vy - [description]
* @param {number} objectWidth - [description] * @param {number} objectWidth - [description]
* @param {number} objectHeight - [description] * @param {number} objectHeight - [description]
* *
* @return {boolean} [description] * @return {boolean} [description]
*/ */
trace: function (x, y, vx, vy, objectWidth, objectHeight) trace: function (x, y, vx, vy, objectWidth, objectHeight)
{ {
// Set up the trace-result // Set up the trace-result
var res = { var res = {
collision: { x: false, y: false, slope: false }, collision: { x: false, y: false, slope: false },
pos: { x: x + vx, y: y + vy }, pos: { x: x + vx, y: y + vy },
tile: { x: 0, y: 0 } tile: { x: 0, y: 0 }
}; };
if (!this.data) if (!this.data)
{ {
return res; return res;
} }
var steps = Math.ceil(Math.max(Math.abs(vx), Math.abs(vy)) / this.tilesize); var steps = Math.ceil(Math.max(Math.abs(vx), Math.abs(vy)) / this.tilesize);
if (steps > 1) if (steps > 1)
{ {
var sx = vx / steps; var sx = vx / steps;
var sy = vy / steps; var sy = vy / steps;
for (var i = 0; i < steps && (sx || sy); i++) for (var i = 0; i < steps && (sx || sy); i++)
{ {
this.step(res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i); this.step(res, x, y, sx, sy, objectWidth, objectHeight, vx, vy, i);
x = res.pos.x; x = res.pos.x;
y = res.pos.y; y = res.pos.y;
if (res.collision.x) if (res.collision.x)
{ {
sx = 0; sx = 0;
vx = 0; vx = 0;
} }
if (res.collision.y) if (res.collision.y)
{ {
sy = 0; sy = 0;
vy = 0; vy = 0;
} }
if (res.collision.slope) if (res.collision.slope)
{ {
break; break;
} }
} }
} }
else else
{ {
this.step(res, x, y, vx, vy, objectWidth, objectHeight, vx, vy, 0); this.step(res, x, y, vx, vy, objectWidth, objectHeight, vx, vy, 0);
} }
return res; return res;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.CollisionMap#step * @method Phaser.Physics.Impact.CollisionMap#step
* @since 3.0.0 * @since 3.0.0
* *
* @param {object} res - [description] * @param {object} res - [description]
* @param {number} x - [description] * @param {number} x - [description]
* @param {number} y - [description] * @param {number} y - [description]
* @param {number} vx - [description] * @param {number} vx - [description]
* @param {number} vy - [description] * @param {number} vy - [description]
* @param {number} width - [description] * @param {number} width - [description]
* @param {number} height - [description] * @param {number} height - [description]
* @param {number} rvx - [description] * @param {number} rvx - [description]
* @param {number} rvy - [description] * @param {number} rvy - [description]
* @param {number} step - [description] * @param {number} step - [description]
*/ */
step: function (res, x, y, vx, vy, width, height, rvx, rvy, step) step: function (res, x, y, vx, vy, width, height, rvx, rvy, step)
{ {
var t = 0; var t = 0;
var tileX; var tileX;
var tileY; var tileY;
var tilesize = this.tilesize; var tilesize = this.tilesize;
var mapWidth = this.width; var mapWidth = this.width;
var mapHeight = this.height; var mapHeight = this.height;
// Horizontal // Horizontal
if (vx) if (vx)
{ {
var pxOffsetX = (vx > 0 ? width : 0); var pxOffsetX = (vx > 0 ? width : 0);
var tileOffsetX = (vx < 0 ? tilesize : 0); var tileOffsetX = (vx < 0 ? tilesize : 0);
var firstTileY = Math.max(Math.floor(y / tilesize), 0); var firstTileY = Math.max(Math.floor(y / tilesize), 0);
var lastTileY = Math.min(Math.ceil((y + height) / tilesize), mapHeight); var lastTileY = Math.min(Math.ceil((y + height) / tilesize), mapHeight);
tileX = Math.floor((res.pos.x + pxOffsetX) / tilesize); tileX = Math.floor((res.pos.x + pxOffsetX) / tilesize);
var prevTileX = Math.floor((x + pxOffsetX) / tilesize); var prevTileX = Math.floor((x + pxOffsetX) / tilesize);
if (step > 0 || tileX === prevTileX || prevTileX < 0 || prevTileX >= mapWidth) if (step > 0 || tileX === prevTileX || prevTileX < 0 || prevTileX >= mapWidth)
{ {
prevTileX = -1; prevTileX = -1;
} }
if (tileX >= 0 && tileX < mapWidth) if (tileX >= 0 && tileX < mapWidth)
{ {
for (tileY = firstTileY; tileY < lastTileY; tileY++) for (tileY = firstTileY; tileY < lastTileY; tileY++)
{ {
if (prevTileX !== -1) if (prevTileX !== -1)
{ {
t = this.data[tileY][prevTileX]; t = this.data[tileY][prevTileX];
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY)) if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, prevTileX, tileY))
{ {
break; break;
} }
} }
t = this.data[tileY][tileX]; t = this.data[tileY][tileX];
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
{ {
if (t > 1 && t <= this.lastSlope && res.collision.slope) if (t > 1 && t <= this.lastSlope && res.collision.slope)
{ {
break; break;
} }
res.collision.x = true; res.collision.x = true;
res.tile.x = t; res.tile.x = t;
res.pos.x = (tileX * tilesize) - pxOffsetX + tileOffsetX; res.pos.x = (tileX * tilesize) - pxOffsetX + tileOffsetX;
x = res.pos.x; x = res.pos.x;
rvx = 0; rvx = 0;
break; break;
} }
} }
} }
} }
// Vertical // Vertical
if (vy) if (vy)
{ {
var pxOffsetY = (vy > 0 ? height : 0); var pxOffsetY = (vy > 0 ? height : 0);
var tileOffsetY = (vy < 0 ? tilesize : 0); var tileOffsetY = (vy < 0 ? tilesize : 0);
var firstTileX = Math.max(Math.floor(res.pos.x / tilesize), 0); var firstTileX = Math.max(Math.floor(res.pos.x / tilesize), 0);
var lastTileX = Math.min(Math.ceil((res.pos.x + width) / tilesize), mapWidth); var lastTileX = Math.min(Math.ceil((res.pos.x + width) / tilesize), mapWidth);
tileY = Math.floor((res.pos.y + pxOffsetY) / tilesize); tileY = Math.floor((res.pos.y + pxOffsetY) / tilesize);
var prevTileY = Math.floor((y + pxOffsetY) / tilesize); var prevTileY = Math.floor((y + pxOffsetY) / tilesize);
if (step > 0 || tileY === prevTileY || prevTileY < 0 || prevTileY >= mapHeight) if (step > 0 || tileY === prevTileY || prevTileY < 0 || prevTileY >= mapHeight)
{ {
prevTileY = -1; prevTileY = -1;
} }
if (tileY >= 0 && tileY < mapHeight) if (tileY >= 0 && tileY < mapHeight)
{ {
for (tileX = firstTileX; tileX < lastTileX; tileX++) for (tileX = firstTileX; tileX < lastTileX; tileX++)
{ {
if (prevTileY !== -1) if (prevTileY !== -1)
{ {
t = this.data[prevTileY][tileX]; t = this.data[prevTileY][tileX];
if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY)) if (t > 1 && t <= this.lastSlope && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, prevTileY))
{ {
break; break;
} }
} }
t = this.data[tileY][tileX]; t = this.data[tileY][tileX];
if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY))) if (t === 1 || t > this.lastSlope || (t > 1 && this.checkDef(res, t, x, y, rvx, rvy, width, height, tileX, tileY)))
{ {
if (t > 1 && t <= this.lastSlope && res.collision.slope) if (t > 1 && t <= this.lastSlope && res.collision.slope)
{ {
break; break;
} }
res.collision.y = true; res.collision.y = true;
res.tile.y = t; res.tile.y = t;
res.pos.y = tileY * tilesize - pxOffsetY + tileOffsetY; res.pos.y = tileY * tilesize - pxOffsetY + tileOffsetY;
break; break;
} }
} }
} }
} }
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.CollisionMap#checkDef * @method Phaser.Physics.Impact.CollisionMap#checkDef
* @since 3.0.0 * @since 3.0.0
* *
* @param {object} res - [description] * @param {object} res - [description]
* @param {number} t - [description] * @param {number} t - [description]
* @param {number} x - [description] * @param {number} x - [description]
* @param {number} y - [description] * @param {number} y - [description]
* @param {number} vx - [description] * @param {number} vx - [description]
* @param {number} vy - [description] * @param {number} vy - [description]
* @param {number} width - [description] * @param {number} width - [description]
* @param {number} height - [description] * @param {number} height - [description]
* @param {number} tileX - [description] * @param {number} tileX - [description]
* @param {number} tileY - [description] * @param {number} tileY - [description]
* *
* @return {boolean} [description] * @return {boolean} [description]
*/ */
checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY) checkDef: function (res, t, x, y, vx, vy, width, height, tileX, tileY)
{ {
var def = this.tiledef[t]; var def = this.tiledef[t];
if (!def) if (!def)
{ {
return false; return false;
} }
var tilesize = this.tilesize; var tilesize = this.tilesize;
var lx = (tileX + def[0]) * tilesize; var lx = (tileX + def[0]) * tilesize;
var ly = (tileY + def[1]) * tilesize; var ly = (tileY + def[1]) * tilesize;
var lvx = (def[2] - def[0]) * tilesize; var lvx = (def[2] - def[0]) * tilesize;
var lvy = (def[3] - def[1]) * tilesize; var lvy = (def[3] - def[1]) * tilesize;
var solid = def[4]; var solid = def[4];
var tx = x + vx + (lvy < 0 ? width : 0) - lx; var tx = x + vx + (lvy < 0 ? width : 0) - lx;
var ty = y + vy + (lvx > 0 ? height : 0) - ly; var ty = y + vy + (lvx > 0 ? height : 0) - ly;
if (lvx * ty - lvy * tx > 0) if (lvx * ty - lvy * tx > 0)
{ {
if (vx * -lvy + vy * lvx < 0) if (vx * -lvy + vy * lvx < 0)
{ {
return solid; return solid;
} }
var length = Math.sqrt(lvx * lvx + lvy * lvy); var length = Math.sqrt(lvx * lvx + lvy * lvy);
var nx = lvy / length; var nx = lvy / length;
var ny = -lvx / length; var ny = -lvx / length;
var proj = tx * nx + ty * ny; var proj = tx * nx + ty * ny;
var px = nx * proj; var px = nx * proj;
var py = ny * proj; var py = ny * proj;
if (px * px + py * py >= vx * vx + vy * vy) if (px * px + py * py >= vx * vx + vy * vy)
{ {
return solid || (lvx * (ty - vy) - lvy * (tx - vx) < 0.5); return solid || (lvx * (ty - vy) - lvy * (tx - vx) < 0.5);
} }
res.pos.x = x + vx - px; res.pos.x = x + vx - px;
res.pos.y = y + vy - py; res.pos.y = y + vy - py;
res.collision.slope = { x: lvx, y: lvy, nx: nx, ny: ny }; res.collision.slope = { x: lvx, y: lvy, nx: nx, ny: ny };
return true; return true;
} }
return false; return false;
} }
}); });
module.exports = CollisionMap; module.exports = CollisionMap;

View file

@ -1,65 +1,65 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var H = 0.5; var H = 0.5;
var N = 1 / 3; var N = 1 / 3;
var M = 2 / 3; var M = 2 / 3;
// Tile ID to Slope defs. // Tile ID to Slope defs.
// First 4 elements = line data, final = solid or non-solid behind the line // First 4 elements = line data, final = solid or non-solid behind the line
module.exports = { module.exports = {
2: [ 0, 1, 1, 0, true ], 2: [ 0, 1, 1, 0, true ],
3: [ 0, 1, 1, H, true ], 3: [ 0, 1, 1, H, true ],
4: [ 0, H, 1, 0, true ], 4: [ 0, H, 1, 0, true ],
5: [ 0, 1, 1, M, true ], 5: [ 0, 1, 1, M, true ],
6: [ 0, M, 1, N, true ], 6: [ 0, M, 1, N, true ],
7: [ 0, N, 1, 0, true ], 7: [ 0, N, 1, 0, true ],
8: [ H, 1, 0, 0, true ], 8: [ H, 1, 0, 0, true ],
9: [ 1, 0, H, 1, true ], 9: [ 1, 0, H, 1, true ],
10: [ H, 1, 1, 0, true ], 10: [ H, 1, 1, 0, true ],
11: [ 0, 0, H, 1, true ], 11: [ 0, 0, H, 1, true ],
12: [ 0, 0, 1, 0, false ], 12: [ 0, 0, 1, 0, false ],
13: [ 1, 1, 0, 0, true ], 13: [ 1, 1, 0, 0, true ],
14: [ 1, H, 0, 0, true ], 14: [ 1, H, 0, 0, true ],
15: [ 1, 1, 0, H, true ], 15: [ 1, 1, 0, H, true ],
16: [ 1, N, 0, 0, true ], 16: [ 1, N, 0, 0, true ],
17: [ 1, M, 0, N, true ], 17: [ 1, M, 0, N, true ],
18: [ 1, 1, 0, M, true ], 18: [ 1, 1, 0, M, true ],
19: [ 1, 1, H, 0, true ], 19: [ 1, 1, H, 0, true ],
20: [ H, 0, 0, 1, true ], 20: [ H, 0, 0, 1, true ],
21: [ 0, 1, H, 0, true ], 21: [ 0, 1, H, 0, true ],
22: [ H, 0, 1, 1, true ], 22: [ H, 0, 1, 1, true ],
23: [ 1, 1, 0, 1, false ], 23: [ 1, 1, 0, 1, false ],
24: [ 0, 0, 1, 1, true ], 24: [ 0, 0, 1, 1, true ],
25: [ 0, 0, 1, H, true ], 25: [ 0, 0, 1, H, true ],
26: [ 0, H, 1, 1, true ], 26: [ 0, H, 1, 1, true ],
27: [ 0, 0, 1, N, true ], 27: [ 0, 0, 1, N, true ],
28: [ 0, N, 1, M, true ], 28: [ 0, N, 1, M, true ],
29: [ 0, M, 1, 1, true ], 29: [ 0, M, 1, 1, true ],
30: [ N, 1, 0, 0, true ], 30: [ N, 1, 0, 0, true ],
31: [ 1, 0, M, 1, true ], 31: [ 1, 0, M, 1, true ],
32: [ M, 1, 1, 0, true ], 32: [ M, 1, 1, 0, true ],
33: [ 0, 0, N, 1, true ], 33: [ 0, 0, N, 1, true ],
34: [ 1, 0, 1, 1, false ], 34: [ 1, 0, 1, 1, false ],
35: [ 1, 0, 0, 1, true ], 35: [ 1, 0, 0, 1, true ],
36: [ 1, H, 0, 1, true ], 36: [ 1, H, 0, 1, true ],
37: [ 1, 0, 0, H, true ], 37: [ 1, 0, 0, H, true ],
38: [ 1, M, 0, 1, true ], 38: [ 1, M, 0, 1, true ],
39: [ 1, N, 0, M, true ], 39: [ 1, N, 0, M, true ],
40: [ 1, 0, 0, N, true ], 40: [ 1, 0, 0, N, true ],
41: [ M, 1, N, 0, true ], 41: [ M, 1, N, 0, true ],
42: [ M, 0, N, 1, true ], 42: [ M, 0, N, 1, true ],
43: [ N, 1, M, 0, true ], 43: [ N, 1, M, 0, true ],
44: [ N, 0, M, 1, true ], 44: [ N, 0, M, 1, true ],
45: [ 0, 1, 0, 0, false ], 45: [ 0, 1, 0, 0, false ],
52: [ 1, 1, M, 0, true ], 52: [ 1, 1, M, 0, true ],
53: [ N, 0, 0, 1, true ], 53: [ N, 0, 0, 1, true ],
54: [ 0, 1, N, 0, true ], 54: [ 0, 1, N, 0, true ],
55: [ M, 0, 1, 1, true ] 55: [ M, 0, 1, 1, true ]
}; };

View file

@ -1,151 +1,151 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
var ImpactBody = require('./ImpactBody'); var ImpactBody = require('./ImpactBody');
var ImpactImage = require('./ImpactImage'); var ImpactImage = require('./ImpactImage');
var ImpactSprite = require('./ImpactSprite'); var ImpactSprite = require('./ImpactSprite');
/** /**
* @classdesc * @classdesc
* The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects. * The Impact Physics Factory allows you to easily create Impact Physics enabled Game Objects.
* Objects that are created by this Factory are automatically added to the physics world. * Objects that are created by this Factory are automatically added to the physics world.
* *
* @class Factory * @class Factory
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @constructor * @constructor
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world. * @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world.
*/ */
var Factory = new Class({ var Factory = new Class({
initialize: initialize:
function Factory (world) function Factory (world)
{ {
/** /**
* A reference to the Impact Physics world. * A reference to the Impact Physics world.
* *
* @name Phaser.Physics.Impact.Factory#world * @name Phaser.Physics.Impact.Factory#world
* @type {Phaser.Physics.Impact.World} * @type {Phaser.Physics.Impact.World}
* @since 3.0.0 * @since 3.0.0
*/ */
this.world = world; this.world = world;
/** /**
* A reference to the Scene.Systems this Impact Physics instance belongs to. * A reference to the Scene.Systems this Impact Physics instance belongs to.
* *
* @name Phaser.Physics.Impact.Factory#sys * @name Phaser.Physics.Impact.Factory#sys
* @type {Phaser.Scenes.Systems} * @type {Phaser.Scenes.Systems}
* @since 3.0.0 * @since 3.0.0
*/ */
this.sys = world.scene.sys; this.sys = world.scene.sys;
}, },
/** /**
* Creates a new ImpactBody object and adds it to the physics simulation. * Creates a new ImpactBody object and adds it to the physics simulation.
* *
* @method Phaser.Physics.Impact.Factory#body * @method Phaser.Physics.Impact.Factory#body
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The horizontal position of the body in the physics world. * @param {number} x - The horizontal position of the body in the physics world.
* @param {number} y - The vertical position of the body in the physics world. * @param {number} y - The vertical position of the body in the physics world.
* @param {number} width - The width of the body. * @param {number} width - The width of the body.
* @param {number} height - The height of the body. * @param {number} height - The height of the body.
* *
* @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created. * @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created.
*/ */
body: function (x, y, width, height) body: function (x, y, width, height)
{ {
return new ImpactBody(this.world, x, y, width, height); return new ImpactBody(this.world, x, y, width, height);
}, },
/** /**
* Adds an Impact Physics Body to the given Game Object. * Adds an Impact Physics Body to the given Game Object.
* *
* @method Phaser.Physics.Impact.Factory#existing * @method Phaser.Physics.Impact.Factory#existing
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body. * @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body.
* *
* @return {Phaser.GameObjects.GameObject} The Game Object. * @return {Phaser.GameObjects.GameObject} The Game Object.
*/ */
existing: function (gameObject) existing: function (gameObject)
{ {
var x = gameObject.x - gameObject.frame.centerX; var x = gameObject.x - gameObject.frame.centerX;
var y = gameObject.y - gameObject.frame.centerY; var y = gameObject.y - gameObject.frame.centerY;
var w = gameObject.width; var w = gameObject.width;
var h = gameObject.height; var h = gameObject.height;
gameObject.body = this.world.create(x, y, w, h); gameObject.body = this.world.create(x, y, w, h);
gameObject.body.parent = gameObject; gameObject.body.parent = gameObject;
gameObject.body.gameObject = gameObject; gameObject.body.gameObject = gameObject;
return gameObject; return gameObject;
}, },
/** /**
* Creates a new ImpactImage object and adds it to the physics world. * Creates a new ImpactImage object and adds it to the physics world.
* *
* @method Phaser.Physics.Impact.Factory#image * @method Phaser.Physics.Impact.Factory#image
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The horizontal position of this Game Object in the world. * @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world.
* @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
* *
* @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created. * @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created.
*/ */
image: function (x, y, key, frame) image: function (x, y, key, frame)
{ {
var image = new ImpactImage(this.world, x, y, key, frame); var image = new ImpactImage(this.world, x, y, key, frame);
this.sys.displayList.add(image); this.sys.displayList.add(image);
return image; return image;
}, },
/** /**
* Creates a new ImpactSprite object and adds it to the physics world. * Creates a new ImpactSprite object and adds it to the physics world.
* *
* @method Phaser.Physics.Impact.Factory#sprite * @method Phaser.Physics.Impact.Factory#sprite
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The horizontal position of this Game Object in the world. * @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world.
* @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {string} key - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
* *
* @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created. * @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created.
*/ */
sprite: function (x, y, key, frame) sprite: function (x, y, key, frame)
{ {
var sprite = new ImpactSprite(this.world, x, y, key, frame); var sprite = new ImpactSprite(this.world, x, y, key, frame);
this.sys.displayList.add(sprite); this.sys.displayList.add(sprite);
this.sys.updateList.add(sprite); this.sys.updateList.add(sprite);
return sprite; return sprite;
}, },
/** /**
* Destroys this Factory. * Destroys this Factory.
* *
* @method Phaser.Physics.Impact.Factory#destroy * @method Phaser.Physics.Impact.Factory#destroy
* @since 3.5.0 * @since 3.5.0
*/ */
destroy: function () destroy: function ()
{ {
this.world = null; this.world = null;
this.sys = null; this.sys = null;
} }
}); });
module.exports = Factory; module.exports = Factory;

View file

@ -1,50 +1,50 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Clamp = require('../../math/Clamp'); var Clamp = require('../../math/Clamp');
/** /**
* [description] * [description]
* *
* @function Phaser.Physics.Impact.GetVelocity * @function Phaser.Physics.Impact.GetVelocity
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * @param {number} delta - The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate.
* @param {number} vel - [description] * @param {number} vel - [description]
* @param {number} accel - [description] * @param {number} accel - [description]
* @param {number} friction - [description] * @param {number} friction - [description]
* @param {number} max - [description] * @param {number} max - [description]
* *
* @return {number} [description] * @return {number} [description]
*/ */
var GetVelocity = function (delta, vel, accel, friction, max) var GetVelocity = function (delta, vel, accel, friction, max)
{ {
if (accel) if (accel)
{ {
return Clamp(vel + accel * delta, -max, max); return Clamp(vel + accel * delta, -max, max);
} }
else if (friction) else if (friction)
{ {
var frictionDelta = friction * delta; var frictionDelta = friction * delta;
if (vel - frictionDelta > 0) if (vel - frictionDelta > 0)
{ {
return vel - frictionDelta; return vel - frictionDelta;
} }
else if (vel + frictionDelta < 0) else if (vel + frictionDelta < 0)
{ {
return vel + frictionDelta; return vel + frictionDelta;
} }
else else
{ {
return 0; return 0;
} }
} }
return Clamp(vel, -max, max); return Clamp(vel, -max, max);
}; };
module.exports = GetVelocity; module.exports = GetVelocity;

View file

@ -1,127 +1,127 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
var Components = require('./components'); var Components = require('./components');
/** /**
* @classdesc * @classdesc
* [description] * [description]
* *
* @class ImpactBody * @class ImpactBody
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @constructor * @constructor
* @since 3.0.0 * @since 3.0.0
* *
* @extends Phaser.Physics.Impact.Components.Acceleration * @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale * @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType * @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce * @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst * @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides * @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug * @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction * @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity * @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset * @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject * @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity * @extends Phaser.Physics.Impact.Components.Velocity
* *
* @param {Phaser.Physics.Impact.World} world - [description] * @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - x - The horizontal position of this physics body in the world. * @param {number} x - x - The horizontal position of this physics body in the world.
* @param {number} y - y - The vertical position of this physics body in the world. * @param {number} y - y - The vertical position of this physics body in the world.
* @param {number} width - The width of the physics body in the world. * @param {number} width - The width of the physics body in the world.
* @param {number} height - [description] * @param {number} height - [description]
*/ */
var ImpactBody = new Class({ var ImpactBody = new Class({
Mixins: [ Mixins: [
Components.Acceleration, Components.Acceleration,
Components.BodyScale, Components.BodyScale,
Components.BodyType, Components.BodyType,
Components.Bounce, Components.Bounce,
Components.CheckAgainst, Components.CheckAgainst,
Components.Collides, Components.Collides,
Components.Debug, Components.Debug,
Components.Friction, Components.Friction,
Components.Gravity, Components.Gravity,
Components.Offset, Components.Offset,
Components.SetGameObject, Components.SetGameObject,
Components.Velocity Components.Velocity
], ],
initialize: initialize:
function ImpactBody (world, x, y, width, height) function ImpactBody (world, x, y, width, height)
{ {
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactBody#body * @name Phaser.Physics.Impact.ImpactBody#body
* @type {Phaser.Physics.Impact.Body} * @type {Phaser.Physics.Impact.Body}
* @since 3.0.0 * @since 3.0.0
*/ */
this.body = world.create(x, y, width, height); this.body = world.create(x, y, width, height);
this.body.parent = this; this.body.parent = this;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactBody#size * @name Phaser.Physics.Impact.ImpactBody#size
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.size = this.body.size; this.size = this.body.size;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactBody#offset * @name Phaser.Physics.Impact.ImpactBody#offset
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.offset = this.body.offset; this.offset = this.body.offset;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactBody#vel * @name Phaser.Physics.Impact.ImpactBody#vel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.vel = this.body.vel; this.vel = this.body.vel;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactBody#accel * @name Phaser.Physics.Impact.ImpactBody#accel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.accel = this.body.accel; this.accel = this.body.accel;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactBody#friction * @name Phaser.Physics.Impact.ImpactBody#friction
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.friction = this.body.friction; this.friction = this.body.friction;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactBody#maxVel * @name Phaser.Physics.Impact.ImpactBody#maxVel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.maxVel = this.body.maxVel; this.maxVel = this.body.maxVel;
} }
}); });
module.exports = ImpactBody; module.exports = ImpactBody;

View file

@ -1,152 +1,152 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
var Components = require('./components'); var Components = require('./components');
var Image = require('../../gameobjects/image/Image'); var Image = require('../../gameobjects/image/Image');
/** /**
* @classdesc * @classdesc
* An Impact Physics Image Game Object. * An Impact Physics Image Game Object.
* *
* An Image is a light-weight Game Object useful for the display of static images in your game, * An Image is a light-weight Game Object useful for the display of static images in your game,
* such as logos, backgrounds, scenery or other non-animated elements. Images can have input * such as logos, backgrounds, scenery or other non-animated elements. Images can have input
* events and physics bodies, or be tweened, tinted or scrolled. The main difference between an * events and physics bodies, or be tweened, tinted or scrolled. The main difference between an
* Image and a Sprite is that you cannot animate an Image as they do not have the Animation component. * Image and a Sprite is that you cannot animate an Image as they do not have the Animation component.
* *
* @class ImpactImage * @class ImpactImage
* @extends Phaser.GameObjects.Image * @extends Phaser.GameObjects.Image
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @constructor * @constructor
* @since 3.0.0 * @since 3.0.0
* *
* @extends Phaser.Physics.Impact.Components.Acceleration * @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale * @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType * @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce * @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst * @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides * @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug * @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction * @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity * @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset * @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject * @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity * @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode * @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds * @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin * @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor * @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size * @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture * @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible * @extends Phaser.GameObjects.Components.Visible
* *
* @param {Phaser.Physics.Impact.World} world - The physics world of the Impact physics system. * @param {Phaser.Physics.Impact.World} world - The physics world of the Impact physics system.
* @param {number} x - The horizontal position of this Game Object in the world. * @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/ */
var ImpactImage = new Class({ var ImpactImage = new Class({
Extends: Image, Extends: Image,
Mixins: [ Mixins: [
Components.Acceleration, Components.Acceleration,
Components.BodyScale, Components.BodyScale,
Components.BodyType, Components.BodyType,
Components.Bounce, Components.Bounce,
Components.CheckAgainst, Components.CheckAgainst,
Components.Collides, Components.Collides,
Components.Debug, Components.Debug,
Components.Friction, Components.Friction,
Components.Gravity, Components.Gravity,
Components.Offset, Components.Offset,
Components.SetGameObject, Components.SetGameObject,
Components.Velocity Components.Velocity
], ],
initialize: initialize:
function ImpactImage (world, x, y, texture, frame) function ImpactImage (world, x, y, texture, frame)
{ {
Image.call(this, world.scene, x, y, texture, frame); Image.call(this, world.scene, x, y, texture, frame);
/** /**
* The Physics Body linked to an ImpactImage. * The Physics Body linked to an ImpactImage.
* *
* @name Phaser.Physics.Impact.ImpactImage#body * @name Phaser.Physics.Impact.ImpactImage#body
* @type {Phaser.Physics.Impact.Body} * @type {Phaser.Physics.Impact.Body}
* @since 3.0.0 * @since 3.0.0
*/ */
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this; this.body.parent = this;
this.body.gameObject = this; this.body.gameObject = this;
/** /**
* The size of the physics Body. * The size of the physics Body.
* *
* @name Phaser.Physics.Impact.ImpactImage#size * @name Phaser.Physics.Impact.ImpactImage#size
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.size = this.body.size; this.size = this.body.size;
/** /**
* The X and Y offset of the Body from the left and top of the Image. * The X and Y offset of the Body from the left and top of the Image.
* *
* @name Phaser.Physics.Impact.ImpactImage#offset * @name Phaser.Physics.Impact.ImpactImage#offset
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.offset = this.body.offset; this.offset = this.body.offset;
/** /**
* The velocity, or rate of change the Body's position. Measured in pixels per second. * The velocity, or rate of change the Body's position. Measured in pixels per second.
* *
* @name Phaser.Physics.Impact.ImpactImage#vel * @name Phaser.Physics.Impact.ImpactImage#vel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.vel = this.body.vel; this.vel = this.body.vel;
/** /**
* The acceleration is the rate of change of the velocity. Measured in pixels per second squared. * The acceleration is the rate of change of the velocity. Measured in pixels per second squared.
* *
* @name Phaser.Physics.Impact.ImpactImage#accel * @name Phaser.Physics.Impact.ImpactImage#accel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.accel = this.body.accel; this.accel = this.body.accel;
/** /**
* Friction between colliding bodies. * Friction between colliding bodies.
* *
* @name Phaser.Physics.Impact.ImpactImage#friction * @name Phaser.Physics.Impact.ImpactImage#friction
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.friction = this.body.friction; this.friction = this.body.friction;
/** /**
* The maximum velocity of the body. * The maximum velocity of the body.
* *
* @name Phaser.Physics.Impact.ImpactImage#maxVel * @name Phaser.Physics.Impact.ImpactImage#maxVel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.maxVel = this.body.maxVel; this.maxVel = this.body.maxVel;
} }
}); });
module.exports = ImpactImage; module.exports = ImpactImage;

View file

@ -1,211 +1,211 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
var Factory = require('./Factory'); var Factory = require('./Factory');
var GetFastValue = require('../../utils/object/GetFastValue'); var GetFastValue = require('../../utils/object/GetFastValue');
var Merge = require('../../utils/object/Merge'); var Merge = require('../../utils/object/Merge');
var PluginCache = require('../../plugins/PluginCache'); var PluginCache = require('../../plugins/PluginCache');
var SceneEvents = require('../../scene/events'); var SceneEvents = require('../../scene/events');
var World = require('./World'); var World = require('./World');
/** /**
* @classdesc * @classdesc
* [description] * [description]
* *
* @class ImpactPhysics * @class ImpactPhysics
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @constructor * @constructor
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Scene} scene - [description] * @param {Phaser.Scene} scene - [description]
*/ */
var ImpactPhysics = new Class({ var ImpactPhysics = new Class({
initialize: initialize:
function ImpactPhysics (scene) function ImpactPhysics (scene)
{ {
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactPhysics#scene * @name Phaser.Physics.Impact.ImpactPhysics#scene
* @type {Phaser.Scene} * @type {Phaser.Scene}
* @since 3.0.0 * @since 3.0.0
*/ */
this.scene = scene; this.scene = scene;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactPhysics#systems * @name Phaser.Physics.Impact.ImpactPhysics#systems
* @type {Phaser.Scenes.Systems} * @type {Phaser.Scenes.Systems}
* @since 3.0.0 * @since 3.0.0
*/ */
this.systems = scene.sys; this.systems = scene.sys;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactPhysics#config * @name Phaser.Physics.Impact.ImpactPhysics#config
* @type {object} * @type {object}
* @since 3.0.0 * @since 3.0.0
*/ */
this.config = this.getConfig(); this.config = this.getConfig();
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactPhysics#world * @name Phaser.Physics.Impact.ImpactPhysics#world
* @type {Phaser.Physics.Impact.World} * @type {Phaser.Physics.Impact.World}
* @since 3.0.0 * @since 3.0.0
*/ */
this.world; this.world;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactPhysics#add * @name Phaser.Physics.Impact.ImpactPhysics#add
* @type {Phaser.Physics.Impact.Factory} * @type {Phaser.Physics.Impact.Factory}
* @since 3.0.0 * @since 3.0.0
*/ */
this.add; this.add;
scene.sys.events.once(SceneEvents.BOOT, this.boot, this); scene.sys.events.once(SceneEvents.BOOT, this.boot, this);
scene.sys.events.on(SceneEvents.START, this.start, this); scene.sys.events.on(SceneEvents.START, this.start, this);
}, },
/** /**
* This method is called automatically, only once, when the Scene is first created. * This method is called automatically, only once, when the Scene is first created.
* Do not invoke it directly. * Do not invoke it directly.
* *
* @method Phaser.Physics.Impact.ImpactPhysics#boot * @method Phaser.Physics.Impact.ImpactPhysics#boot
* @private * @private
* @since 3.5.1 * @since 3.5.1
*/ */
boot: function () boot: function ()
{ {
this.world = new World(this.scene, this.config); this.world = new World(this.scene, this.config);
this.add = new Factory(this.world); this.add = new Factory(this.world);
this.systems.events.once(SceneEvents.DESTROY, this.destroy, this); this.systems.events.once(SceneEvents.DESTROY, this.destroy, this);
}, },
/** /**
* This method is called automatically by the Scene when it is starting up. * This method is called automatically by the Scene when it is starting up.
* It is responsible for creating local systems, properties and listening for Scene events. * It is responsible for creating local systems, properties and listening for Scene events.
* Do not invoke it directly. * Do not invoke it directly.
* *
* @method Phaser.Physics.Impact.ImpactPhysics#start * @method Phaser.Physics.Impact.ImpactPhysics#start
* @private * @private
* @since 3.5.0 * @since 3.5.0
*/ */
start: function () start: function ()
{ {
if (!this.world) if (!this.world)
{ {
this.world = new World(this.scene, this.config); this.world = new World(this.scene, this.config);
this.add = new Factory(this.world); this.add = new Factory(this.world);
} }
var eventEmitter = this.systems.events; var eventEmitter = this.systems.events;
eventEmitter.on(SceneEvents.UPDATE, this.world.update, this.world); eventEmitter.on(SceneEvents.UPDATE, this.world.update, this.world);
eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this); eventEmitter.once(SceneEvents.SHUTDOWN, this.shutdown, this);
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.ImpactPhysics#getConfig * @method Phaser.Physics.Impact.ImpactPhysics#getConfig
* @since 3.0.0 * @since 3.0.0
* *
* @return {object} [description] * @return {object} [description]
*/ */
getConfig: function () getConfig: function ()
{ {
var gameConfig = this.systems.game.config.physics; var gameConfig = this.systems.game.config.physics;
var sceneConfig = this.systems.settings.physics; var sceneConfig = this.systems.settings.physics;
var config = Merge( var config = Merge(
GetFastValue(sceneConfig, 'impact', {}), GetFastValue(sceneConfig, 'impact', {}),
GetFastValue(gameConfig, 'impact', {}) GetFastValue(gameConfig, 'impact', {})
); );
return config; return config;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.ImpactPhysics#pause * @method Phaser.Physics.Impact.ImpactPhysics#pause
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.Physics.Impact.World} The Impact World object. * @return {Phaser.Physics.Impact.World} The Impact World object.
*/ */
pause: function () pause: function ()
{ {
return this.world.pause(); return this.world.pause();
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.ImpactPhysics#resume * @method Phaser.Physics.Impact.ImpactPhysics#resume
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.Physics.Impact.World} The Impact World object. * @return {Phaser.Physics.Impact.World} The Impact World object.
*/ */
resume: function () resume: function ()
{ {
return this.world.resume(); return this.world.resume();
}, },
/** /**
* The Scene that owns this plugin is shutting down. * The Scene that owns this plugin is shutting down.
* We need to kill and reset all internal properties as well as stop listening to Scene events. * We need to kill and reset all internal properties as well as stop listening to Scene events.
* *
* @method Phaser.Physics.Impact.ImpactPhysics#shutdown * @method Phaser.Physics.Impact.ImpactPhysics#shutdown
* @private * @private
* @since 3.0.0 * @since 3.0.0
*/ */
shutdown: function () shutdown: function ()
{ {
var eventEmitter = this.systems.events; var eventEmitter = this.systems.events;
eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world); eventEmitter.off(SceneEvents.UPDATE, this.world.update, this.world);
eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this); eventEmitter.off(SceneEvents.SHUTDOWN, this.shutdown, this);
this.add.destroy(); this.add.destroy();
this.world.destroy(); this.world.destroy();
this.add = null; this.add = null;
this.world = null; this.world = null;
}, },
/** /**
* The Scene that owns this plugin is being destroyed. * The Scene that owns this plugin is being destroyed.
* We need to shutdown and then kill off all external references. * We need to shutdown and then kill off all external references.
* *
* @method Phaser.Physics.Impact.ImpactPhysics#destroy * @method Phaser.Physics.Impact.ImpactPhysics#destroy
* @private * @private
* @since 3.0.0 * @since 3.0.0
*/ */
destroy: function () destroy: function ()
{ {
this.shutdown(); this.shutdown();
this.scene.sys.events.off(SceneEvents.START, this.start, this); this.scene.sys.events.off(SceneEvents.START, this.start, this);
this.scene = null; this.scene = null;
this.systems = null; this.systems = null;
} }
}); });
PluginCache.register('ImpactPhysics', ImpactPhysics, 'impactPhysics'); PluginCache.register('ImpactPhysics', ImpactPhysics, 'impactPhysics');
module.exports = ImpactPhysics; module.exports = ImpactPhysics;

View file

@ -1,155 +1,155 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Class = require('../../utils/Class'); var Class = require('../../utils/Class');
var Components = require('./components'); var Components = require('./components');
var Sprite = require('../../gameobjects/sprite/Sprite'); var Sprite = require('../../gameobjects/sprite/Sprite');
/** /**
* @classdesc * @classdesc
* An Impact Physics Sprite Game Object. * An Impact Physics Sprite Game Object.
* *
* A Sprite Game Object is used for the display of both static and animated images in your game. * A Sprite Game Object is used for the display of both static and animated images in your game.
* Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled * Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled
* and animated. * and animated.
* *
* The main difference between a Sprite and an Image Game Object is that you cannot animate Images. * The main difference between a Sprite and an Image Game Object is that you cannot animate Images.
* As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation * As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation
* Component. If you do not require animation then you can safely use Images to replace Sprites in all cases. * Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
* *
* @class ImpactSprite * @class ImpactSprite
* @extends Phaser.GameObjects.Sprite * @extends Phaser.GameObjects.Sprite
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @constructor * @constructor
* @since 3.0.0 * @since 3.0.0
* *
* @extends Phaser.Physics.Impact.Components.Acceleration * @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale * @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType * @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce * @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst * @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides * @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug * @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction * @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity * @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset * @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject * @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity * @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha * @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode * @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth * @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip * @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds * @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin * @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline * @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor * @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size * @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture * @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint * @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform * @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible * @extends Phaser.GameObjects.Components.Visible
* *
* @param {Phaser.Physics.Impact.World} world - [description] * @param {Phaser.Physics.Impact.World} world - [description]
* @param {number} x - The horizontal position of this Game Object in the world. * @param {number} x - The horizontal position of this Game Object in the world.
* @param {number} y - The vertical position of this Game Object in the world. * @param {number} y - The vertical position of this Game Object in the world.
* @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param {string} texture - The key of the Texture this Game Object will use to render with, as stored in the Texture Manager.
* @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with. * @param {(string|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/ */
var ImpactSprite = new Class({ var ImpactSprite = new Class({
Extends: Sprite, Extends: Sprite,
Mixins: [ Mixins: [
Components.Acceleration, Components.Acceleration,
Components.BodyScale, Components.BodyScale,
Components.BodyType, Components.BodyType,
Components.Bounce, Components.Bounce,
Components.CheckAgainst, Components.CheckAgainst,
Components.Collides, Components.Collides,
Components.Debug, Components.Debug,
Components.Friction, Components.Friction,
Components.Gravity, Components.Gravity,
Components.Offset, Components.Offset,
Components.SetGameObject, Components.SetGameObject,
Components.Velocity Components.Velocity
], ],
initialize: initialize:
function ImpactSprite (world, x, y, texture, frame) function ImpactSprite (world, x, y, texture, frame)
{ {
Sprite.call(this, world.scene, x, y, texture, frame); Sprite.call(this, world.scene, x, y, texture, frame);
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactSprite#body * @name Phaser.Physics.Impact.ImpactSprite#body
* @type {Phaser.Physics.Impact.Body} * @type {Phaser.Physics.Impact.Body}
* @since 3.0.0 * @since 3.0.0
*/ */
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height); this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this; this.body.parent = this;
this.body.gameObject = this; this.body.gameObject = this;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactSprite#size * @name Phaser.Physics.Impact.ImpactSprite#size
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.size = this.body.size; this.size = this.body.size;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactSprite#offset * @name Phaser.Physics.Impact.ImpactSprite#offset
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.offset = this.body.offset; this.offset = this.body.offset;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactSprite#vel * @name Phaser.Physics.Impact.ImpactSprite#vel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.vel = this.body.vel; this.vel = this.body.vel;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactSprite#accel * @name Phaser.Physics.Impact.ImpactSprite#accel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.accel = this.body.accel; this.accel = this.body.accel;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactSprite#friction * @name Phaser.Physics.Impact.ImpactSprite#friction
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.friction = this.body.friction; this.friction = this.body.friction;
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.ImpactSprite#maxVel * @name Phaser.Physics.Impact.ImpactSprite#maxVel
* @type {{x: number, y: number}} * @type {{x: number, y: number}}
* @since 3.0.0 * @since 3.0.0
*/ */
this.maxVel = this.body.maxVel; this.maxVel = this.body.maxVel;
} }
}); });
module.exports = ImpactSprite; module.exports = ImpactSprite;

View file

@ -1,50 +1,50 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* [description] * [description]
* *
* @function Phaser.Physics.Impact.SeparateX * @function Phaser.Physics.Impact.SeparateX
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Physics.Impact.World} world - [description] * @param {Phaser.Physics.Impact.World} world - [description]
* @param {Phaser.Physics.Impact.Body} left - [description] * @param {Phaser.Physics.Impact.Body} left - [description]
* @param {Phaser.Physics.Impact.Body} right - [description] * @param {Phaser.Physics.Impact.Body} right - [description]
* @param {Phaser.Physics.Impact.Body} [weak] - [description] * @param {Phaser.Physics.Impact.Body} [weak] - [description]
*/ */
var SeparateX = function (world, left, right, weak) var SeparateX = function (world, left, right, weak)
{ {
var nudge = left.pos.x + left.size.x - right.pos.x; var nudge = left.pos.x + left.size.x - right.pos.x;
// We have a weak entity, so just move this one // We have a weak entity, so just move this one
if (weak) if (weak)
{ {
var strong = (left === weak) ? right : left; var strong = (left === weak) ? right : left;
weak.vel.x = -weak.vel.x * weak.bounciness + strong.vel.x; weak.vel.x = -weak.vel.x * weak.bounciness + strong.vel.x;
var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, weak === left ? -nudge : nudge, 0, weak.size.x, weak.size.y); var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, weak === left ? -nudge : nudge, 0, weak.size.x, weak.size.y);
weak.pos.x = resWeak.pos.x; weak.pos.x = resWeak.pos.x;
} }
else else
{ {
var v2 = (left.vel.x - right.vel.x) / 2; var v2 = (left.vel.x - right.vel.x) / 2;
left.vel.x = -v2; left.vel.x = -v2;
right.vel.x = v2; right.vel.x = v2;
var resLeft = world.collisionMap.trace(left.pos.x, left.pos.y, -nudge / 2, 0, left.size.x, left.size.y); var resLeft = world.collisionMap.trace(left.pos.x, left.pos.y, -nudge / 2, 0, left.size.x, left.size.y);
left.pos.x = Math.floor(resLeft.pos.x); left.pos.x = Math.floor(resLeft.pos.x);
var resRight = world.collisionMap.trace(right.pos.x, right.pos.y, nudge / 2, 0, right.size.x, right.size.y); var resRight = world.collisionMap.trace(right.pos.x, right.pos.y, nudge / 2, 0, right.size.x, right.size.y);
right.pos.x = Math.ceil(resRight.pos.x); right.pos.x = Math.ceil(resRight.pos.x);
} }
}; };
module.exports = SeparateX; module.exports = SeparateX;

View file

@ -1,79 +1,79 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* [description] * [description]
* *
* @function Phaser.Physics.Impact.SeparateY * @function Phaser.Physics.Impact.SeparateY
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Physics.Impact.World} world - [description] * @param {Phaser.Physics.Impact.World} world - [description]
* @param {Phaser.Physics.Impact.Body} top - [description] * @param {Phaser.Physics.Impact.Body} top - [description]
* @param {Phaser.Physics.Impact.Body} bottom - [description] * @param {Phaser.Physics.Impact.Body} bottom - [description]
* @param {Phaser.Physics.Impact.Body} [weak] - [description] * @param {Phaser.Physics.Impact.Body} [weak] - [description]
*/ */
var SeparateY = function (world, top, bottom, weak) var SeparateY = function (world, top, bottom, weak)
{ {
var nudge = (top.pos.y + top.size.y - bottom.pos.y); var nudge = (top.pos.y + top.size.y - bottom.pos.y);
var nudgeX; var nudgeX;
var resTop; var resTop;
if (weak) if (weak)
{ {
var strong = (top === weak) ? bottom : top; var strong = (top === weak) ? bottom : top;
weak.vel.y = -weak.vel.y * weak.bounciness + strong.vel.y; weak.vel.y = -weak.vel.y * weak.bounciness + strong.vel.y;
// Riding on a platform? // Riding on a platform?
nudgeX = 0; nudgeX = 0;
if (weak === top && Math.abs(weak.vel.y - strong.vel.y) < weak.minBounceVelocity) if (weak === top && Math.abs(weak.vel.y - strong.vel.y) < weak.minBounceVelocity)
{ {
weak.standing = true; weak.standing = true;
nudgeX = strong.vel.x * world.delta; nudgeX = strong.vel.x * world.delta;
} }
var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, nudgeX, weak === top ? -nudge : nudge, weak.size.x, weak.size.y); var resWeak = world.collisionMap.trace(weak.pos.x, weak.pos.y, nudgeX, weak === top ? -nudge : nudge, weak.size.x, weak.size.y);
weak.pos.y = resWeak.pos.y; weak.pos.y = resWeak.pos.y;
weak.pos.x = resWeak.pos.x; weak.pos.x = resWeak.pos.x;
} }
else if (world.gravity && (bottom.standing || top.vel.y > 0)) else if (world.gravity && (bottom.standing || top.vel.y > 0))
{ {
resTop = world.collisionMap.trace(top.pos.x, top.pos.y, 0, -(top.pos.y + top.size.y - bottom.pos.y), top.size.x, top.size.y); resTop = world.collisionMap.trace(top.pos.x, top.pos.y, 0, -(top.pos.y + top.size.y - bottom.pos.y), top.size.x, top.size.y);
top.pos.y = resTop.pos.y; top.pos.y = resTop.pos.y;
if (top.bounciness > 0 && top.vel.y > top.minBounceVelocity) if (top.bounciness > 0 && top.vel.y > top.minBounceVelocity)
{ {
top.vel.y *= -top.bounciness; top.vel.y *= -top.bounciness;
} }
else else
{ {
top.standing = true; top.standing = true;
top.vel.y = 0; top.vel.y = 0;
} }
} }
else else
{ {
var v2 = (top.vel.y - bottom.vel.y) / 2; var v2 = (top.vel.y - bottom.vel.y) / 2;
top.vel.y = -v2; top.vel.y = -v2;
bottom.vel.y = v2; bottom.vel.y = v2;
nudgeX = bottom.vel.x * world.delta; nudgeX = bottom.vel.x * world.delta;
resTop = world.collisionMap.trace(top.pos.x, top.pos.y, nudgeX, -nudge / 2, top.size.x, top.size.y); resTop = world.collisionMap.trace(top.pos.x, top.pos.y, nudgeX, -nudge / 2, top.size.x, top.size.y);
top.pos.y = resTop.pos.y; top.pos.y = resTop.pos.y;
var resBottom = world.collisionMap.trace(bottom.pos.x, bottom.pos.y, 0, nudge / 2, bottom.size.x, bottom.size.y); var resBottom = world.collisionMap.trace(bottom.pos.x, bottom.pos.y, 0, nudge / 2, bottom.size.x, bottom.size.y);
bottom.pos.y = resBottom.pos.y; bottom.pos.y = resBottom.pos.y;
} }
}; };
module.exports = SeparateY; module.exports = SeparateY;

View file

@ -1,70 +1,70 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var COLLIDES = require('./COLLIDES'); var COLLIDES = require('./COLLIDES');
var Events = require('./events'); var Events = require('./events');
var SeparateX = require('./SeparateX'); var SeparateX = require('./SeparateX');
var SeparateY = require('./SeparateY'); var SeparateY = require('./SeparateY');
/** /**
* Impact Physics Solver * Impact Physics Solver
* *
* @function Phaser.Physics.Impact.Solver * @function Phaser.Physics.Impact.Solver
* @fires Phaser.Physics.Impact.Events#COLLIDE * @fires Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Physics.Impact.World} world - The Impact simulation to run the solver in. * @param {Phaser.Physics.Impact.World} world - The Impact simulation to run the solver in.
* @param {Phaser.Physics.Impact.Body} bodyA - The first body in the collision. * @param {Phaser.Physics.Impact.Body} bodyA - The first body in the collision.
* @param {Phaser.Physics.Impact.Body} bodyB - The second body in the collision. * @param {Phaser.Physics.Impact.Body} bodyB - The second body in the collision.
*/ */
var Solver = function (world, bodyA, bodyB) var Solver = function (world, bodyA, bodyB)
{ {
var weak = null; var weak = null;
if (bodyA.collides === COLLIDES.LITE || bodyB.collides === COLLIDES.FIXED) if (bodyA.collides === COLLIDES.LITE || bodyB.collides === COLLIDES.FIXED)
{ {
weak = bodyA; weak = bodyA;
} }
else if (bodyB.collides === COLLIDES.LITE || bodyA.collides === COLLIDES.FIXED) else if (bodyB.collides === COLLIDES.LITE || bodyA.collides === COLLIDES.FIXED)
{ {
weak = bodyB; weak = bodyB;
} }
if (bodyA.last.x + bodyA.size.x > bodyB.last.x && bodyA.last.x < bodyB.last.x + bodyB.size.x) if (bodyA.last.x + bodyA.size.x > bodyB.last.x && bodyA.last.x < bodyB.last.x + bodyB.size.x)
{ {
if (bodyA.last.y < bodyB.last.y) if (bodyA.last.y < bodyB.last.y)
{ {
SeparateY(world, bodyA, bodyB, weak); SeparateY(world, bodyA, bodyB, weak);
} }
else else
{ {
SeparateY(world, bodyB, bodyA, weak); SeparateY(world, bodyB, bodyA, weak);
} }
bodyA.collideWith(bodyB, 'y'); bodyA.collideWith(bodyB, 'y');
bodyB.collideWith(bodyA, 'y'); bodyB.collideWith(bodyA, 'y');
world.emit(Events.COLLIDE, bodyA, bodyB, 'y'); world.emit(Events.COLLIDE, bodyA, bodyB, 'y');
} }
else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y) else if (bodyA.last.y + bodyA.size.y > bodyB.last.y && bodyA.last.y < bodyB.last.y + bodyB.size.y)
{ {
if (bodyA.last.x < bodyB.last.x) if (bodyA.last.x < bodyB.last.x)
{ {
SeparateX(world, bodyA, bodyB, weak); SeparateX(world, bodyA, bodyB, weak);
} }
else else
{ {
SeparateX(world, bodyB, bodyA, weak); SeparateX(world, bodyB, bodyA, weak);
} }
bodyA.collideWith(bodyB, 'x'); bodyA.collideWith(bodyB, 'x');
bodyB.collideWith(bodyA, 'x'); bodyB.collideWith(bodyA, 'x');
world.emit(Events.COLLIDE, bodyA, bodyB, 'x'); world.emit(Events.COLLIDE, bodyA, bodyB, 'x');
} }
}; };
module.exports = Solver; module.exports = Solver;

View file

@ -1,62 +1,62 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Collision Types - Determine if and how entities collide with each other. * Collision Types - Determine if and how entities collide with each other.
* *
* In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves, * In ACTIVE vs. LITE or FIXED vs. ANY collisions, only the "weak" entity moves,
* while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE * while the other one stays fixed. In ACTIVE vs. ACTIVE and ACTIVE vs. PASSIVE
* collisions, both entities are moved. LITE or PASSIVE entities don't collide * collisions, both entities are moved. LITE or PASSIVE entities don't collide
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs. * with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined. * FIXED collisions is undefined.
* *
* @namespace Phaser.Physics.Impact.TYPE * @namespace Phaser.Physics.Impact.TYPE
* @memberof Phaser.Physics.Impact * @memberof Phaser.Physics.Impact
* @since 3.0.0 * @since 3.0.0
*/ */
module.exports = { module.exports = {
/** /**
* Collides with nothing. * Collides with nothing.
* *
* @name Phaser.Physics.Impact.TYPE.NONE * @name Phaser.Physics.Impact.TYPE.NONE
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
NONE: 0, NONE: 0,
/** /**
* Type A. Collides with Type B. * Type A. Collides with Type B.
* *
* @name Phaser.Physics.Impact.TYPE.A * @name Phaser.Physics.Impact.TYPE.A
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
A: 1, A: 1,
/** /**
* Type B. Collides with Type A. * Type B. Collides with Type A.
* *
* @name Phaser.Physics.Impact.TYPE.B * @name Phaser.Physics.Impact.TYPE.B
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
B: 2, B: 2,
/** /**
* Collides with both types A and B. * Collides with both types A and B.
* *
* @name Phaser.Physics.Impact.TYPE.BOTH * @name Phaser.Physics.Impact.TYPE.BOTH
* @type {integer} * @type {integer}
* @const * @const
* @since 3.0.0 * @since 3.0.0
*/ */
BOTH: 3 BOTH: 3
}; };

View file

@ -1,89 +1,89 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Set up the trace-result * Set up the trace-result
* var res = { * var res = {
* collision: {x: false, y: false, slope: false}, * collision: {x: false, y: false, slope: false},
* pos: {x: x, y: y}, * pos: {x: x, y: y},
* tile: {x: 0, y: 0} * tile: {x: 0, y: 0}
* }; * };
* *
* @function Phaser.Physics.Impact.UpdateMotion * @function Phaser.Physics.Impact.UpdateMotion
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Physics.Impact.Body} body - [description] * @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} res - [description] * @param {object} res - [description]
*/ */
var UpdateMotion = function (body, res) var UpdateMotion = function (body, res)
{ {
body.standing = false; body.standing = false;
// Y // Y
if (res.collision.y) if (res.collision.y)
{ {
if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity) if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity)
{ {
body.vel.y *= -body.bounciness; body.vel.y *= -body.bounciness;
} }
else else
{ {
if (body.vel.y > 0) if (body.vel.y > 0)
{ {
body.standing = true; body.standing = true;
} }
body.vel.y = 0; body.vel.y = 0;
} }
} }
// X // X
if (res.collision.x) if (res.collision.x)
{ {
if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity) if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity)
{ {
body.vel.x *= -body.bounciness; body.vel.x *= -body.bounciness;
} }
else else
{ {
body.vel.x = 0; body.vel.x = 0;
} }
} }
// SLOPE // SLOPE
if (res.collision.slope) if (res.collision.slope)
{ {
var s = res.collision.slope; var s = res.collision.slope;
if (body.bounciness > 0) if (body.bounciness > 0)
{ {
var proj = body.vel.x * s.nx + body.vel.y * s.ny; var proj = body.vel.x * s.nx + body.vel.y * s.ny;
body.vel.x = (body.vel.x - s.nx * proj * 2) * body.bounciness; body.vel.x = (body.vel.x - s.nx * proj * 2) * body.bounciness;
body.vel.y = (body.vel.y - s.ny * proj * 2) * body.bounciness; body.vel.y = (body.vel.y - s.ny * proj * 2) * body.bounciness;
} }
else else
{ {
var lengthSquared = s.x * s.x + s.y * s.y; var lengthSquared = s.x * s.x + s.y * s.y;
var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared; var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared;
body.vel.x = s.x * dot; body.vel.x = s.x * dot;
body.vel.y = s.y * dot; body.vel.y = s.y * dot;
var angle = Math.atan2(s.x, s.y); var angle = Math.atan2(s.x, s.y);
if (angle > body.slopeStanding.min && angle < body.slopeStanding.max) if (angle > body.slopeStanding.min && angle < body.slopeStanding.max)
{ {
body.standing = true; body.standing = true;
} }
} }
} }
body.pos.x = res.pos.x; body.pos.x = res.pos.x;
body.pos.y = res.pos.y; body.pos.y = res.pos.y;
}; };
module.exports = UpdateMotion; module.exports = UpdateMotion;

File diff suppressed because it is too large Load diff

View file

@ -1,71 +1,71 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Acceleration component. * The Impact Acceleration component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Acceleration * @namespace Phaser.Physics.Impact.Components.Acceleration
* @since 3.0.0 * @since 3.0.0
*/ */
var Acceleration = { var Acceleration = {
/** /**
* Sets the horizontal acceleration of this body. * Sets the horizontal acceleration of this body.
* *
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The amount of acceleration to apply. * @param {number} x - The amount of acceleration to apply.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setAccelerationX: function (x) setAccelerationX: function (x)
{ {
this.accel.x = x; this.accel.x = x;
return this; return this;
}, },
/** /**
* Sets the vertical acceleration of this body. * Sets the vertical acceleration of this body.
* *
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY * @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} y - The amount of acceleration to apply. * @param {number} y - The amount of acceleration to apply.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setAccelerationY: function (y) setAccelerationY: function (y)
{ {
this.accel.y = y; this.accel.y = y;
return this; return this;
}, },
/** /**
* Sets the horizontal and vertical acceleration of this body. * Sets the horizontal and vertical acceleration of this body.
* *
* @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration * @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The amount of horizontal acceleration to apply. * @param {number} x - The amount of horizontal acceleration to apply.
* @param {number} y - The amount of vertical acceleration to apply. * @param {number} y - The amount of vertical acceleration to apply.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setAcceleration: function (x, y) setAcceleration: function (x, y)
{ {
this.accel.x = x; this.accel.x = x;
this.accel.y = y; this.accel.y = y;
return this; return this;
} }
}; };
module.exports = Acceleration; module.exports = Acceleration;

View file

@ -1,68 +1,68 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Body Scale component. * The Impact Body Scale component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.BodyScale * @namespace Phaser.Physics.Impact.Components.BodyScale
* @since 3.0.0 * @since 3.0.0
*/ */
var BodyScale = { var BodyScale = {
/** /**
* Sets the size of the physics body. * Sets the size of the physics body.
* *
* @method Phaser.Physics.Impact.Components.BodyScale#setBodySize * @method Phaser.Physics.Impact.Components.BodyScale#setBodySize
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} width - The width of the body in pixels. * @param {number} width - The width of the body in pixels.
* @param {number} [height=width] - The height of the body in pixels. * @param {number} [height=width] - The height of the body in pixels.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setBodySize: function (width, height) setBodySize: function (width, height)
{ {
if (height === undefined) { height = width; } if (height === undefined) { height = width; }
this.body.size.x = Math.round(width); this.body.size.x = Math.round(width);
this.body.size.y = Math.round(height); this.body.size.y = Math.round(height);
return this; return this;
}, },
/** /**
* Sets the scale of the physics body. * Sets the scale of the physics body.
* *
* @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale * @method Phaser.Physics.Impact.Components.BodyScale#setBodyScale
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} scaleX - The horizontal scale of the body. * @param {number} scaleX - The horizontal scale of the body.
* @param {number} [scaleY] - The vertical scale of the body. If not given, will use the horizontal scale value. * @param {number} [scaleY] - The vertical scale of the body. If not given, will use the horizontal scale value.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setBodyScale: function (scaleX, scaleY) setBodyScale: function (scaleX, scaleY)
{ {
if (scaleY === undefined) { scaleY = scaleX; } if (scaleY === undefined) { scaleY = scaleX; }
var gameObject = this.body.gameObject; var gameObject = this.body.gameObject;
if (gameObject) if (gameObject)
{ {
gameObject.setScale(scaleX, scaleY); gameObject.setScale(scaleX, scaleY);
return this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); return this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY);
} }
else else
{ {
return this.setBodySize(this.body.size.x * scaleX, this.body.size.y * scaleY); return this.setBodySize(this.body.size.x * scaleX, this.body.size.y * scaleY);
} }
} }
}; };
module.exports = BodyScale; module.exports = BodyScale;

View file

@ -1,78 +1,78 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var TYPE = require('../TYPE'); var TYPE = require('../TYPE');
/** /**
* The Impact Body Type component. * The Impact Body Type component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.BodyType * @namespace Phaser.Physics.Impact.Components.BodyType
* @since 3.0.0 * @since 3.0.0
*/ */
var BodyType = { var BodyType = {
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.BodyType#getBodyType * @method Phaser.Physics.Impact.Components.BodyType#getBodyType
* @since 3.0.0 * @since 3.0.0
* *
* @return {number} [description] * @return {number} [description]
*/ */
getBodyType: function () getBodyType: function ()
{ {
return this.body.type; return this.body.type;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.BodyType#setTypeNone * @method Phaser.Physics.Impact.Components.BodyType#setTypeNone
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setTypeNone: function () setTypeNone: function ()
{ {
this.body.type = TYPE.NONE; this.body.type = TYPE.NONE;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.BodyType#setTypeA * @method Phaser.Physics.Impact.Components.BodyType#setTypeA
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setTypeA: function () setTypeA: function ()
{ {
this.body.type = TYPE.A; this.body.type = TYPE.A;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.BodyType#setTypeB * @method Phaser.Physics.Impact.Components.BodyType#setTypeB
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setTypeB: function () setTypeB: function ()
{ {
this.body.type = TYPE.B; this.body.type = TYPE.B;
return this; return this;
} }
}; };
module.exports = BodyType; module.exports = BodyType;

View file

@ -1,74 +1,74 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Bounce component. * The Impact Bounce component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Bounce * @namespace Phaser.Physics.Impact.Components.Bounce
* @since 3.0.0 * @since 3.0.0
*/ */
var Bounce = { var Bounce = {
/** /**
* Sets the impact physics bounce, or restitution, value. * Sets the impact physics bounce, or restitution, value.
* *
* @method Phaser.Physics.Impact.Components.Bounce#setBounce * @method Phaser.Physics.Impact.Components.Bounce#setBounce
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} value - A value between 0 (no rebound) and 1 (full rebound) * @param {number} value - A value between 0 (no rebound) and 1 (full rebound)
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setBounce: function (value) setBounce: function (value)
{ {
this.body.bounciness = value; this.body.bounciness = value;
return this; return this;
}, },
/** /**
* Sets the minimum velocity the body is allowed to be moving to be considered for rebound. * Sets the minimum velocity the body is allowed to be moving to be considered for rebound.
* *
* @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity * @method Phaser.Physics.Impact.Components.Bounce#setMinBounceVelocity
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} value - The minimum allowed velocity. * @param {number} value - The minimum allowed velocity.
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setMinBounceVelocity: function (value) setMinBounceVelocity: function (value)
{ {
this.body.minBounceVelocity = value; this.body.minBounceVelocity = value;
return this; return this;
}, },
/** /**
* The bounce, or restitution, value of this body. * The bounce, or restitution, value of this body.
* A value between 0 (no rebound) and 1 (full rebound) * A value between 0 (no rebound) and 1 (full rebound)
* *
* @name Phaser.Physics.Impact.Components.Bounce#bounce * @name Phaser.Physics.Impact.Components.Bounce#bounce
* @type {number} * @type {number}
* @since 3.0.0 * @since 3.0.0
*/ */
bounce: { bounce: {
get: function () get: function ()
{ {
return this.body.bounciness; return this.body.bounciness;
}, },
set: function (value) set: function (value)
{ {
this.body.bounciness = value; this.body.bounciness = value;
} }
} }
}; };
module.exports = Bounce; module.exports = Bounce;

View file

@ -1,116 +1,116 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var TYPE = require('../TYPE'); var TYPE = require('../TYPE');
/** /**
* The Impact Check Against component. * The Impact Check Against component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.CheckAgainst * @namespace Phaser.Physics.Impact.Components.CheckAgainst
* @since 3.0.0 * @since 3.0.0
*/ */
var CheckAgainst = { var CheckAgainst = {
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.CheckAgainst#setAvsB * @method Phaser.Physics.Impact.Components.CheckAgainst#setAvsB
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setAvsB: function () setAvsB: function ()
{ {
this.setTypeA(); this.setTypeA();
return this.setCheckAgainstB(); return this.setCheckAgainstB();
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.CheckAgainst#setBvsA * @method Phaser.Physics.Impact.Components.CheckAgainst#setBvsA
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setBvsA: function () setBvsA: function ()
{ {
this.setTypeB(); this.setTypeB();
return this.setCheckAgainstA(); return this.setCheckAgainstA();
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstNone * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstNone
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setCheckAgainstNone: function () setCheckAgainstNone: function ()
{ {
this.body.checkAgainst = TYPE.NONE; this.body.checkAgainst = TYPE.NONE;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstA * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstA
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setCheckAgainstA: function () setCheckAgainstA: function ()
{ {
this.body.checkAgainst = TYPE.A; this.body.checkAgainst = TYPE.A;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstB * @method Phaser.Physics.Impact.Components.CheckAgainst#setCheckAgainstB
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setCheckAgainstB: function () setCheckAgainstB: function ()
{ {
this.body.checkAgainst = TYPE.B; this.body.checkAgainst = TYPE.B;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.Components.CheckAgainst#checkAgainst * @name Phaser.Physics.Impact.Components.CheckAgainst#checkAgainst
* @type {number} * @type {number}
* @since 3.0.0 * @since 3.0.0
*/ */
checkAgainst: { checkAgainst: {
get: function () get: function ()
{ {
return this.body.checkAgainst; return this.body.checkAgainst;
}, },
set: function (value) set: function (value)
{ {
this.body.checkAgainst = value; this.body.checkAgainst = value;
} }
} }
}; };
module.exports = CheckAgainst; module.exports = CheckAgainst;

View file

@ -1,150 +1,150 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var COLLIDES = require('../COLLIDES'); var COLLIDES = require('../COLLIDES');
/** /**
* @callback CollideCallback * @callback CollideCallback
* *
* @param {Phaser.Physics.Impact.Body} body - [description] * @param {Phaser.Physics.Impact.Body} body - [description]
* @param {Phaser.Physics.Impact.Body} other - [description] * @param {Phaser.Physics.Impact.Body} other - [description]
* @param {string} axis - [description] * @param {string} axis - [description]
*/ */
/** /**
* The Impact Collides component. * The Impact Collides component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Collides * @namespace Phaser.Physics.Impact.Components.Collides
* @since 3.0.0 * @since 3.0.0
*/ */
var Collides = { var Collides = {
_collideCallback: null, _collideCallback: null,
_callbackScope: null, _callbackScope: null,
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Collides#setCollideCallback * @method Phaser.Physics.Impact.Components.Collides#setCollideCallback
* @since 3.0.0 * @since 3.0.0
* *
* @param {CollideCallback} callback - [description] * @param {CollideCallback} callback - [description]
* @param {*} scope - [description] * @param {*} scope - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setCollideCallback: function (callback, scope) setCollideCallback: function (callback, scope)
{ {
this._collideCallback = callback; this._collideCallback = callback;
if (scope) if (scope)
{ {
this._callbackScope = scope; this._callbackScope = scope;
} }
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Collides#setCollidesNever * @method Phaser.Physics.Impact.Components.Collides#setCollidesNever
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setCollidesNever: function () setCollidesNever: function ()
{ {
this.body.collides = COLLIDES.NEVER; this.body.collides = COLLIDES.NEVER;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Collides#setLiteCollision * @method Phaser.Physics.Impact.Components.Collides#setLiteCollision
* @since 3.6.0 * @since 3.6.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setLiteCollision: function () setLiteCollision: function ()
{ {
this.body.collides = COLLIDES.LITE; this.body.collides = COLLIDES.LITE;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Collides#setPassiveCollision * @method Phaser.Physics.Impact.Components.Collides#setPassiveCollision
* @since 3.6.0 * @since 3.6.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setPassiveCollision: function () setPassiveCollision: function ()
{ {
this.body.collides = COLLIDES.PASSIVE; this.body.collides = COLLIDES.PASSIVE;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Collides#setActiveCollision * @method Phaser.Physics.Impact.Components.Collides#setActiveCollision
* @since 3.6.0 * @since 3.6.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setActiveCollision: function () setActiveCollision: function ()
{ {
this.body.collides = COLLIDES.ACTIVE; this.body.collides = COLLIDES.ACTIVE;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Collides#setFixedCollision * @method Phaser.Physics.Impact.Components.Collides#setFixedCollision
* @since 3.6.0 * @since 3.6.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setFixedCollision: function () setFixedCollision: function ()
{ {
this.body.collides = COLLIDES.FIXED; this.body.collides = COLLIDES.FIXED;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.Components.Collides#collides * @name Phaser.Physics.Impact.Components.Collides#collides
* @type {number} * @type {number}
* @since 3.0.0 * @since 3.0.0
*/ */
collides: { collides: {
get: function () get: function ()
{ {
return this.body.collides; return this.body.collides;
}, },
set: function (value) set: function (value)
{ {
this.body.collides = value; this.body.collides = value;
} }
} }
}; };
module.exports = Collides; module.exports = Collides;

View file

@ -1,119 +1,119 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Debug component. * The Impact Debug component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Debug * @namespace Phaser.Physics.Impact.Components.Debug
* @since 3.0.0 * @since 3.0.0
*/ */
var Debug = { var Debug = {
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Debug#setDebug * @method Phaser.Physics.Impact.Components.Debug#setDebug
* @since 3.0.0 * @since 3.0.0
* *
* @param {boolean} showBody - [description] * @param {boolean} showBody - [description]
* @param {boolean} showVelocity - [description] * @param {boolean} showVelocity - [description]
* @param {number} bodyColor - [description] * @param {number} bodyColor - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setDebug: function (showBody, showVelocity, bodyColor) setDebug: function (showBody, showVelocity, bodyColor)
{ {
this.debugShowBody = showBody; this.debugShowBody = showBody;
this.debugShowVelocity = showVelocity; this.debugShowVelocity = showVelocity;
this.debugBodyColor = bodyColor; this.debugBodyColor = bodyColor;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Debug#setDebugBodyColor * @method Phaser.Physics.Impact.Components.Debug#setDebugBodyColor
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} value - [description] * @param {number} value - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setDebugBodyColor: function (value) setDebugBodyColor: function (value)
{ {
this.body.debugBodyColor = value; this.body.debugBodyColor = value;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.Components.Debug#debugShowBody * @name Phaser.Physics.Impact.Components.Debug#debugShowBody
* @type {boolean} * @type {boolean}
* @since 3.0.0 * @since 3.0.0
*/ */
debugShowBody: { debugShowBody: {
get: function () get: function ()
{ {
return this.body.debugShowBody; return this.body.debugShowBody;
}, },
set: function (value) set: function (value)
{ {
this.body.debugShowBody = value; this.body.debugShowBody = value;
} }
}, },
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.Components.Debug#debugShowVelocity * @name Phaser.Physics.Impact.Components.Debug#debugShowVelocity
* @type {boolean} * @type {boolean}
* @since 3.0.0 * @since 3.0.0
*/ */
debugShowVelocity: { debugShowVelocity: {
get: function () get: function ()
{ {
return this.body.debugShowVelocity; return this.body.debugShowVelocity;
}, },
set: function (value) set: function (value)
{ {
this.body.debugShowVelocity = value; this.body.debugShowVelocity = value;
} }
}, },
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.Components.Debug#debugBodyColor * @name Phaser.Physics.Impact.Components.Debug#debugBodyColor
* @type {number} * @type {number}
* @since 3.0.0 * @since 3.0.0
*/ */
debugBodyColor: { debugBodyColor: {
get: function () get: function ()
{ {
return this.body.debugBodyColor; return this.body.debugBodyColor;
}, },
set: function (value) set: function (value)
{ {
this.body.debugBodyColor = value; this.body.debugBodyColor = value;
} }
} }
}; };
module.exports = Debug; module.exports = Debug;

View file

@ -1,71 +1,71 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Friction component. * The Impact Friction component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Friction * @namespace Phaser.Physics.Impact.Components.Friction
* @since 3.0.0 * @since 3.0.0
*/ */
var Friction = { var Friction = {
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Friction#setFrictionX * @method Phaser.Physics.Impact.Components.Friction#setFrictionX
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {number} x - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setFrictionX: function (x) setFrictionX: function (x)
{ {
this.friction.x = x; this.friction.x = x;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Friction#setFrictionY * @method Phaser.Physics.Impact.Components.Friction#setFrictionY
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} y - [description] * @param {number} y - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setFrictionY: function (y) setFrictionY: function (y)
{ {
this.friction.y = y; this.friction.y = y;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Friction#setFriction * @method Phaser.Physics.Impact.Components.Friction#setFriction
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {number} x - [description]
* @param {number} y - [description] * @param {number} y - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setFriction: function (x, y) setFriction: function (x, y)
{ {
this.friction.x = x; this.friction.x = x;
this.friction.y = y; this.friction.y = y;
return this; return this;
} }
}; };
module.exports = Friction; module.exports = Friction;

View file

@ -1,56 +1,56 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Gravity component. * The Impact Gravity component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Gravity * @namespace Phaser.Physics.Impact.Components.Gravity
* @since 3.0.0 * @since 3.0.0
*/ */
var Gravity = { var Gravity = {
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Gravity#setGravity * @method Phaser.Physics.Impact.Components.Gravity#setGravity
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} value - [description] * @param {number} value - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setGravity: function (value) setGravity: function (value)
{ {
this.body.gravityFactor = value; this.body.gravityFactor = value;
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @name Phaser.Physics.Impact.Components.Gravity#gravity * @name Phaser.Physics.Impact.Components.Gravity#gravity
* @type {number} * @type {number}
* @since 3.0.0 * @since 3.0.0
*/ */
gravity: { gravity: {
get: function () get: function ()
{ {
return this.body.gravityFactor; return this.body.gravityFactor;
}, },
set: function (value) set: function (value)
{ {
this.body.gravityFactor = value; this.body.gravityFactor = value;
} }
} }
}; };
module.exports = Gravity; module.exports = Gravity;

View file

@ -1,44 +1,44 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Offset component. * The Impact Offset component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Offset * @namespace Phaser.Physics.Impact.Components.Offset
* @since 3.0.0 * @since 3.0.0
*/ */
var Offset = { var Offset = {
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.Offset#setOffset * @method Phaser.Physics.Impact.Components.Offset#setOffset
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - [description] * @param {number} x - [description]
* @param {number} y - [description] * @param {number} y - [description]
* @param {number} [width] - [description] * @param {number} [width] - [description]
* @param {number} [height] - [description] * @param {number} [height] - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setOffset: function (x, y, width, height) setOffset: function (x, y, width, height)
{ {
this.body.offset.x = x; this.body.offset.x = x;
this.body.offset.y = y; this.body.offset.y = y;
if (width) if (width)
{ {
this.setBodySize(width, height); this.setBodySize(width, height);
} }
return this; return this;
} }
}; };
module.exports = Offset; module.exports = Offset;

View file

@ -1,70 +1,70 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Set Game Object component. * The Impact Set Game Object component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.SetGameObject * @namespace Phaser.Physics.Impact.Components.SetGameObject
* @since 3.0.0 * @since 3.0.0
*/ */
var SetGameObject = { var SetGameObject = {
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject * @method Phaser.Physics.Impact.Components.SetGameObject#setGameObject
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.GameObjects.GameObject} gameObject - [description] * @param {Phaser.GameObjects.GameObject} gameObject - [description]
* @param {boolean} [sync=true] - [description] * @param {boolean} [sync=true] - [description]
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
setGameObject: function (gameObject, sync) setGameObject: function (gameObject, sync)
{ {
if (sync === undefined) { sync = true; } if (sync === undefined) { sync = true; }
if (gameObject) if (gameObject)
{ {
this.body.gameObject = gameObject; this.body.gameObject = gameObject;
if (sync) if (sync)
{ {
this.syncGameObject(); this.syncGameObject();
} }
} }
else else
{ {
this.body.gameObject = null; this.body.gameObject = null;
} }
return this; return this;
}, },
/** /**
* [description] * [description]
* *
* @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject * @method Phaser.Physics.Impact.Components.SetGameObject#syncGameObject
* @since 3.0.0 * @since 3.0.0
* *
* @return {Phaser.GameObjects.GameObject} This Game Object. * @return {Phaser.GameObjects.GameObject} This Game Object.
*/ */
syncGameObject: function () syncGameObject: function ()
{ {
var gameObject = this.body.gameObject; var gameObject = this.body.gameObject;
if (gameObject) if (gameObject)
{ {
this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY); this.setBodySize(gameObject.width * gameObject.scaleX, gameObject.height * gameObject.scaleY);
} }
return this; return this;
} }
}; };
module.exports = SetGameObject; module.exports = SetGameObject;

View file

@ -1,94 +1,94 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Velocity component. * The Impact Velocity component.
* Should be applied as a mixin. * Should be applied as a mixin.
* *
* @namespace Phaser.Physics.Impact.Components.Velocity * @namespace Phaser.Physics.Impact.Components.Velocity
* @since 3.0.0 * @since 3.0.0
*/ */
var Velocity = { var Velocity = {
/** /**
* Sets the horizontal velocity of the physics body. * Sets the horizontal velocity of the physics body.
* *
* @method Phaser.Physics.Impact.Components.Velocity#setVelocityX * @method Phaser.Physics.Impact.Components.Velocity#setVelocityX
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The horizontal velocity value. * @param {number} x - The horizontal velocity value.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setVelocityX: function (x) setVelocityX: function (x)
{ {
this.vel.x = x; this.vel.x = x;
return this; return this;
}, },
/** /**
* Sets the vertical velocity of the physics body. * Sets the vertical velocity of the physics body.
* *
* @method Phaser.Physics.Impact.Components.Velocity#setVelocityY * @method Phaser.Physics.Impact.Components.Velocity#setVelocityY
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} y - The vertical velocity value. * @param {number} y - The vertical velocity value.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setVelocityY: function (y) setVelocityY: function (y)
{ {
this.vel.y = y; this.vel.y = y;
return this; return this;
}, },
/** /**
* Sets the horizontal and vertical velocities of the physics body. * Sets the horizontal and vertical velocities of the physics body.
* *
* @method Phaser.Physics.Impact.Components.Velocity#setVelocity * @method Phaser.Physics.Impact.Components.Velocity#setVelocity
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The horizontal velocity value. * @param {number} x - The horizontal velocity value.
* @param {number} [y=x] - The vertical velocity value. If not given, defaults to the horizontal value. * @param {number} [y=x] - The vertical velocity value. If not given, defaults to the horizontal value.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setVelocity: function (x, y) setVelocity: function (x, y)
{ {
if (y === undefined) { y = x; } if (y === undefined) { y = x; }
this.vel.x = x; this.vel.x = x;
this.vel.y = y; this.vel.y = y;
return this; return this;
}, },
/** /**
* Sets the maximum velocity this body can travel at. * Sets the maximum velocity this body can travel at.
* *
* @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity * @method Phaser.Physics.Impact.Components.Velocity#setMaxVelocity
* @since 3.0.0 * @since 3.0.0
* *
* @param {number} x - The maximum allowed horizontal velocity. * @param {number} x - The maximum allowed horizontal velocity.
* @param {number} [y=x] - The maximum allowed vertical velocity. If not given, defaults to the horizontal value. * @param {number} [y=x] - The maximum allowed vertical velocity. If not given, defaults to the horizontal value.
* *
* @return {this} This Game Object. * @return {this} This Game Object.
*/ */
setMaxVelocity: function (x, y) setMaxVelocity: function (x, y)
{ {
if (y === undefined) { y = x; } if (y === undefined) { y = x; }
this.maxVel.x = x; this.maxVel.x = x;
this.maxVel.y = y; this.maxVel.y = y;
return this; return this;
} }
}; };
module.exports = Velocity; module.exports = Velocity;

View file

@ -1,26 +1,26 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* @namespace Phaser.Physics.Impact.Components * @namespace Phaser.Physics.Impact.Components
*/ */
module.exports = { module.exports = {
Acceleration: require('./Acceleration'), Acceleration: require('./Acceleration'),
BodyScale: require('./BodyScale'), BodyScale: require('./BodyScale'),
BodyType: require('./BodyType'), BodyType: require('./BodyType'),
Bounce: require('./Bounce'), Bounce: require('./Bounce'),
CheckAgainst: require('./CheckAgainst'), CheckAgainst: require('./CheckAgainst'),
Collides: require('./Collides'), Collides: require('./Collides'),
Debug: require('./Debug'), Debug: require('./Debug'),
Friction: require('./Friction'), Friction: require('./Friction'),
Gravity: require('./Gravity'), Gravity: require('./Gravity'),
Offset: require('./Offset'), Offset: require('./Offset'),
SetGameObject: require('./SetGameObject'), SetGameObject: require('./SetGameObject'),
Velocity: require('./Velocity') Velocity: require('./Velocity')
}; };

View file

@ -1,21 +1,21 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Physics World Collide Event. * The Impact Physics World Collide Event.
* *
* This event is dispatched by an Impact Physics World instance if two bodies collide. * This event is dispatched by an Impact Physics World instance if two bodies collide.
* *
* Listen to it from a Scene using: `this.impact.world.on('collide', listener)`. * Listen to it from a Scene using: `this.impact.world.on('collide', listener)`.
* *
* @event Phaser.Physics.Impact.Events#COLLIDE * @event Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0 * @since 3.0.0
* *
* @param {Phaser.Physics.Impact.Body} bodyA - The first body involved in the collision. * @param {Phaser.Physics.Impact.Body} bodyA - The first body involved in the collision.
* @param {Phaser.Physics.Impact.Body} bodyB - The second body involved in the collision. * @param {Phaser.Physics.Impact.Body} bodyB - The second body involved in the collision.
* @param {string} axis - The collision axis. Either `x` or `y`. * @param {string} axis - The collision axis. Either `x` or `y`.
*/ */
module.exports = 'collide'; module.exports = 'collide';

View file

@ -1,17 +1,17 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Physics World Pause Event. * The Impact Physics World Pause Event.
* *
* This event is dispatched by an Impact Physics World instance when it is paused. * This event is dispatched by an Impact Physics World instance when it is paused.
* *
* Listen to it from a Scene using: `this.impact.world.on('pause', listener)`. * Listen to it from a Scene using: `this.impact.world.on('pause', listener)`.
* *
* @event Phaser.Physics.Impact.Events#PAUSE * @event Phaser.Physics.Impact.Events#PAUSE
* @since 3.0.0 * @since 3.0.0
*/ */
module.exports = 'pause'; module.exports = 'pause';

View file

@ -1,17 +1,17 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* The Impact Physics World Resume Event. * The Impact Physics World Resume Event.
* *
* This event is dispatched by an Impact Physics World instance when it resumes from a paused state. * This event is dispatched by an Impact Physics World instance when it resumes from a paused state.
* *
* Listen to it from a Scene using: `this.impact.world.on('resume', listener)`. * Listen to it from a Scene using: `this.impact.world.on('resume', listener)`.
* *
* @event Phaser.Physics.Impact.Events#RESUME * @event Phaser.Physics.Impact.Events#RESUME
* @since 3.0.0 * @since 3.0.0
*/ */
module.exports = 'resume'; module.exports = 'resume';

View file

@ -1,17 +1,17 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* @namespace Phaser.Physics.Impact.Events * @namespace Phaser.Physics.Impact.Events
*/ */
module.exports = { module.exports = {
COLLIDE: require('./COLLIDE_EVENT'), COLLIDE: require('./COLLIDE_EVENT'),
PAUSE: require('./PAUSE_EVENT'), PAUSE: require('./PAUSE_EVENT'),
RESUME: require('./RESUME_EVENT') RESUME: require('./RESUME_EVENT')
}; };

View file

@ -1,36 +1,36 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* An Impact.js compatible physics world, body and solver, for those who are used * An Impact.js compatible physics world, body and solver, for those who are used
* to the Impact way of defining and controlling physics bodies. Also works with * to the Impact way of defining and controlling physics bodies. Also works with
* the new Loader support for Weltmeister map data. * the new Loader support for Weltmeister map data.
* *
* World updated to run off the Phaser main loop. * World updated to run off the Phaser main loop.
* Body extended to support additional setter functions. * Body extended to support additional setter functions.
* *
* To create the map data you'll need Weltmeister, which comes with Impact * To create the map data you'll need Weltmeister, which comes with Impact
* and can be purchased from http://impactjs.com * and can be purchased from http://impactjs.com
* *
* My thanks to Dominic Szablewski for his permission to support Impact in Phaser. * My thanks to Dominic Szablewski for his permission to support Impact in Phaser.
* *
* @namespace Phaser.Physics.Impact * @namespace Phaser.Physics.Impact
*/ */
module.exports = { module.exports = {
Body: require('./Body'), Body: require('./Body'),
Events: require('./events'), Events: require('./events'),
COLLIDES: require('./COLLIDES'), COLLIDES: require('./COLLIDES'),
CollisionMap: require('./CollisionMap'), CollisionMap: require('./CollisionMap'),
Factory: require('./Factory'), Factory: require('./Factory'),
Image: require('./ImpactImage'), Image: require('./ImpactImage'),
ImpactBody: require('./ImpactBody'), ImpactBody: require('./ImpactBody'),
ImpactPhysics: require('./ImpactPhysics'), ImpactPhysics: require('./ImpactPhysics'),
Sprite: require('./ImpactSprite'), Sprite: require('./ImpactSprite'),
TYPE: require('./TYPE'), TYPE: require('./TYPE'),
World: require('./World') World: require('./World')
}; };

View file

@ -1,14 +1,14 @@
/** /**
* @typedef {object} Phaser.Types.Physics.Impact.CollisionOptions * @typedef {object} Phaser.Types.Physics.Impact.CollisionOptions
* @since 3.0.0 * @since 3.0.0
* *
* @property {string} [slopeTileProperty=null] - Slope IDs can be stored on tiles directly * @property {string} [slopeTileProperty=null] - Slope IDs can be stored on tiles directly
* using Impacts tileset editor. If a tile has a property with the given slopeTileProperty string * using Impacts tileset editor. If a tile has a property with the given slopeTileProperty string
* name, the value of that property for the tile will be used for its slope mapping. E.g. a 45 * name, the value of that property for the tile will be used for its slope mapping. E.g. a 45
* degree slope upward could be given a "slope" property with a value of 2. * degree slope upward could be given a "slope" property with a value of 2.
* @property {object} [slopeMap=null] - A tile index to slope definition map. * @property {object} [slopeMap=null] - A tile index to slope definition map.
* @property {integer} [defaultCollidingSlope=null] - If specified, the default slope ID to * @property {integer} [defaultCollidingSlope=null] - If specified, the default slope ID to
* assign to a colliding tile. If not specified, the tile's index is used. * assign to a colliding tile. If not specified, the tile's index is used.
* @property {integer} [defaultNonCollidingSlope=0] - The default slope ID to assign to a * @property {integer} [defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile. * non-colliding tile.
*/ */

View file

@ -1,18 +1,18 @@
/** /**
* @typedef {object} Phaser.Types.Physics.Impact.JSONImpactBody * @typedef {object} Phaser.Types.Physics.Impact.JSONImpactBody
* @since 3.0.0 * @since 3.0.0
* *
* @property {string} name - [description] * @property {string} name - [description]
* @property {Phaser.Types.Math.Vector2Like} size - [description] * @property {Phaser.Types.Math.Vector2Like} size - [description]
* @property {Phaser.Types.Math.Vector2Like} pos - The entity's position in the game world. * @property {Phaser.Types.Math.Vector2Like} pos - The entity's position in the game world.
* @property {Phaser.Types.Math.Vector2Like} vel - Current velocity in pixels per second. * @property {Phaser.Types.Math.Vector2Like} vel - Current velocity in pixels per second.
* @property {Phaser.Types.Math.Vector2Like} accel - Current acceleration to be added to the entity's velocity per second. E.g. an entity with a `vel.x` of 0 and `accel.x` of 10 will have a `vel.x` of 100 ten seconds later. * @property {Phaser.Types.Math.Vector2Like} accel - Current acceleration to be added to the entity's velocity per second. E.g. an entity with a `vel.x` of 0 and `accel.x` of 10 will have a `vel.x` of 100 ten seconds later.
* @property {Phaser.Types.Math.Vector2Like} friction - Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0. * @property {Phaser.Types.Math.Vector2Like} friction - Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0.
* @property {Phaser.Types.Math.Vector2Like} maxVel - The maximum velocity a body can move. * @property {Phaser.Types.Math.Vector2Like} maxVel - The maximum velocity a body can move.
* @property {number} gravityFactor - [description] * @property {number} gravityFactor - [description]
* @property {number} bounciness - [description] * @property {number} bounciness - [description]
* @property {number} minBounceVelocity - [description] * @property {number} minBounceVelocity - [description]
* @property {Phaser.Physics.Impact.TYPE} type - [description] * @property {Phaser.Physics.Impact.TYPE} type - [description]
* @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description] * @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description]
* @property {Phaser.Physics.Impact.COLLIDES} collides - [description] * @property {Phaser.Physics.Impact.COLLIDES} collides - [description]
*/ */

View file

@ -1,30 +1,30 @@
/** /**
* @typedef {object} Phaser.Types.Physics.Impact.WorldConfig * @typedef {object} Phaser.Types.Physics.Impact.WorldConfig
* @since 3.0.0 * @since 3.0.0
* *
* @property {number} [gravity=0] - Sets {@link Phaser.Physics.Impact.World#gravity} * @property {number} [gravity=0] - Sets {@link Phaser.Physics.Impact.World#gravity}
* @property {number} [cellSize=64] - The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world. * @property {number} [cellSize=64] - The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world.
* @property {number} [timeScale=1] - A number that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed. * @property {number} [timeScale=1] - A number that allows per-body time scaling, e.g. a force-field where bodies inside are in slow-motion, while others are at full speed.
* @property {number} [maxStep=0.05] - [description] * @property {number} [maxStep=0.05] - [description]
* @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}. * @property {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}.
* @property {number} [maxVelocity=100] - The maximum velocity a body can move. * @property {number} [maxVelocity=100] - The maximum velocity a body can move.
* @property {boolean} [debugShowBody=true] - Whether the Body's boundary is drawn to the debug display. * @property {boolean} [debugShowBody=true] - Whether the Body's boundary is drawn to the debug display.
* @property {boolean} [debugShowVelocity=true] - Whether the Body's velocity is drawn to the debug display. * @property {boolean} [debugShowVelocity=true] - Whether the Body's velocity is drawn to the debug display.
* @property {number} [debugBodyColor=0xff00ff] - The color of this Body on the debug display. * @property {number} [debugBodyColor=0xff00ff] - The color of this Body on the debug display.
* @property {number} [debugVelocityColor=0x00ff00] - The color of the Body's velocity on the debug display. * @property {number} [debugVelocityColor=0x00ff00] - The color of the Body's velocity on the debug display.
* @property {number} [maxVelocityX=maxVelocity] - Maximum X velocity objects can move. * @property {number} [maxVelocityX=maxVelocity] - Maximum X velocity objects can move.
* @property {number} [maxVelocityY=maxVelocity] - Maximum Y velocity objects can move. * @property {number} [maxVelocityY=maxVelocity] - Maximum Y velocity objects can move.
* @property {number} [minBounceVelocity=40] - The minimum velocity an object can be moving at to be considered for bounce. * @property {number} [minBounceVelocity=40] - The minimum velocity an object can be moving at to be considered for bounce.
* @property {number} [gravityFactor=1] - Gravity multiplier. Set to 0 for no gravity. * @property {number} [gravityFactor=1] - Gravity multiplier. Set to 0 for no gravity.
* @property {number} [bounciness=0] - The default bounce, or restitution, of bodies in the world. * @property {number} [bounciness=0] - The default bounce, or restitution, of bodies in the world.
* @property {(object|boolean)} [setBounds] - Should the world have bounds enabled by default? * @property {(object|boolean)} [setBounds] - Should the world have bounds enabled by default?
* @property {number} [setBounds.x=0] - The x coordinate of the world bounds. * @property {number} [setBounds.x=0] - The x coordinate of the world bounds.
* @property {number} [setBounds.y=0] - The y coordinate of the world bounds. * @property {number} [setBounds.y=0] - The y coordinate of the world bounds.
* @property {number} [setBounds.width] - The width of the world bounds. * @property {number} [setBounds.width] - The width of the world bounds.
* @property {number} [setBounds.height] - The height of the world bounds. * @property {number} [setBounds.height] - The height of the world bounds.
* @property {number} [setBounds.thickness=64] - The thickness of the walls of the world bounds. * @property {number} [setBounds.thickness=64] - The thickness of the walls of the world bounds.
* @property {boolean} [setBounds.left=true] - Should the left-side world bounds wall be created? * @property {boolean} [setBounds.left=true] - Should the left-side world bounds wall be created?
* @property {boolean} [setBounds.right=true] - Should the right-side world bounds wall be created? * @property {boolean} [setBounds.right=true] - Should the right-side world bounds wall be created?
* @property {boolean} [setBounds.top=true] - Should the top world bounds wall be created? * @property {boolean} [setBounds.top=true] - Should the top world bounds wall be created?
* @property {boolean} [setBounds.bottom=true] - Should the bottom world bounds wall be created? * @property {boolean} [setBounds.bottom=true] - Should the bottom world bounds wall be created?
*/ */

View file

@ -1,16 +1,16 @@
/** /**
* An object containing the 4 wall bodies that bound the physics world. * An object containing the 4 wall bodies that bound the physics world.
* *
* @typedef {object} Phaser.Types.Physics.Impact.WorldDefaults * @typedef {object} Phaser.Types.Physics.Impact.WorldDefaults
* @since 3.0.0 * @since 3.0.0
* *
* @property {boolean} debugShowBody - Whether the Body's boundary is drawn to the debug display. * @property {boolean} debugShowBody - Whether the Body's boundary is drawn to the debug display.
* @property {boolean} debugShowVelocity - Whether the Body's velocity is drawn to the debug display. * @property {boolean} debugShowVelocity - Whether the Body's velocity is drawn to the debug display.
* @property {number} bodyDebugColor - The color of this Body on the debug display. * @property {number} bodyDebugColor - The color of this Body on the debug display.
* @property {number} velocityDebugColor - The color of the Body's velocity on the debug display. * @property {number} velocityDebugColor - The color of the Body's velocity on the debug display.
* @property {number} maxVelocityX - Maximum X velocity objects can move. * @property {number} maxVelocityX - Maximum X velocity objects can move.
* @property {number} maxVelocityY - Maximum Y velocity objects can move. * @property {number} maxVelocityY - Maximum Y velocity objects can move.
* @property {number} minBounceVelocity - The minimum velocity an object can be moving at to be considered for bounce. * @property {number} minBounceVelocity - The minimum velocity an object can be moving at to be considered for bounce.
* @property {number} gravityFactor - Gravity multiplier. Set to 0 for no gravity. * @property {number} gravityFactor - Gravity multiplier. Set to 0 for no gravity.
* @property {number} bounciness - The default bounce, or restitution, of bodies in the world. * @property {number} bounciness - The default bounce, or restitution, of bodies in the world.
*/ */

View file

@ -1,9 +1,9 @@
/** /**
* @typedef {object} Phaser.Types.Physics.Impact.WorldWalls * @typedef {object} Phaser.Types.Physics.Impact.WorldWalls
* @since 3.0.0 * @since 3.0.0
* *
* @property {?Phaser.Physics.Impact.Body} left - The left-side wall of the world bounds. * @property {?Phaser.Physics.Impact.Body} left - The left-side wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} right - The right-side wall of the world bounds. * @property {?Phaser.Physics.Impact.Body} right - The right-side wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} top - The top wall of the world bounds. * @property {?Phaser.Physics.Impact.Body} top - The top wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds. * @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds.
*/ */

View file

@ -1,9 +1,9 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* @namespace Phaser.Types.Physics.Impact * @namespace Phaser.Types.Physics.Impact
*/ */

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -1,42 +1,42 @@
/** /**
* @author samme * @author samme
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var QuickSet = require('../display/align/to/QuickSet'); var QuickSet = require('../display/align/to/QuickSet');
/** /**
* Takes an array of Game Objects, or any objects that have public `x` and `y` properties, and aligns them next to each other. * Takes an array of Game Objects, or any objects that have public `x` and `y` properties, and aligns them next to each other.
* *
* The first item isn't moved. The second item is aligned next to the first, then the third next to the second, and so on. * The first item isn't moved. The second item is aligned next to the first, then the third next to the second, and so on.
* *
* @function Phaser.Actions.AlignTo * @function Phaser.Actions.AlignTo
* @since 3.22.0 * @since 3.22.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {integer} position - The position to align the items with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`. * @param {integer} position - The position to align the items with. This is an align constant, such as `Phaser.Display.Align.LEFT_CENTER`.
* @param {number} [offsetX=0] - Optional horizontal offset from the position. * @param {number} [offsetX=0] - Optional horizontal offset from the position.
* @param {number} [offsetY=0] - Optional vertical offset from the position. * @param {number} [offsetY=0] - Optional vertical offset from the position.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var AlignTo = function (items, position, offsetX, offsetY) var AlignTo = function (items, position, offsetX, offsetY)
{ {
var target = items[0]; var target = items[0];
for (var i = 1; i < items.length; i++) for (var i = 1; i < items.length; i++)
{ {
var item = items[i]; var item = items[i];
QuickSet(item, target, position, offsetX, offsetY); QuickSet(item, target, position, offsetX, offsetY);
target = item; target = item;
} }
return items; return items;
}; };
module.exports = AlignTo; module.exports = AlignTo;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have a public `angle` property, * Takes an array of Game Objects, or any objects that have a public `angle` property,
* and then adds the given value to each of their `angle` properties. * and then adds the given value to each of their `angle` properties.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `Angle(group.getChildren(), value, step)` * To use this with a Group: `Angle(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.Angle * @function Phaser.Actions.Angle
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to be added to the `angle` property. * @param {number} value - The amount to be added to the `angle` property.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var Angle = function (items, value, step, index, direction) var Angle = function (items, value, step, index, direction)
{ {
return PropertyValueInc(items, 'angle', value, step, index, direction); return PropertyValueInc(items, 'angle', value, step, index, direction);
}; };
module.exports = Angle; module.exports = Angle;

View file

@ -1,33 +1,33 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of objects and passes each of them to the given callback. * Takes an array of objects and passes each of them to the given callback.
* *
* @function Phaser.Actions.Call * @function Phaser.Actions.Call
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {Phaser.Types.Actions.CallCallback} callback - The callback to be invoked. It will be passed just one argument: the item from the array. * @param {Phaser.Types.Actions.CallCallback} callback - The callback to be invoked. It will be passed just one argument: the item from the array.
* @param {*} context - The scope in which the callback will be invoked. * @param {*} context - The scope in which the callback will be invoked.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that was passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that was passed to this Action.
*/ */
var Call = function (items, callback, context) var Call = function (items, callback, context)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
var item = items[i]; var item = items[i];
callback.call(context, item); callback.call(context, item);
} }
return items; return items;
}; };
module.exports = Call; module.exports = Call;

View file

@ -1,52 +1,52 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of objects and returns the first element in the array that has properties which match * Takes an array of objects and returns the first element in the array that has properties which match
* all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }`
* then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1. * then it would return the first item which had the property `scaleX` set to 0.5 and `alpha` set to 1.
* *
* To use this with a Group: `GetFirst(group.getChildren(), compare, index)` * To use this with a Group: `GetFirst(group.getChildren(), compare, index)`
* *
* @function Phaser.Actions.GetFirst * @function Phaser.Actions.GetFirst
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items] * @generic {Phaser.GameObjects.GameObject[]} G - [items]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action.
* @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* *
* @return {?(object|Phaser.GameObjects.GameObject)} The first object in the array that matches the comparison object, or `null` if no match was found. * @return {?(object|Phaser.GameObjects.GameObject)} The first object in the array that matches the comparison object, or `null` if no match was found.
*/ */
var GetFirst = function (items, compare, index) var GetFirst = function (items, compare, index)
{ {
if (index === undefined) { index = 0; } if (index === undefined) { index = 0; }
for (var i = index; i < items.length; i++) for (var i = index; i < items.length; i++)
{ {
var item = items[i]; var item = items[i];
var match = true; var match = true;
for (var property in compare) for (var property in compare)
{ {
if (item[property] !== compare[property]) if (item[property] !== compare[property])
{ {
match = false; match = false;
} }
} }
if (match) if (match)
{ {
return item; return item;
} }
} }
return null; return null;
}; };
module.exports = GetFirst; module.exports = GetFirst;

View file

@ -1,52 +1,52 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of objects and returns the last element in the array that has properties which match * Takes an array of objects and returns the last element in the array that has properties which match
* all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }` * all of those specified in the `compare` object. For example, if the compare object was: `{ scaleX: 0.5, alpha: 1 }`
* then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1. * then it would return the last item which had the property `scaleX` set to 0.5 and `alpha` set to 1.
* *
* To use this with a Group: `GetLast(group.getChildren(), compare, index)` * To use this with a Group: `GetLast(group.getChildren(), compare, index)`
* *
* @function Phaser.Actions.GetLast * @function Phaser.Actions.GetLast
* @since 3.3.0 * @since 3.3.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items] * @generic {Phaser.GameObjects.GameObject[]} G - [items]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be searched by this action.
* @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array. * @param {object} compare - The comparison object. Each property in this object will be checked against the items of the array.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* *
* @return {?(object|Phaser.GameObjects.GameObject)} The last object in the array that matches the comparison object, or `null` if no match was found. * @return {?(object|Phaser.GameObjects.GameObject)} The last object in the array that matches the comparison object, or `null` if no match was found.
*/ */
var GetLast = function (items, compare, index) var GetLast = function (items, compare, index)
{ {
if (index === undefined) { index = 0; } if (index === undefined) { index = 0; }
for (var i = index; i < items.length; i++) for (var i = index; i < items.length; i++)
{ {
var item = items[i]; var item = items[i];
var match = true; var match = true;
for (var property in compare) for (var property in compare)
{ {
if (item[property] !== compare[property]) if (item[property] !== compare[property])
{ {
match = false; match = false;
} }
} }
if (match) if (match)
{ {
return item; return item;
} }
} }
return null; return null;
}; };
module.exports = GetLast; module.exports = GetLast;

View file

@ -1,93 +1,93 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var AlignIn = require('../display/align/in/QuickSet'); var AlignIn = require('../display/align/in/QuickSet');
var CONST = require('../display/align/const'); var CONST = require('../display/align/const');
var GetFastValue = require('../utils/object/GetFastValue'); var GetFastValue = require('../utils/object/GetFastValue');
var NOOP = require('../utils/NOOP'); var NOOP = require('../utils/NOOP');
var Zone = require('../gameobjects/zone/Zone'); var Zone = require('../gameobjects/zone/Zone');
var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1); var tempZone = new Zone({ sys: { queueDepthSort: NOOP, events: { once: NOOP } } }, 0, 0, 1, 1);
/** /**
* Takes an array of Game Objects, or any objects that have public `x` and `y` properties, * Takes an array of Game Objects, or any objects that have public `x` and `y` properties,
* and then aligns them based on the grid configuration given to this action. * and then aligns them based on the grid configuration given to this action.
* *
* @function Phaser.Actions.GridAlign * @function Phaser.Actions.GridAlign
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {Phaser.Types.Actions.GridAlignConfig} options - The GridAlign Configuration object. * @param {Phaser.Types.Actions.GridAlignConfig} options - The GridAlign Configuration object.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var GridAlign = function (items, options) var GridAlign = function (items, options)
{ {
if (options === undefined) { options = {}; } if (options === undefined) { options = {}; }
var widthSet = options.hasOwnProperty('width'); var widthSet = options.hasOwnProperty('width');
var heightSet = options.hasOwnProperty('height'); var heightSet = options.hasOwnProperty('height');
var width = GetFastValue(options, 'width', -1); var width = GetFastValue(options, 'width', -1);
var height = GetFastValue(options, 'height', -1); var height = GetFastValue(options, 'height', -1);
var cellWidth = GetFastValue(options, 'cellWidth', 1); var cellWidth = GetFastValue(options, 'cellWidth', 1);
var cellHeight = GetFastValue(options, 'cellHeight', cellWidth); var cellHeight = GetFastValue(options, 'cellHeight', cellWidth);
var position = GetFastValue(options, 'position', CONST.TOP_LEFT); var position = GetFastValue(options, 'position', CONST.TOP_LEFT);
var x = GetFastValue(options, 'x', 0); var x = GetFastValue(options, 'x', 0);
var y = GetFastValue(options, 'y', 0); var y = GetFastValue(options, 'y', 0);
var cx = 0; var cx = 0;
var cy = 0; var cy = 0;
var w = (width * cellWidth); var w = (width * cellWidth);
var h = (height * cellHeight); var h = (height * cellHeight);
tempZone.setPosition(x, y); tempZone.setPosition(x, y);
tempZone.setSize(cellWidth, cellHeight); tempZone.setSize(cellWidth, cellHeight);
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
AlignIn(items[i], tempZone, position); AlignIn(items[i], tempZone, position);
if (widthSet && width === -1) if (widthSet && width === -1)
{ {
// We keep laying them out horizontally until we've done them all // We keep laying them out horizontally until we've done them all
tempZone.x += cellWidth; tempZone.x += cellWidth;
} }
else if (heightSet && height === -1) else if (heightSet && height === -1)
{ {
// We keep laying them out vertically until we've done them all // We keep laying them out vertically until we've done them all
tempZone.y += cellHeight; tempZone.y += cellHeight;
} }
else else
{ {
// We keep laying them out until we hit the column limit // We keep laying them out until we hit the column limit
cx += cellWidth; cx += cellWidth;
tempZone.x += cellWidth; tempZone.x += cellWidth;
if (cx === w) if (cx === w)
{ {
cx = 0; cx = 0;
cy += cellHeight; cy += cellHeight;
tempZone.x = x; tempZone.x = x;
tempZone.y += cellHeight; tempZone.y += cellHeight;
if (cy === h) if (cy === h)
{ {
// We've hit the column limit, so return, even if there are items left // We've hit the column limit, so return, even if there are items left
break; break;
} }
} }
} }
} }
return items; return items;
}; };
module.exports = GridAlign; module.exports = GridAlign;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have a public `alpha` property, * Takes an array of Game Objects, or any objects that have a public `alpha` property,
* and then adds the given value to each of their `alpha` properties. * and then adds the given value to each of their `alpha` properties.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `IncAlpha(group.getChildren(), value, step)` * To use this with a Group: `IncAlpha(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.IncAlpha * @function Phaser.Actions.IncAlpha
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to be added to the `alpha` property. * @param {number} value - The amount to be added to the `alpha` property.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var IncAlpha = function (items, value, step, index, direction) var IncAlpha = function (items, value, step, index, direction)
{ {
return PropertyValueInc(items, 'alpha', value, step, index, direction); return PropertyValueInc(items, 'alpha', value, step, index, direction);
}; };
module.exports = IncAlpha; module.exports = IncAlpha;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have a public `x` property, * Takes an array of Game Objects, or any objects that have a public `x` property,
* and then adds the given value to each of their `x` properties. * and then adds the given value to each of their `x` properties.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `IncX(group.getChildren(), value, step)` * To use this with a Group: `IncX(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.IncX * @function Phaser.Actions.IncX
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to be added to the `x` property. * @param {number} value - The amount to be added to the `x` property.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var IncX = function (items, value, step, index, direction) var IncX = function (items, value, step, index, direction)
{ {
return PropertyValueInc(items, 'x', value, step, index, direction); return PropertyValueInc(items, 'x', value, step, index, direction);
}; };
module.exports = IncX; module.exports = IncX;

View file

@ -1,41 +1,41 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have public `x` and `y` properties, * Takes an array of Game Objects, or any objects that have public `x` and `y` properties,
* and then adds the given value to each of them. * and then adds the given value to each of them.
* *
* The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)` * To use this with a Group: `IncXY(group.getChildren(), x, y, stepX, stepY)`
* *
* @function Phaser.Actions.IncXY * @function Phaser.Actions.IncXY
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} x - The amount to be added to the `x` property. * @param {number} x - The amount to be added to the `x` property.
* @param {number} [y=x] - The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value. * @param {number} [y=x] - The amount to be added to the `y` property. If `undefined` or `null` it uses the `x` value.
* @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter.
* @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var IncXY = function (items, x, y, stepX, stepY, index, direction) var IncXY = function (items, x, y, stepX, stepY, index, direction)
{ {
if (y === undefined || y === null) { y = x; } if (y === undefined || y === null) { y = x; }
PropertyValueInc(items, 'x', x, stepX, index, direction); PropertyValueInc(items, 'x', x, stepX, index, direction);
return PropertyValueInc(items, 'y', y, stepY, index, direction); return PropertyValueInc(items, 'y', y, stepY, index, direction);
}; };
module.exports = IncXY; module.exports = IncXY;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have a public `y` property, * Takes an array of Game Objects, or any objects that have a public `y` property,
* and then adds the given value to each of their `y` properties. * and then adds the given value to each of their `y` properties.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `IncY(group.getChildren(), value, step)` * To use this with a Group: `IncY(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.IncY * @function Phaser.Actions.IncY
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to be added to the `y` property. * @param {number} value - The amount to be added to the `y` property.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var IncY = function (items, value, step, index, direction) var IncY = function (items, value, step, index, direction)
{ {
return PropertyValueInc(items, 'y', value, step, index, direction); return PropertyValueInc(items, 'y', value, step, index, direction);
}; };
module.exports = IncY; module.exports = IncY;

View file

@ -1,43 +1,43 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle. * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Circle.
* *
* If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property.
* *
* @function Phaser.Actions.PlaceOnCircle * @function Phaser.Actions.PlaceOnCircle
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Circle} circle - The Circle to position the Game Objects on. * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects on.
* @param {number} [startAngle=0] - Optional angle to start position from, in radians. * @param {number} [startAngle=0] - Optional angle to start position from, in radians.
* @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians.
* *
* @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 PlaceOnCircle = function (items, circle, startAngle, endAngle) var PlaceOnCircle = function (items, circle, startAngle, endAngle)
{ {
if (startAngle === undefined) { startAngle = 0; } if (startAngle === undefined) { startAngle = 0; }
if (endAngle === undefined) { endAngle = 6.28; } if (endAngle === undefined) { endAngle = 6.28; }
var angle = startAngle; var angle = startAngle;
var angleStep = (endAngle - startAngle) / items.length; var angleStep = (endAngle - startAngle) / items.length;
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
items[i].x = circle.x + (circle.radius * Math.cos(angle)); items[i].x = circle.x + (circle.radius * Math.cos(angle));
items[i].y = circle.y + (circle.radius * Math.sin(angle)); items[i].y = circle.y + (circle.radius * Math.sin(angle));
angle += angleStep; angle += angleStep;
} }
return items; return items;
}; };
module.exports = PlaceOnCircle; module.exports = PlaceOnCircle;

View file

@ -1,46 +1,46 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse. * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of an Ellipse.
* *
* If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property.
* *
* @function Phaser.Actions.PlaceOnEllipse * @function Phaser.Actions.PlaceOnEllipse
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Ellipse} ellipse - The Ellipse to position the Game Objects on. * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects on.
* @param {number} [startAngle=0] - Optional angle to start position from, in radians. * @param {number} [startAngle=0] - Optional angle to start position from, in radians.
* @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians. * @param {number} [endAngle=6.28] - Optional angle to stop position at, in radians.
* *
* @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 PlaceOnEllipse = function (items, ellipse, startAngle, endAngle) var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle)
{ {
if (startAngle === undefined) { startAngle = 0; } if (startAngle === undefined) { startAngle = 0; }
if (endAngle === undefined) { endAngle = 6.28; } if (endAngle === undefined) { endAngle = 6.28; }
var angle = startAngle; var angle = startAngle;
var angleStep = (endAngle - startAngle) / items.length; var angleStep = (endAngle - startAngle) / items.length;
var a = ellipse.width / 2; var a = ellipse.width / 2;
var b = ellipse.height / 2; var b = ellipse.height / 2;
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
items[i].x = ellipse.x + a * Math.cos(angle); items[i].x = ellipse.x + a * Math.cos(angle);
items[i].y = ellipse.y + b * Math.sin(angle); items[i].y = ellipse.y + b * Math.sin(angle);
angle += angleStep; angle += angleStep;
} }
return items; return items;
}; };
module.exports = PlaceOnEllipse; module.exports = PlaceOnEllipse;

View file

@ -1,38 +1,38 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var GetPoints = require('../geom/line/GetPoints'); var GetPoints = require('../geom/line/GetPoints');
/** /**
* 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.
* *
* @function Phaser.Actions.PlaceOnLine * @function Phaser.Actions.PlaceOnLine
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.
* *
* @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)
{ {
var points = GetPoints(line, items.length); var points = GetPoints(line, items.length);
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
var item = items[i]; var item = items[i];
var point = points[i]; var point = points[i];
item.x = point.x; item.x = point.x;
item.y = point.y; item.y = point.y;
} }
return items; return items;
}; };
module.exports = PlaceOnLine; module.exports = PlaceOnLine;

View file

@ -1,52 +1,52 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var MarchingAnts = require('../geom/rectangle/MarchingAnts'); var MarchingAnts = require('../geom/rectangle/MarchingAnts');
var RotateLeft = require('../utils/array/RotateLeft'); var RotateLeft = require('../utils/array/RotateLeft');
var RotateRight = require('../utils/array/RotateRight'); var RotateRight = require('../utils/array/RotateRight');
/** /**
* Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle. * Takes an array of Game Objects and positions them on evenly spaced points around the perimeter of a Rectangle.
* *
* Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction. * Placement starts from the top-left of the rectangle, and proceeds in a clockwise direction.
* If the `shift` parameter is given you can offset where placement begins. * If the `shift` parameter is given you can offset where placement begins.
* *
* @function Phaser.Actions.PlaceOnRectangle * @function Phaser.Actions.PlaceOnRectangle
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Rectangle} rect - The Rectangle to position the Game Objects on. * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on.
* @param {integer} [shift=1] - An optional positional offset. * @param {integer} [shift=1] - An optional positional offset.
* *
* @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 PlaceOnRectangle = function (items, rect, shift) var PlaceOnRectangle = function (items, rect, shift)
{ {
if (shift === undefined) { shift = 0; } if (shift === undefined) { shift = 0; }
var points = MarchingAnts(rect, false, items.length); var points = MarchingAnts(rect, false, items.length);
if (shift > 0) if (shift > 0)
{ {
RotateLeft(points, shift); RotateLeft(points, shift);
} }
else if (shift < 0) else if (shift < 0)
{ {
RotateRight(points, Math.abs(shift)); RotateRight(points, Math.abs(shift));
} }
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
items[i].x = points[i].x; items[i].x = points[i].x;
items[i].y = points[i].y; items[i].y = points[i].y;
} }
return items; return items;
}; };
module.exports = PlaceOnRectangle; module.exports = PlaceOnRectangle;

View file

@ -1,55 +1,55 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var BresenhamPoints = require('../geom/line/BresenhamPoints'); var BresenhamPoints = require('../geom/line/BresenhamPoints');
/** /**
* Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle. * Takes an array of Game Objects and positions them on evenly spaced points around the edges of a Triangle.
* *
* If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property.
* *
* @function Phaser.Actions.PlaceOnTriangle * @function Phaser.Actions.PlaceOnTriangle
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Triangle} triangle - The Triangle to position the Game Objects on. * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects on.
* @param {number} [stepRate=1] - An optional step rate, to increase or decrease the packing of the Game Objects on the lines. * @param {number} [stepRate=1] - An optional step rate, to increase or decrease the packing of the Game Objects on the lines.
* *
* @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 PlaceOnTriangle = function (items, triangle, stepRate) var PlaceOnTriangle = function (items, triangle, stepRate)
{ {
var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate); var p1 = BresenhamPoints({ x1: triangle.x1, y1: triangle.y1, x2: triangle.x2, y2: triangle.y2 }, stepRate);
var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate); var p2 = BresenhamPoints({ x1: triangle.x2, y1: triangle.y2, x2: triangle.x3, y2: triangle.y3 }, stepRate);
var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate); var p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate);
// Remove overlaps // Remove overlaps
p1.pop(); p1.pop();
p2.pop(); p2.pop();
p3.pop(); p3.pop();
p1 = p1.concat(p2, p3); p1 = p1.concat(p2, p3);
var step = p1.length / items.length; var step = p1.length / items.length;
var p = 0; var p = 0;
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
var item = items[i]; var item = items[i];
var point = p1[Math.floor(p)]; var point = p1[Math.floor(p)];
item.x = point.x; item.x = point.x;
item.y = point.y; item.y = point.y;
p += step; p += step;
} }
return items; return items;
}; };
module.exports = PlaceOnTriangle; module.exports = PlaceOnTriangle;

View file

@ -1,31 +1,31 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Play an animation with the given key, starting at the given startFrame on all Game Objects in items. * Play an animation with the given key, starting at the given startFrame on all Game Objects in items.
* *
* @function Phaser.Actions.PlayAnimation * @function Phaser.Actions.PlayAnimation
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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 {string} key - The name of the animation to play. * @param {string} key - The name of the animation to play.
* @param {(string|integer)} [startFrame] - The starting frame of the animation with the given key. * @param {(string|integer)} [startFrame] - The starting frame of the animation with the given key.
* *
* @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 PlayAnimation = function (items, key, startFrame) var PlayAnimation = function (items, key, startFrame)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
items[i].anims.play(key, startFrame); items[i].anims.play(key, startFrame);
} }
return items; return items;
}; };
module.exports = PlayAnimation; module.exports = PlayAnimation;

View file

@ -1,61 +1,61 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of Game Objects, or any objects that have a public property as defined in `key`, * Takes an array of Game Objects, or any objects that have a public property as defined in `key`,
* and then adds the given value to it. * and then adds the given value to it.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)` * To use this with a Group: `PropertyValueInc(group.getChildren(), key, value, step)`
* *
* @function Phaser.Actions.PropertyValueInc * @function Phaser.Actions.PropertyValueInc
* @since 3.3.0 * @since 3.3.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {string} key - The property to be updated. * @param {string} key - The property to be updated.
* @param {number} value - The amount to be added to the property. * @param {number} value - The amount to be added to the property.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var PropertyValueInc = function (items, key, value, step, index, direction) var PropertyValueInc = function (items, key, value, step, index, direction)
{ {
if (step === undefined) { step = 0; } if (step === undefined) { step = 0; }
if (index === undefined) { index = 0; } if (index === undefined) { index = 0; }
if (direction === undefined) { direction = 1; } if (direction === undefined) { direction = 1; }
var i; var i;
var t = 0; var t = 0;
var end = items.length; var end = items.length;
if (direction === 1) if (direction === 1)
{ {
// Start to End // Start to End
for (i = index; i < end; i++) for (i = index; i < end; i++)
{ {
items[i][key] += value + (t * step); items[i][key] += value + (t * step);
t++; t++;
} }
} }
else else
{ {
// End to Start // End to Start
for (i = index; i >= 0; i--) for (i = index; i >= 0; i--)
{ {
items[i][key] += value + (t * step); items[i][key] += value + (t * step);
t++; t++;
} }
} }
return items; return items;
}; };
module.exports = PropertyValueInc; module.exports = PropertyValueInc;

View file

@ -1,61 +1,61 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of Game Objects, or any objects that have a public property as defined in `key`, * Takes an array of Game Objects, or any objects that have a public property as defined in `key`,
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)` * To use this with a Group: `PropertyValueSet(group.getChildren(), key, value, step)`
* *
* @function Phaser.Actions.PropertyValueSet * @function Phaser.Actions.PropertyValueSet
* @since 3.3.0 * @since 3.3.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {string} key - The property to be updated. * @param {string} key - The property to be updated.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var PropertyValueSet = function (items, key, value, step, index, direction) var PropertyValueSet = function (items, key, value, step, index, direction)
{ {
if (step === undefined) { step = 0; } if (step === undefined) { step = 0; }
if (index === undefined) { index = 0; } if (index === undefined) { index = 0; }
if (direction === undefined) { direction = 1; } if (direction === undefined) { direction = 1; }
var i; var i;
var t = 0; var t = 0;
var end = items.length; var end = items.length;
if (direction === 1) if (direction === 1)
{ {
// Start to End // Start to End
for (i = index; i < end; i++) for (i = index; i < end; i++)
{ {
items[i][key] = value + (t * step); items[i][key] = value + (t * step);
t++; t++;
} }
} }
else else
{ {
// End to Start // End to Start
for (i = index; i >= 0; i--) for (i = index; i >= 0; i--)
{ {
items[i][key] = value + (t * step); items[i][key] = value + (t * step);
t++; t++;
} }
} }
return items; return items;
}; };
module.exports = PropertyValueSet; module.exports = PropertyValueSet;

View file

@ -1,34 +1,34 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Random = require('../geom/circle/Random'); var Random = require('../geom/circle/Random');
/** /**
* Takes an array of Game Objects and positions them at random locations within the Circle. * Takes an array of Game Objects and positions them at random locations within the Circle.
* *
* If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property. * If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property.
* *
* @function Phaser.Actions.RandomCircle * @function Phaser.Actions.RandomCircle
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Circle} circle - The Circle to position the Game Objects within. * @param {Phaser.Geom.Circle} circle - The Circle to position the Game Objects within.
* *
* @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 RandomCircle = function (items, circle) var RandomCircle = function (items, circle)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
Random(circle, items[i]); Random(circle, items[i]);
} }
return items; return items;
}; };
module.exports = RandomCircle; module.exports = RandomCircle;

View file

@ -1,34 +1,34 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Random = require('../geom/ellipse/Random'); var Random = require('../geom/ellipse/Random');
/** /**
* Takes an array of Game Objects and positions them at random locations within the Ellipse. * Takes an array of Game Objects and positions them at random locations within the Ellipse.
* *
* If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property. * If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property.
* *
* @function Phaser.Actions.RandomEllipse * @function Phaser.Actions.RandomEllipse
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Ellipse} ellipse - The Ellipse to position the Game Objects within. * @param {Phaser.Geom.Ellipse} ellipse - The Ellipse to position the Game Objects within.
* *
* @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 RandomEllipse = function (items, ellipse) var RandomEllipse = function (items, ellipse)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
Random(ellipse, items[i]); Random(ellipse, items[i]);
} }
return items; return items;
}; };
module.exports = RandomEllipse; module.exports = RandomEllipse;

View file

@ -1,34 +1,34 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Random = require('../geom/line/Random'); var Random = require('../geom/line/Random');
/** /**
* Takes an array of Game Objects and positions them at random locations on the Line. * Takes an array of Game Objects and positions them at random locations on the Line.
* *
* If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property. * If you wish to pass a `Phaser.GameObjects.Line` Shape to this function, you should pass its `geom` property.
* *
* @function Phaser.Actions.RandomLine * @function Phaser.Actions.RandomLine
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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 randomly on. * @param {Phaser.Geom.Line} line - The Line to position the Game Objects randomly on.
* *
* @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 RandomLine = function (items, line) var RandomLine = function (items, line)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
Random(line, items[i]); Random(line, items[i]);
} }
return items; return items;
}; };
module.exports = RandomLine; module.exports = RandomLine;

View file

@ -1,32 +1,32 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Random = require('../geom/rectangle/Random'); var Random = require('../geom/rectangle/Random');
/** /**
* Takes an array of Game Objects and positions them at random locations within the Rectangle. * Takes an array of Game Objects and positions them at random locations within the Rectangle.
* *
* @function Phaser.Actions.RandomRectangle * @function Phaser.Actions.RandomRectangle
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Rectangle} rect - The Rectangle to position the Game Objects within. * @param {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects within.
* *
* @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 RandomRectangle = function (items, rect) var RandomRectangle = function (items, rect)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
Random(rect, items[i]); Random(rect, items[i]);
} }
return items; return items;
}; };
module.exports = RandomRectangle; module.exports = RandomRectangle;

View file

@ -1,34 +1,34 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var Random = require('../geom/triangle/Random'); var Random = require('../geom/triangle/Random');
/** /**
* Takes an array of Game Objects and positions them at random locations within the Triangle. * Takes an array of Game Objects and positions them at random locations within the Triangle.
* *
* If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property. * If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property.
* *
* @function Phaser.Actions.RandomTriangle * @function Phaser.Actions.RandomTriangle
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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.Triangle} triangle - The Triangle to position the Game Objects within. * @param {Phaser.Geom.Triangle} triangle - The Triangle to position the Game Objects within.
* *
* @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 RandomTriangle = function (items, triangle) var RandomTriangle = function (items, triangle)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
Random(triangle, items[i]); Random(triangle, items[i]);
} }
return items; return items;
}; };
module.exports = RandomTriangle; module.exports = RandomTriangle;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have a public `rotation` property, * Takes an array of Game Objects, or any objects that have a public `rotation` property,
* and then adds the given value to each of their `rotation` properties. * and then adds the given value to each of their `rotation` properties.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `Rotate(group.getChildren(), value, step)` * To use this with a Group: `Rotate(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.Rotate * @function Phaser.Actions.Rotate
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to be added to the `rotation` property (in radians). * @param {number} value - The amount to be added to the `rotation` property (in radians).
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var Rotate = function (items, value, step, index, direction) var Rotate = function (items, value, step, index, direction)
{ {
return PropertyValueInc(items, 'rotation', value, step, index, direction); return PropertyValueInc(items, 'rotation', value, step, index, direction);
}; };
module.exports = Rotate; module.exports = Rotate;

View file

@ -1,40 +1,40 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var RotateAroundDistance = require('../math/RotateAroundDistance'); var RotateAroundDistance = require('../math/RotateAroundDistance');
var DistanceBetween = require('../math/distance/DistanceBetween'); var DistanceBetween = require('../math/distance/DistanceBetween');
/** /**
* Rotates each item around the given point by the given angle. * Rotates each item around the given point by the given angle.
* *
* @function Phaser.Actions.RotateAround * @function Phaser.Actions.RotateAround
* @since 3.0.0 * @since 3.0.0
* @see Phaser.Math.RotateAroundDistance * @see Phaser.Math.RotateAroundDistance
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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 {object} point - Any object with public `x` and `y` properties. * @param {object} point - Any object with public `x` and `y` properties.
* @param {number} angle - The angle to rotate by, in radians. * @param {number} angle - The angle to rotate by, in radians.
* *
* @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 RotateAround = function (items, point, angle) var RotateAround = function (items, point, angle)
{ {
var x = point.x; var x = point.x;
var y = point.y; var y = point.y;
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
var item = items[i]; var item = items[i];
RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y))); RotateAroundDistance(item, x, y, angle, Math.max(1, DistanceBetween(item.x, item.y, x, y)));
} }
return items; return items;
}; };
module.exports = RotateAround; module.exports = RotateAround;

View file

@ -1,43 +1,43 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var MathRotateAroundDistance = require('../math/RotateAroundDistance'); var MathRotateAroundDistance = require('../math/RotateAroundDistance');
/** /**
* Rotates an array of Game Objects around a point by the given angle and distance. * Rotates an array of Game Objects around a point by the given angle and distance.
* *
* @function Phaser.Actions.RotateAroundDistance * @function Phaser.Actions.RotateAroundDistance
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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 {object} point - Any object with public `x` and `y` properties. * @param {object} point - Any object with public `x` and `y` properties.
* @param {number} angle - The angle to rotate by, in radians. * @param {number} angle - The angle to rotate by, in radians.
* @param {number} distance - The distance from the point of rotation in pixels. * @param {number} distance - The distance from the point of rotation in pixels.
* *
* @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 RotateAroundDistance = function (items, point, angle, distance) var RotateAroundDistance = function (items, point, angle, distance)
{ {
var x = point.x; var x = point.x;
var y = point.y; var y = point.y;
// There's nothing to do // There's nothing to do
if (distance === 0) if (distance === 0)
{ {
return items; return items;
} }
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
MathRotateAroundDistance(items[i], x, y, angle, distance); MathRotateAroundDistance(items[i], x, y, angle, distance);
} }
return items; return items;
}; };
module.exports = RotateAroundDistance; module.exports = RotateAroundDistance;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have a public `scaleX` property, * Takes an array of Game Objects, or any objects that have a public `scaleX` property,
* and then adds the given value to each of their `scaleX` properties. * and then adds the given value to each of their `scaleX` properties.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `ScaleX(group.getChildren(), value, step)` * To use this with a Group: `ScaleX(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.ScaleX * @function Phaser.Actions.ScaleX
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to be added to the `scaleX` property. * @param {number} value - The amount to be added to the `scaleX` property.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var ScaleX = function (items, value, step, index, direction) var ScaleX = function (items, value, step, index, direction)
{ {
return PropertyValueInc(items, 'scaleX', value, step, index, direction); return PropertyValueInc(items, 'scaleX', value, step, index, direction);
}; };
module.exports = ScaleX; module.exports = ScaleX;

View file

@ -1,41 +1,41 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties, * Takes an array of Game Objects, or any objects that have public `scaleX` and `scaleY` properties,
* and then adds the given value to each of them. * and then adds the given value to each of them.
* *
* The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)` * To use this with a Group: `ScaleXY(group.getChildren(), scaleX, scaleY, stepX, stepY)`
* *
* @function Phaser.Actions.ScaleXY * @function Phaser.Actions.ScaleXY
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} scaleX - The amount to be added to the `scaleX` property. * @param {number} scaleX - The amount to be added to the `scaleX` property.
* @param {number} [scaleY] - The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value. * @param {number} [scaleY] - The amount to be added to the `scaleY` property. If `undefined` or `null` it uses the `scaleX` value.
* @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter.
* @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction) var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction)
{ {
if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } if (scaleY === undefined || scaleY === null) { scaleY = scaleX; }
PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction); PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction);
return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction); return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction);
}; };
module.exports = ScaleXY; module.exports = ScaleXY;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueInc = require('./PropertyValueInc'); var PropertyValueInc = require('./PropertyValueInc');
/** /**
* Takes an array of Game Objects, or any objects that have a public `scaleY` property, * Takes an array of Game Objects, or any objects that have a public `scaleY` property,
* and then adds the given value to each of their `scaleY` properties. * and then adds the given value to each of their `scaleY` properties.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `ScaleY(group.getChildren(), value, step)` * To use this with a Group: `ScaleY(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.ScaleY * @function Phaser.Actions.ScaleY
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to be added to the `scaleY` property. * @param {number} value - The amount to be added to the `scaleY` property.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var ScaleY = function (items, value, step, index, direction) var ScaleY = function (items, value, step, index, direction)
{ {
return PropertyValueInc(items, 'scaleY', value, step, index, direction); return PropertyValueInc(items, 'scaleY', value, step, index, direction);
}; };
module.exports = ScaleY; module.exports = ScaleY;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `alpha` * Takes an array of Game Objects, or any objects that have the public property `alpha`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetAlpha(group.getChildren(), value, step)` * To use this with a Group: `SetAlpha(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetAlpha * @function Phaser.Actions.SetAlpha
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetAlpha = function (items, value, step, index, direction) var SetAlpha = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'alpha', value, step, index, direction); return PropertyValueSet(items, 'alpha', value, step, index, direction);
}; };
module.exports = SetAlpha; module.exports = SetAlpha;

View file

@ -1,34 +1,34 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `blendMode` * Takes an array of Game Objects, or any objects that have the public property `blendMode`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetBlendMode(group.getChildren(), value)` * To use this with a Group: `SetBlendMode(group.getChildren(), value)`
* *
* @function Phaser.Actions.SetBlendMode * @function Phaser.Actions.SetBlendMode
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetBlendMode = function (items, value, index, direction) var SetBlendMode = function (items, value, index, direction)
{ {
return PropertyValueSet(items, 'blendMode', value, 0, index, direction); return PropertyValueSet(items, 'blendMode', value, 0, index, direction);
}; };
module.exports = SetBlendMode; module.exports = SetBlendMode;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `depth` * Takes an array of Game Objects, or any objects that have the public property `depth`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetDepth(group.getChildren(), value, step)` * To use this with a Group: `SetDepth(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetDepth * @function Phaser.Actions.SetDepth
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetDepth = function (items, value, step, index, direction) var SetDepth = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'depth', value, step, index, direction); return PropertyValueSet(items, 'depth', value, step, index, direction);
}; };
module.exports = SetDepth; module.exports = SetDepth;

View file

@ -1,33 +1,33 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks.
* *
* @see {@link Phaser.GameObjects.GameObject#setInteractive} * @see {@link Phaser.GameObjects.GameObject#setInteractive}
* *
* @function Phaser.Actions.SetHitArea * @function Phaser.Actions.SetHitArea
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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 {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used. * @param {*} hitArea - Either an input configuration object, or a geometric shape that defines the hit area for the Game Object. If not specified a Rectangle will be used.
* @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. * @param {Phaser.Types.Input.HitAreaCallback} hitAreaCallback - A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback.
* *
* @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 SetHitArea = function (items, hitArea, hitAreaCallback) var SetHitArea = function (items, hitArea, hitAreaCallback)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
items[i].setInteractive(hitArea, hitAreaCallback); items[i].setInteractive(hitArea, hitAreaCallback);
} }
return items; return items;
}; };
module.exports = SetHitArea; module.exports = SetHitArea;

View file

@ -1,41 +1,41 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY` * Takes an array of Game Objects, or any objects that have the public properties `originX` and `originY`
* and then sets them to the given values. * and then sets them to the given values.
* *
* The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)` * To use this with a Group: `SetOrigin(group.getChildren(), originX, originY, stepX, stepY)`
* *
* @function Phaser.Actions.SetOrigin * @function Phaser.Actions.SetOrigin
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} originX - The amount to set the `originX` property to. * @param {number} originX - The amount to set the `originX` property to.
* @param {number} [originY] - The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value. * @param {number} [originY] - The amount to set the `originY` property to. If `undefined` or `null` it uses the `originX` value.
* @param {number} [stepX=0] - This is added to the `originX` amount, multiplied by the iteration counter. * @param {number} [stepX=0] - This is added to the `originX` amount, multiplied by the iteration counter.
* @param {number} [stepY=0] - This is added to the `originY` amount, multiplied by the iteration counter. * @param {number} [stepY=0] - This is added to the `originY` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction) var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction)
{ {
if (originY === undefined || originY === null) { originY = originX; } if (originY === undefined || originY === null) { originY = originX; }
PropertyValueSet(items, 'originX', originX, stepX, index, direction); PropertyValueSet(items, 'originX', originX, stepX, index, direction);
return PropertyValueSet(items, 'originY', originY, stepY, index, direction); return PropertyValueSet(items, 'originY', originY, stepY, index, direction);
}; };
module.exports = SetOrigin; module.exports = SetOrigin;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `rotation` * Takes an array of Game Objects, or any objects that have the public property `rotation`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetRotation(group.getChildren(), value, step)` * To use this with a Group: `SetRotation(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetRotation * @function Phaser.Actions.SetRotation
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetRotation = function (items, value, step, index, direction) var SetRotation = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'rotation', value, step, index, direction); return PropertyValueSet(items, 'rotation', value, step, index, direction);
}; };
module.exports = SetRotation; module.exports = SetRotation;

View file

@ -1,41 +1,41 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY` * Takes an array of Game Objects, or any objects that have the public properties `scaleX` and `scaleY`
* and then sets them to the given values. * and then sets them to the given values.
* *
* The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)` * To use this with a Group: `SetScale(group.getChildren(), scaleX, scaleY, stepX, stepY)`
* *
* @function Phaser.Actions.SetScale * @function Phaser.Actions.SetScale
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} scaleX - The amount to set the `scaleX` property to. * @param {number} scaleX - The amount to set the `scaleX` property to.
* @param {number} [scaleY] - The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value. * @param {number} [scaleY] - The amount to set the `scaleY` property to. If `undefined` or `null` it uses the `scaleX` value.
* @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter. * @param {number} [stepX=0] - This is added to the `scaleX` amount, multiplied by the iteration counter.
* @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter. * @param {number} [stepY=0] - This is added to the `scaleY` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction) var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction)
{ {
if (scaleY === undefined || scaleY === null) { scaleY = scaleX; } if (scaleY === undefined || scaleY === null) { scaleY = scaleX; }
PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction); PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction);
return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction); return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction);
}; };
module.exports = SetScale; module.exports = SetScale;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `scaleX` * Takes an array of Game Objects, or any objects that have the public property `scaleX`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetScaleX(group.getChildren(), value, step)` * To use this with a Group: `SetScaleX(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetScaleX * @function Phaser.Actions.SetScaleX
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetScaleX = function (items, value, step, index, direction) var SetScaleX = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'scaleX', value, step, index, direction); return PropertyValueSet(items, 'scaleX', value, step, index, direction);
}; };
module.exports = SetScaleX; module.exports = SetScaleX;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `scaleY` * Takes an array of Game Objects, or any objects that have the public property `scaleY`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetScaleY(group.getChildren(), value, step)` * To use this with a Group: `SetScaleY(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetScaleY * @function Phaser.Actions.SetScaleY
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetScaleY = function (items, value, step, index, direction) var SetScaleY = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'scaleY', value, step, index, direction); return PropertyValueSet(items, 'scaleY', value, step, index, direction);
}; };
module.exports = SetScaleY; module.exports = SetScaleY;

View file

@ -1,41 +1,41 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public properties `scrollFactorX` and `scrollFactorY` * Takes an array of Game Objects, or any objects that have the public properties `scrollFactorX` and `scrollFactorY`
* and then sets them to the given values. * and then sets them to the given values.
* *
* The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetScrollFactor(group.getChildren(), scrollFactorX, scrollFactorY, stepX, stepY)` * To use this with a Group: `SetScrollFactor(group.getChildren(), scrollFactorX, scrollFactorY, stepX, stepY)`
* *
* @function Phaser.Actions.SetScrollFactor * @function Phaser.Actions.SetScrollFactor
* @since 3.21.0 * @since 3.21.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} scrollFactorX - The amount to set the `scrollFactorX` property to. * @param {number} scrollFactorX - The amount to set the `scrollFactorX` property to.
* @param {number} [scrollFactorY] - The amount to set the `scrollFactorY` property to. If `undefined` or `null` it uses the `scrollFactorX` value. * @param {number} [scrollFactorY] - The amount to set the `scrollFactorY` property to. If `undefined` or `null` it uses the `scrollFactorX` value.
* @param {number} [stepX=0] - This is added to the `scrollFactorX` amount, multiplied by the iteration counter. * @param {number} [stepX=0] - This is added to the `scrollFactorX` amount, multiplied by the iteration counter.
* @param {number} [stepY=0] - This is added to the `scrollFactorY` amount, multiplied by the iteration counter. * @param {number} [stepY=0] - This is added to the `scrollFactorY` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetScrollFactor = function (items, scrollFactorX, scrollFactorY, stepX, stepY, index, direction) var SetScrollFactor = function (items, scrollFactorX, scrollFactorY, stepX, stepY, index, direction)
{ {
if (scrollFactorY === undefined || scrollFactorY === null) { scrollFactorY = scrollFactorX; } if (scrollFactorY === undefined || scrollFactorY === null) { scrollFactorY = scrollFactorX; }
PropertyValueSet(items, 'scrollFactorX', scrollFactorX, stepX, index, direction); PropertyValueSet(items, 'scrollFactorX', scrollFactorX, stepX, index, direction);
return PropertyValueSet(items, 'scrollFactorY', scrollFactorY, stepY, index, direction); return PropertyValueSet(items, 'scrollFactorY', scrollFactorY, stepY, index, direction);
}; };
module.exports = SetScrollFactor; module.exports = SetScrollFactor;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorX` * Takes an array of Game Objects, or any objects that have the public property `scrollFactorX`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetScrollFactorX(group.getChildren(), value, step)` * To use this with a Group: `SetScrollFactorX(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetScrollFactorX * @function Phaser.Actions.SetScrollFactorX
* @since 3.21.0 * @since 3.21.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetScrollFactorX = function (items, value, step, index, direction) var SetScrollFactorX = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'scrollFactorX', value, step, index, direction); return PropertyValueSet(items, 'scrollFactorX', value, step, index, direction);
}; };
module.exports = SetScrollFactorX; module.exports = SetScrollFactorX;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorY` * Takes an array of Game Objects, or any objects that have the public property `scrollFactorY`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetScrollFactorY(group.getChildren(), value, step)` * To use this with a Group: `SetScrollFactorY(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetScrollFactorY * @function Phaser.Actions.SetScrollFactorY
* @since 3.21.0 * @since 3.21.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetScrollFactorY = function (items, value, step, index, direction) var SetScrollFactorY = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'scrollFactorY', value, step, index, direction); return PropertyValueSet(items, 'scrollFactorY', value, step, index, direction);
}; };
module.exports = SetScrollFactorY; module.exports = SetScrollFactorY;

View file

@ -1,33 +1,33 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
/** /**
* Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color. * Takes an array of Game Objects, or any objects that have the public method setTint() and then updates it to the given value(s). You can specify tint color per corner or provide only one color value for `topLeft` parameter, in which case whole item will be tinted with that color.
* *
* @function Phaser.Actions.SetTint * @function Phaser.Actions.SetTint
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @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 {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item. * @param {number} topLeft - The tint being applied to top-left corner of item. If other parameters are given no value, this tint will be applied to whole item.
* @param {number} [topRight] - The tint to be applied to top-right corner of item. * @param {number} [topRight] - The tint to be applied to top-right corner of item.
* @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item. * @param {number} [bottomLeft] - The tint to be applied to the bottom-left corner of item.
* @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item. * @param {number} [bottomRight] - The tint to be applied to the bottom-right corner of item.
* *
* @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 SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight) var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight)
{ {
for (var i = 0; i < items.length; i++) for (var i = 0; i < items.length; i++)
{ {
items[i].setTint(topLeft, topRight, bottomLeft, bottomRight); items[i].setTint(topLeft, topRight, bottomLeft, bottomRight);
} }
return items; return items;
}; };
module.exports = SetTint; module.exports = SetTint;

View file

@ -1,32 +1,32 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `visible` * Takes an array of Game Objects, or any objects that have the public property `visible`
* and then sets it to the given value. * and then sets it to the given value.
* *
* To use this with a Group: `SetVisible(group.getChildren(), value)` * To use this with a Group: `SetVisible(group.getChildren(), value)`
* *
* @function Phaser.Actions.SetVisible * @function Phaser.Actions.SetVisible
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {boolean} value - The value to set the property to. * @param {boolean} value - The value to set the property to.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetVisible = function (items, value, index, direction) var SetVisible = function (items, value, index, direction)
{ {
return PropertyValueSet(items, 'visible', value, 0, index, direction); return PropertyValueSet(items, 'visible', value, 0, index, direction);
}; };
module.exports = SetVisible; module.exports = SetVisible;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `x` * Takes an array of Game Objects, or any objects that have the public property `x`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetX(group.getChildren(), value, step)` * To use this with a Group: `SetX(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetX * @function Phaser.Actions.SetX
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetX = function (items, value, step, index, direction) var SetX = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'x', value, step, index, direction); return PropertyValueSet(items, 'x', value, step, index, direction);
}; };
module.exports = SetX; module.exports = SetX;

View file

@ -1,41 +1,41 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public properties `x` and `y` * Takes an array of Game Objects, or any objects that have the public properties `x` and `y`
* and then sets them to the given values. * and then sets them to the given values.
* *
* The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array. * The optional `stepX` and `stepY` properties are applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)` * To use this with a Group: `SetXY(group.getChildren(), x, y, stepX, stepY)`
* *
* @function Phaser.Actions.SetXY * @function Phaser.Actions.SetXY
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} x - The amount to set the `x` property to. * @param {number} x - The amount to set the `x` property to.
* @param {number} [y=x] - The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value. * @param {number} [y=x] - The amount to set the `y` property to. If `undefined` or `null` it uses the `x` value.
* @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter. * @param {number} [stepX=0] - This is added to the `x` amount, multiplied by the iteration counter.
* @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter. * @param {number} [stepY=0] - This is added to the `y` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetXY = function (items, x, y, stepX, stepY, index, direction) var SetXY = function (items, x, y, stepX, stepY, index, direction)
{ {
if (y === undefined || y === null) { y = x; } if (y === undefined || y === null) { y = x; }
PropertyValueSet(items, 'x', x, stepX, index, direction); PropertyValueSet(items, 'x', x, stepX, index, direction);
return PropertyValueSet(items, 'y', y, stepY, index, direction); return PropertyValueSet(items, 'y', y, stepY, index, direction);
}; };
module.exports = SetXY; module.exports = SetXY;

View file

@ -1,35 +1,35 @@
/** /**
* @author Richard Davey <rich@photonstorm.com> * @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd. * @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License} * @license {@link https://opensource.org/licenses/MIT|MIT License}
*/ */
var PropertyValueSet = require('./PropertyValueSet'); var PropertyValueSet = require('./PropertyValueSet');
/** /**
* Takes an array of Game Objects, or any objects that have the public property `y` * Takes an array of Game Objects, or any objects that have the public property `y`
* and then sets it to the given value. * and then sets it to the given value.
* *
* The optional `step` property is applied incrementally, multiplied by each item in the array. * The optional `step` property is applied incrementally, multiplied by each item in the array.
* *
* To use this with a Group: `SetY(group.getChildren(), value, step)` * To use this with a Group: `SetY(group.getChildren(), value, step)`
* *
* @function Phaser.Actions.SetY * @function Phaser.Actions.SetY
* @since 3.0.0 * @since 3.0.0
* *
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return] * @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
* *
* @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action. * @param {(array|Phaser.GameObjects.GameObject[])} items - The array of items to be updated by this action.
* @param {number} value - The amount to set the property to. * @param {number} value - The amount to set the property to.
* @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter. * @param {number} [step=0] - This is added to the `value` amount, multiplied by the iteration counter.
* @param {integer} [index=0] - An optional offset to start searching from within the items array. * @param {integer} [index=0] - An optional offset to start searching from within the items array.
* @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning. * @param {integer} [direction=1] - The direction to iterate through the array. 1 is from beginning to end, -1 from end to beginning.
* *
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action. * @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/ */
var SetY = function (items, value, step, index, direction) var SetY = function (items, value, step, index, direction)
{ {
return PropertyValueSet(items, 'y', value, step, index, direction); return PropertyValueSet(items, 'y', value, step, index, direction);
}; };
module.exports = SetY; module.exports = SetY;

Some files were not shown because too many files have changed in this diff Show more