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
Thumbs.db
.DS_Store
.idea
.vscode
*.suo
*.sublime-project
*.sublime-workspace
# Vendors
node_modules/
# Build
/npm-debug.log
build/
out/
scripts/tsgen/test/bin/
scripts/tsgen/test/output.txt
# System and IDE files
Thumbs.db
.DS_Store
.idea
.vscode
*.suo
*.sublime-project
*.sublime-workspace
# Vendors
node_modules/
# Build
/npm-debug.log
build/
out/
scripts/tsgen/test/bin/
scripts/tsgen/test/output.txt
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",
"version": "3.23.0-beta1",
"release": "Ginro",
"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)",
"homepage": "http://phaser.io",
"bugs": "https://github.com/photonstorm/phaser/issues",
"license": "MIT",
"licenseUrl": "http://www.opensource.org/licenses/mit-license.php",
"main": "./src/phaser.js",
"types": "./types/phaser.d.ts",
"repository": {
"type": "git",
"url": "https://photonstorm@github.com/photonstorm/phaser.git"
},
"scripts": {
"beta": "npm publish --tag beta",
"help": "node scripts/help.js",
"build": "webpack --config config/webpack.config.js",
"watch": "webpack --watch --config config/webpack.config.js",
"buildfb": "webpack --config config/webpack.fb.config.js",
"watchfb": "webpack --config config/webpack.fb.config.js --watch",
"dist": "webpack --config config/webpack.dist.config.js",
"distT": "webpack --config config/webpack.dist.config.js && npm run toT",
"toT": "@powershell Copy-Item ./dist/phaser.min.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",
"distfull": "npm run dist && npm run distfb",
"plugin.cam3d": "webpack --config plugins/camera3d/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.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.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.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.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.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",
"lint": "eslint --config .eslintrc.json \"src/**/*.js\"",
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",
"sloc": "node-sloc \"./src\" --include-extensions \"js\"",
"bundleshaders": "node scripts/bundle-shaders.js",
"postinstall": "node scripts/support.js",
"build-tsgen": "cd scripts/tsgen && tsc",
"tsgen": "cd scripts/tsgen && jsdoc -c jsdoc-tsd.conf.json",
"test-ts": "cd scripts/tsgen/test && tsc > output.txt",
"ts": "npm run tsgen && npm run test-ts",
"tsdev": "npm run build-tsgen && npm run tsgen && npm run test-ts"
},
"keywords": [
"2d",
"HTML5",
"WebGL",
"canvas",
"game",
"javascript",
"physics",
"tweens",
"typescript",
"web audio"
],
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"dts-dom": "^3.3.0",
"eslint": "^4.19.1",
"eslint-plugin-es5": "^1.3.1",
"fs-extra": "^6.0.1",
"jsdoc": "^3.6.3",
"node-sloc": "^0.1.11",
"remove-files-webpack-plugin": "^1.1.3",
"typescript": "^3.4.5",
"uglifyjs-webpack-plugin": "^1.3.0",
"vivid-cli": "^1.1.2",
"webpack": "^4.23.0",
"webpack-cli": "^3.1.1",
"webpack-shell-plugin": "^0.5.0"
},
"dependencies": {
"eventemitter3": "^3.1.0",
"exports-loader": "^0.7.0",
"imports-loader": "^0.8.0",
"path": "^0.12.7"
}
}
{
"name": "phaser",
"version": "3.23.0-beta1",
"release": "Ginro",
"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)",
"homepage": "http://phaser.io",
"bugs": "https://github.com/photonstorm/phaser/issues",
"license": "MIT",
"licenseUrl": "http://www.opensource.org/licenses/mit-license.php",
"main": "./src/phaser.js",
"types": "./types/phaser.d.ts",
"repository": {
"type": "git",
"url": "https://photonstorm@github.com/photonstorm/phaser.git"
},
"scripts": {
"beta": "npm publish --tag beta",
"help": "node scripts/help.js",
"build": "webpack --config config/webpack.config.js",
"watch": "webpack --watch --config config/webpack.config.js",
"buildfb": "webpack --config config/webpack.fb.config.js",
"watchfb": "webpack --config config/webpack.fb.config.js --watch",
"dist": "webpack --config config/webpack.dist.config.js",
"distT": "webpack --config config/webpack.dist.config.js && npm run toT",
"toT": "@powershell Copy-Item ./dist/phaser.min.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",
"distfull": "npm run dist && npm run distfb",
"plugin.cam3d": "webpack --config plugins/camera3d/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.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.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.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.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.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",
"lint": "eslint --config .eslintrc.json \"src/**/*.js\"",
"lintfix": "eslint --config .eslintrc.json \"src/**/*.js\" --fix",
"sloc": "node-sloc \"./src\" --include-extensions \"js\"",
"bundleshaders": "node scripts/bundle-shaders.js",
"postinstall": "node scripts/support.js",
"build-tsgen": "cd scripts/tsgen && tsc",
"tsgen": "cd scripts/tsgen && jsdoc -c jsdoc-tsd.conf.json",
"test-ts": "cd scripts/tsgen/test && tsc > output.txt",
"ts": "npm run tsgen && npm run test-ts",
"tsdev": "npm run build-tsgen && npm run tsgen && npm run test-ts"
},
"keywords": [
"2d",
"HTML5",
"WebGL",
"canvas",
"game",
"javascript",
"physics",
"tweens",
"typescript",
"web audio"
],
"devDependencies": {
"clean-webpack-plugin": "^0.1.19",
"dts-dom": "^3.3.0",
"eslint": "^4.19.1",
"eslint-plugin-es5": "^1.3.1",
"fs-extra": "^6.0.1",
"jsdoc": "^3.6.3",
"node-sloc": "^0.1.11",
"remove-files-webpack-plugin": "^1.1.3",
"typescript": "^3.4.5",
"uglifyjs-webpack-plugin": "^1.3.0",
"vivid-cli": "^1.1.2",
"webpack": "^4.23.0",
"webpack-cli": "^3.1.1",
"webpack-shell-plugin": "^0.5.0"
},
"dependencies": {
"eventemitter3": "^3.1.0",
"exports-loader": "^0.7.0",
"imports-loader": "^0.8.0",
"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>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* 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,
* 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
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.COLLIDES
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Never collides.
*
* @name Phaser.Physics.Impact.COLLIDES.NEVER
* @type {integer}
* @const
* @since 3.0.0
*/
NEVER: 0,
/**
* Lite collision.
*
* @name Phaser.Physics.Impact.COLLIDES.LITE
* @type {integer}
* @const
* @since 3.0.0
*/
LITE: 1,
/**
* Passive collision.
*
* @name Phaser.Physics.Impact.COLLIDES.PASSIVE
* @type {integer}
* @const
* @since 3.0.0
*/
PASSIVE: 2,
/**
* Active collision.
*
* @name Phaser.Physics.Impact.COLLIDES.ACTIVE
* @type {integer}
* @const
* @since 3.0.0
*/
ACTIVE: 4,
/**
* Fixed collision.
*
* @name Phaser.Physics.Impact.COLLIDES.FIXED
* @type {integer}
* @const
* @since 3.0.0
*/
FIXED: 8
};
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* 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,
* 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
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.COLLIDES
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Never collides.
*
* @name Phaser.Physics.Impact.COLLIDES.NEVER
* @type {integer}
* @const
* @since 3.0.0
*/
NEVER: 0,
/**
* Lite collision.
*
* @name Phaser.Physics.Impact.COLLIDES.LITE
* @type {integer}
* @const
* @since 3.0.0
*/
LITE: 1,
/**
* Passive collision.
*
* @name Phaser.Physics.Impact.COLLIDES.PASSIVE
* @type {integer}
* @const
* @since 3.0.0
*/
PASSIVE: 2,
/**
* Active collision.
*
* @name Phaser.Physics.Impact.COLLIDES.ACTIVE
* @type {integer}
* @const
* @since 3.0.0
*/
ACTIVE: 4,
/**
* Fixed collision.
*
* @name Phaser.Physics.Impact.COLLIDES.FIXED
* @type {integer}
* @const
* @since 3.0.0
*/
FIXED: 8
};

View file

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

View file

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

View file

@ -1,151 +1,151 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var ImpactBody = require('./ImpactBody');
var ImpactImage = require('./ImpactImage');
var ImpactSprite = require('./ImpactSprite');
/**
* @classdesc
* 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.
*
* @class Factory
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world.
*/
var Factory = new Class({
initialize:
function Factory (world)
{
/**
* A reference to the Impact Physics world.
*
* @name Phaser.Physics.Impact.Factory#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world = world;
/**
* A reference to the Scene.Systems this Impact Physics instance belongs to.
*
* @name Phaser.Physics.Impact.Factory#sys
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.sys = world.scene.sys;
},
/**
* Creates a new ImpactBody object and adds it to the physics simulation.
*
* @method Phaser.Physics.Impact.Factory#body
* @since 3.0.0
*
* @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} width - The width of the body.
* @param {number} height - The height of the body.
*
* @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created.
*/
body: function (x, y, width, height)
{
return new ImpactBody(this.world, x, y, width, height);
},
/**
* Adds an Impact Physics Body to the given Game Object.
*
* @method Phaser.Physics.Impact.Factory#existing
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body.
*
* @return {Phaser.GameObjects.GameObject} The Game Object.
*/
existing: function (gameObject)
{
var x = gameObject.x - gameObject.frame.centerX;
var y = gameObject.y - gameObject.frame.centerY;
var w = gameObject.width;
var h = gameObject.height;
gameObject.body = this.world.create(x, y, w, h);
gameObject.body.parent = gameObject;
gameObject.body.gameObject = gameObject;
return gameObject;
},
/**
* Creates a new ImpactImage object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#image
* @since 3.0.0
*
* @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 {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.
*
* @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created.
*/
image: function (x, y, key, frame)
{
var image = new ImpactImage(this.world, x, y, key, frame);
this.sys.displayList.add(image);
return image;
},
/**
* Creates a new ImpactSprite object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#sprite
* @since 3.0.0
*
* @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 {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.
*
* @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created.
*/
sprite: function (x, y, key, frame)
{
var sprite = new ImpactSprite(this.world, x, y, key, frame);
this.sys.displayList.add(sprite);
this.sys.updateList.add(sprite);
return sprite;
},
/**
* Destroys this Factory.
*
* @method Phaser.Physics.Impact.Factory#destroy
* @since 3.5.0
*/
destroy: function ()
{
this.world = null;
this.sys = null;
}
});
module.exports = Factory;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var ImpactBody = require('./ImpactBody');
var ImpactImage = require('./ImpactImage');
var ImpactSprite = require('./ImpactSprite');
/**
* @classdesc
* 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.
*
* @class Factory
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.World} world - A reference to the Impact Physics world.
*/
var Factory = new Class({
initialize:
function Factory (world)
{
/**
* A reference to the Impact Physics world.
*
* @name Phaser.Physics.Impact.Factory#world
* @type {Phaser.Physics.Impact.World}
* @since 3.0.0
*/
this.world = world;
/**
* A reference to the Scene.Systems this Impact Physics instance belongs to.
*
* @name Phaser.Physics.Impact.Factory#sys
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.sys = world.scene.sys;
},
/**
* Creates a new ImpactBody object and adds it to the physics simulation.
*
* @method Phaser.Physics.Impact.Factory#body
* @since 3.0.0
*
* @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} width - The width of the body.
* @param {number} height - The height of the body.
*
* @return {Phaser.Physics.Impact.ImpactBody} The ImpactBody object that was created.
*/
body: function (x, y, width, height)
{
return new ImpactBody(this.world, x, y, width, height);
},
/**
* Adds an Impact Physics Body to the given Game Object.
*
* @method Phaser.Physics.Impact.Factory#existing
* @since 3.0.0
*
* @param {Phaser.GameObjects.GameObject} gameObject - The Game Object to receive the physics body.
*
* @return {Phaser.GameObjects.GameObject} The Game Object.
*/
existing: function (gameObject)
{
var x = gameObject.x - gameObject.frame.centerX;
var y = gameObject.y - gameObject.frame.centerY;
var w = gameObject.width;
var h = gameObject.height;
gameObject.body = this.world.create(x, y, w, h);
gameObject.body.parent = gameObject;
gameObject.body.gameObject = gameObject;
return gameObject;
},
/**
* Creates a new ImpactImage object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#image
* @since 3.0.0
*
* @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 {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.
*
* @return {Phaser.Physics.Impact.ImpactImage} The ImpactImage object that was created.
*/
image: function (x, y, key, frame)
{
var image = new ImpactImage(this.world, x, y, key, frame);
this.sys.displayList.add(image);
return image;
},
/**
* Creates a new ImpactSprite object and adds it to the physics world.
*
* @method Phaser.Physics.Impact.Factory#sprite
* @since 3.0.0
*
* @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 {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.
*
* @return {Phaser.Physics.Impact.ImpactSprite} The ImpactSprite object that was created.
*/
sprite: function (x, y, key, frame)
{
var sprite = new ImpactSprite(this.world, x, y, key, frame);
this.sys.displayList.add(sprite);
this.sys.updateList.add(sprite);
return sprite;
},
/**
* Destroys this Factory.
*
* @method Phaser.Physics.Impact.Factory#destroy
* @since 3.5.0
*/
destroy: function ()
{
this.world = null;
this.sys = null;
}
});
module.exports = Factory;

View file

@ -1,50 +1,50 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Clamp = require('../../math/Clamp');
/**
* [description]
*
* @function Phaser.Physics.Impact.GetVelocity
* @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} vel - [description]
* @param {number} accel - [description]
* @param {number} friction - [description]
* @param {number} max - [description]
*
* @return {number} [description]
*/
var GetVelocity = function (delta, vel, accel, friction, max)
{
if (accel)
{
return Clamp(vel + accel * delta, -max, max);
}
else if (friction)
{
var frictionDelta = friction * delta;
if (vel - frictionDelta > 0)
{
return vel - frictionDelta;
}
else if (vel + frictionDelta < 0)
{
return vel + frictionDelta;
}
else
{
return 0;
}
}
return Clamp(vel, -max, max);
};
module.exports = GetVelocity;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Clamp = require('../../math/Clamp');
/**
* [description]
*
* @function Phaser.Physics.Impact.GetVelocity
* @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} vel - [description]
* @param {number} accel - [description]
* @param {number} friction - [description]
* @param {number} max - [description]
*
* @return {number} [description]
*/
var GetVelocity = function (delta, vel, accel, friction, max)
{
if (accel)
{
return Clamp(vel + accel * delta, -max, max);
}
else if (friction)
{
var frictionDelta = friction * delta;
if (vel - frictionDelta > 0)
{
return vel - frictionDelta;
}
else if (vel + frictionDelta < 0)
{
return vel + frictionDelta;
}
else
{
return 0;
}
}
return Clamp(vel, -max, max);
};
module.exports = GetVelocity;

View file

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

View file

@ -1,152 +1,152 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Image = require('../../gameobjects/image/Image');
/**
* @classdesc
* An Impact Physics Image Game Object.
*
* 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
* 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.
*
* @class ImpactImage
* @extends Phaser.GameObjects.Image
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @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} 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|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactImage = new Class({
Extends: Image,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactImage (world, x, y, texture, frame)
{
Image.call(this, world.scene, x, y, texture, frame);
/**
* The Physics Body linked to an ImpactImage.
*
* @name Phaser.Physics.Impact.ImpactImage#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* The size of the physics Body.
*
* @name Phaser.Physics.Impact.ImpactImage#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* The X and Y offset of the Body from the left and top of the Image.
*
* @name Phaser.Physics.Impact.ImpactImage#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* The velocity, or rate of change the Body's position. Measured in pixels per second.
*
* @name Phaser.Physics.Impact.ImpactImage#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* The acceleration is the rate of change of the velocity. Measured in pixels per second squared.
*
* @name Phaser.Physics.Impact.ImpactImage#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* Friction between colliding bodies.
*
* @name Phaser.Physics.Impact.ImpactImage#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* The maximum velocity of the body.
*
* @name Phaser.Physics.Impact.ImpactImage#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactImage;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Image = require('../../gameobjects/image/Image');
/**
* @classdesc
* An Impact Physics Image Game Object.
*
* 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
* 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.
*
* @class ImpactImage
* @extends Phaser.GameObjects.Image
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @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} 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|integer)} [frame] - An optional frame from the Texture this Game Object is rendering with.
*/
var ImpactImage = new Class({
Extends: Image,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactImage (world, x, y, texture, frame)
{
Image.call(this, world.scene, x, y, texture, frame);
/**
* The Physics Body linked to an ImpactImage.
*
* @name Phaser.Physics.Impact.ImpactImage#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* The size of the physics Body.
*
* @name Phaser.Physics.Impact.ImpactImage#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* The X and Y offset of the Body from the left and top of the Image.
*
* @name Phaser.Physics.Impact.ImpactImage#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* The velocity, or rate of change the Body's position. Measured in pixels per second.
*
* @name Phaser.Physics.Impact.ImpactImage#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* The acceleration is the rate of change of the velocity. Measured in pixels per second squared.
*
* @name Phaser.Physics.Impact.ImpactImage#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* Friction between colliding bodies.
*
* @name Phaser.Physics.Impact.ImpactImage#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* The maximum velocity of the body.
*
* @name Phaser.Physics.Impact.ImpactImage#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactImage;

View file

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

View file

@ -1,155 +1,155 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Sprite = require('../../gameobjects/sprite/Sprite');
/**
* @classdesc
* An Impact Physics Sprite Game Object.
*
* 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
* and animated.
*
* 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
* Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
*
* @class ImpactSprite
* @extends Phaser.GameObjects.Sprite
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @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 {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.
*/
var ImpactSprite = new Class({
Extends: Sprite,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactSprite (world, x, y, texture, frame)
{
Sprite.call(this, world.scene, x, y, texture, frame);
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactSprite;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Class = require('../../utils/Class');
var Components = require('./components');
var Sprite = require('../../gameobjects/sprite/Sprite');
/**
* @classdesc
* An Impact Physics Sprite Game Object.
*
* 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
* and animated.
*
* 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
* Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.
*
* @class ImpactSprite
* @extends Phaser.GameObjects.Sprite
* @memberof Phaser.Physics.Impact
* @constructor
* @since 3.0.0
*
* @extends Phaser.Physics.Impact.Components.Acceleration
* @extends Phaser.Physics.Impact.Components.BodyScale
* @extends Phaser.Physics.Impact.Components.BodyType
* @extends Phaser.Physics.Impact.Components.Bounce
* @extends Phaser.Physics.Impact.Components.CheckAgainst
* @extends Phaser.Physics.Impact.Components.Collides
* @extends Phaser.Physics.Impact.Components.Debug
* @extends Phaser.Physics.Impact.Components.Friction
* @extends Phaser.Physics.Impact.Components.Gravity
* @extends Phaser.Physics.Impact.Components.Offset
* @extends Phaser.Physics.Impact.Components.SetGameObject
* @extends Phaser.Physics.Impact.Components.Velocity
* @extends Phaser.GameObjects.Components.Alpha
* @extends Phaser.GameObjects.Components.BlendMode
* @extends Phaser.GameObjects.Components.Depth
* @extends Phaser.GameObjects.Components.Flip
* @extends Phaser.GameObjects.Components.GetBounds
* @extends Phaser.GameObjects.Components.Origin
* @extends Phaser.GameObjects.Components.Pipeline
* @extends Phaser.GameObjects.Components.ScrollFactor
* @extends Phaser.GameObjects.Components.Size
* @extends Phaser.GameObjects.Components.Texture
* @extends Phaser.GameObjects.Components.Tint
* @extends Phaser.GameObjects.Components.Transform
* @extends Phaser.GameObjects.Components.Visible
*
* @param {Phaser.Physics.Impact.World} world - [description]
* @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 {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.
*/
var ImpactSprite = new Class({
Extends: Sprite,
Mixins: [
Components.Acceleration,
Components.BodyScale,
Components.BodyType,
Components.Bounce,
Components.CheckAgainst,
Components.Collides,
Components.Debug,
Components.Friction,
Components.Gravity,
Components.Offset,
Components.SetGameObject,
Components.Velocity
],
initialize:
function ImpactSprite (world, x, y, texture, frame)
{
Sprite.call(this, world.scene, x, y, texture, frame);
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#body
* @type {Phaser.Physics.Impact.Body}
* @since 3.0.0
*/
this.body = world.create(x - this.frame.centerX, y - this.frame.centerY, this.width, this.height);
this.body.parent = this;
this.body.gameObject = this;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#size
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.size = this.body.size;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#offset
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.offset = this.body.offset;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#vel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.vel = this.body.vel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#accel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.accel = this.body.accel;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#friction
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.friction = this.body.friction;
/**
* [description]
*
* @name Phaser.Physics.Impact.ImpactSprite#maxVel
* @type {{x: number, y: number}}
* @since 3.0.0
*/
this.maxVel = this.body.maxVel;
}
});
module.exports = ImpactSprite;

View file

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

View file

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

View file

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

View file

@ -1,62 +1,62 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* 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,
* 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
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.TYPE
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Collides with nothing.
*
* @name Phaser.Physics.Impact.TYPE.NONE
* @type {integer}
* @const
* @since 3.0.0
*/
NONE: 0,
/**
* Type A. Collides with Type B.
*
* @name Phaser.Physics.Impact.TYPE.A
* @type {integer}
* @const
* @since 3.0.0
*/
A: 1,
/**
* Type B. Collides with Type A.
*
* @name Phaser.Physics.Impact.TYPE.B
* @type {integer}
* @const
* @since 3.0.0
*/
B: 2,
/**
* Collides with both types A and B.
*
* @name Phaser.Physics.Impact.TYPE.BOTH
* @type {integer}
* @const
* @since 3.0.0
*/
BOTH: 3
};
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* 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,
* 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
* with other LITE or PASSIVE entities at all. The behavior for FIXED vs.
* FIXED collisions is undefined.
*
* @namespace Phaser.Physics.Impact.TYPE
* @memberof Phaser.Physics.Impact
* @since 3.0.0
*/
module.exports = {
/**
* Collides with nothing.
*
* @name Phaser.Physics.Impact.TYPE.NONE
* @type {integer}
* @const
* @since 3.0.0
*/
NONE: 0,
/**
* Type A. Collides with Type B.
*
* @name Phaser.Physics.Impact.TYPE.A
* @type {integer}
* @const
* @since 3.0.0
*/
A: 1,
/**
* Type B. Collides with Type A.
*
* @name Phaser.Physics.Impact.TYPE.B
* @type {integer}
* @const
* @since 3.0.0
*/
B: 2,
/**
* Collides with both types A and B.
*
* @name Phaser.Physics.Impact.TYPE.BOTH
* @type {integer}
* @const
* @since 3.0.0
*/
BOTH: 3
};

View file

@ -1,89 +1,89 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Set up the trace-result
* var res = {
* collision: {x: false, y: false, slope: false},
* pos: {x: x, y: y},
* tile: {x: 0, y: 0}
* };
*
* @function Phaser.Physics.Impact.UpdateMotion
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} res - [description]
*/
var UpdateMotion = function (body, res)
{
body.standing = false;
// Y
if (res.collision.y)
{
if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity)
{
body.vel.y *= -body.bounciness;
}
else
{
if (body.vel.y > 0)
{
body.standing = true;
}
body.vel.y = 0;
}
}
// X
if (res.collision.x)
{
if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity)
{
body.vel.x *= -body.bounciness;
}
else
{
body.vel.x = 0;
}
}
// SLOPE
if (res.collision.slope)
{
var s = res.collision.slope;
if (body.bounciness > 0)
{
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.y = (body.vel.y - s.ny * proj * 2) * body.bounciness;
}
else
{
var lengthSquared = s.x * s.x + s.y * s.y;
var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared;
body.vel.x = s.x * dot;
body.vel.y = s.y * dot;
var angle = Math.atan2(s.x, s.y);
if (angle > body.slopeStanding.min && angle < body.slopeStanding.max)
{
body.standing = true;
}
}
}
body.pos.x = res.pos.x;
body.pos.y = res.pos.y;
};
module.exports = UpdateMotion;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Set up the trace-result
* var res = {
* collision: {x: false, y: false, slope: false},
* pos: {x: x, y: y},
* tile: {x: 0, y: 0}
* };
*
* @function Phaser.Physics.Impact.UpdateMotion
* @since 3.0.0
*
* @param {Phaser.Physics.Impact.Body} body - [description]
* @param {object} res - [description]
*/
var UpdateMotion = function (body, res)
{
body.standing = false;
// Y
if (res.collision.y)
{
if (body.bounciness > 0 && Math.abs(body.vel.y) > body.minBounceVelocity)
{
body.vel.y *= -body.bounciness;
}
else
{
if (body.vel.y > 0)
{
body.standing = true;
}
body.vel.y = 0;
}
}
// X
if (res.collision.x)
{
if (body.bounciness > 0 && Math.abs(body.vel.x) > body.minBounceVelocity)
{
body.vel.x *= -body.bounciness;
}
else
{
body.vel.x = 0;
}
}
// SLOPE
if (res.collision.slope)
{
var s = res.collision.slope;
if (body.bounciness > 0)
{
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.y = (body.vel.y - s.ny * proj * 2) * body.bounciness;
}
else
{
var lengthSquared = s.x * s.x + s.y * s.y;
var dot = (body.vel.x * s.x + body.vel.y * s.y) / lengthSquared;
body.vel.x = s.x * dot;
body.vel.y = s.y * dot;
var angle = Math.atan2(s.x, s.y);
if (angle > body.slopeStanding.min && angle < body.slopeStanding.max)
{
body.standing = true;
}
}
}
body.pos.x = res.pos.x;
body.pos.y = res.pos.y;
};
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>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Acceleration component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Acceleration
* @since 3.0.0
*/
var Acceleration = {
/**
* Sets the horizontal acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX
* @since 3.0.0
*
* @param {number} x - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationX: function (x)
{
this.accel.x = x;
return this;
},
/**
* Sets the vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY
* @since 3.0.0
*
* @param {number} y - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationY: function (y)
{
this.accel.y = y;
return this;
},
/**
* Sets the horizontal and vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration
* @since 3.0.0
*
* @param {number} x - The amount of horizontal acceleration to apply.
* @param {number} y - The amount of vertical acceleration to apply.
*
* @return {this} This Game Object.
*/
setAcceleration: function (x, y)
{
this.accel.x = x;
this.accel.y = y;
return this;
}
};
module.exports = Acceleration;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Acceleration component.
* Should be applied as a mixin.
*
* @namespace Phaser.Physics.Impact.Components.Acceleration
* @since 3.0.0
*/
var Acceleration = {
/**
* Sets the horizontal acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationX
* @since 3.0.0
*
* @param {number} x - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationX: function (x)
{
this.accel.x = x;
return this;
},
/**
* Sets the vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAccelerationY
* @since 3.0.0
*
* @param {number} y - The amount of acceleration to apply.
*
* @return {this} This Game Object.
*/
setAccelerationY: function (y)
{
this.accel.y = y;
return this;
},
/**
* Sets the horizontal and vertical acceleration of this body.
*
* @method Phaser.Physics.Impact.Components.Acceleration#setAcceleration
* @since 3.0.0
*
* @param {number} x - The amount of horizontal acceleration to apply.
* @param {number} y - The amount of vertical acceleration to apply.
*
* @return {this} This Game Object.
*/
setAcceleration: function (x, y)
{
this.accel.x = x;
this.accel.y = y;
return this;
}
};
module.exports = Acceleration;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,21 +1,21 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Collide Event.
*
* 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)`.
*
* @event Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0
*
* @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 {string} axis - The collision axis. Either `x` or `y`.
*/
module.exports = 'collide';
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Collide Event.
*
* 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)`.
*
* @event Phaser.Physics.Impact.Events#COLLIDE
* @since 3.0.0
*
* @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 {string} axis - The collision axis. Either `x` or `y`.
*/
module.exports = 'collide';

View file

@ -1,17 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Pause Event.
*
* 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)`.
*
* @event Phaser.Physics.Impact.Events#PAUSE
* @since 3.0.0
*/
module.exports = 'pause';
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Pause Event.
*
* 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)`.
*
* @event Phaser.Physics.Impact.Events#PAUSE
* @since 3.0.0
*/
module.exports = 'pause';

View file

@ -1,17 +1,17 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Resume Event.
*
* 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)`.
*
* @event Phaser.Physics.Impact.Events#RESUME
* @since 3.0.0
*/
module.exports = 'resume';
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* The Impact Physics World Resume Event.
*
* 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)`.
*
* @event Phaser.Physics.Impact.Events#RESUME
* @since 3.0.0
*/
module.exports = 'resume';

View file

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

View file

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

View file

@ -1,14 +1,14 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.CollisionOptions
* @since 3.0.0
*
* @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
* 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.
* @property {object} [slopeMap=null] - A tile index to slope definition map.
* @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.
* @property {integer} [defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile.
*/
/**
* @typedef {object} Phaser.Types.Physics.Impact.CollisionOptions
* @since 3.0.0
*
* @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
* 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.
* @property {object} [slopeMap=null] - A tile index to slope definition map.
* @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.
* @property {integer} [defaultNonCollidingSlope=0] - The default slope ID to assign to a
* non-colliding tile.
*/

View file

@ -1,18 +1,18 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.JSONImpactBody
* @since 3.0.0
*
* @property {string} name - [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} 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} 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 {number} gravityFactor - [description]
* @property {number} bounciness - [description]
* @property {number} minBounceVelocity - [description]
* @property {Phaser.Physics.Impact.TYPE} type - [description]
* @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description]
* @property {Phaser.Physics.Impact.COLLIDES} collides - [description]
*/
/**
* @typedef {object} Phaser.Types.Physics.Impact.JSONImpactBody
* @since 3.0.0
*
* @property {string} name - [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} 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} 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 {number} gravityFactor - [description]
* @property {number} bounciness - [description]
* @property {number} minBounceVelocity - [description]
* @property {Phaser.Physics.Impact.TYPE} type - [description]
* @property {Phaser.Physics.Impact.TYPE} checkAgainst - [description]
* @property {Phaser.Physics.Impact.COLLIDES} collides - [description]
*/

View file

@ -1,30 +1,30 @@
/**
* @typedef {object} Phaser.Types.Physics.Impact.WorldConfig
* @since 3.0.0
*
* @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} [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 {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}.
* @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} [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} [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} [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} [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 {(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.y=0] - The y coordinate 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.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.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.bottom=true] - Should the bottom world bounds wall be created?
*/
/**
* @typedef {object} Phaser.Types.Physics.Impact.WorldConfig
* @since 3.0.0
*
* @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} [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 {boolean} [debug=false] - Sets {@link Phaser.Physics.Impact.World#debug}.
* @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} [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} [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} [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} [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 {(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.y=0] - The y coordinate 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.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.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.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.
*
* @typedef {object} Phaser.Types.Physics.Impact.WorldDefaults
* @since 3.0.0
*
* @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 {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} maxVelocityX - Maximum X 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} gravityFactor - Gravity multiplier. Set to 0 for no gravity.
* @property {number} bounciness - The default bounce, or restitution, of bodies in the world.
*/
/**
* An object containing the 4 wall bodies that bound the physics world.
*
* @typedef {object} Phaser.Types.Physics.Impact.WorldDefaults
* @since 3.0.0
*
* @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 {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} maxVelocityX - Maximum X 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} gravityFactor - Gravity multiplier. Set to 0 for no gravity.
* @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
* @since 3.0.0
*
* @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} top - The top wall of the world bounds.
* @property {?Phaser.Physics.Impact.Body} bottom - The bottom wall of the world bounds.
*/
/**
* @typedef {object} Phaser.Types.Physics.Impact.WorldWalls
* @since 3.0.0
*
* @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} top - The top 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>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @namespace Phaser.Types.Physics.Impact
*/
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* @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
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
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.
*
* 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
* @since 3.22.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {number} [offsetX=0] - Optional horizontal 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.
*/
var AlignTo = function (items, position, offsetX, offsetY)
{
var target = items[0];
for (var i = 1; i < items.length; i++)
{
var item = items[i];
QuickSet(item, target, position, offsetX, offsetY);
target = item;
}
return items;
};
module.exports = AlignTo;
/**
* @author samme
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
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.
*
* 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
* @since 3.22.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {number} [offsetX=0] - Optional horizontal 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.
*/
var AlignTo = function (items, position, offsetX, offsetY)
{
var target = items[0];
for (var i = 1; i < items.length; i++)
{
var item = items[i];
QuickSet(item, target, position, offsetX, offsetY);
target = item;
}
return items;
};
module.exports = AlignTo;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.Angle
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var Angle = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'angle', value, step, index, direction);
};
module.exports = Angle;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.Angle
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var Angle = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'angle', value, step, index, direction);
};
module.exports = Angle;

View file

@ -1,33 +1,33 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Takes an array of objects and passes each of them to the given callback.
*
* @function Phaser.Actions.Call
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {*} 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.
*/
var Call = function (items, callback, context)
{
for (var i = 0; i < items.length; i++)
{
var item = items[i];
callback.call(context, item);
}
return items;
};
module.exports = Call;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Takes an array of objects and passes each of them to the given callback.
*
* @function Phaser.Actions.Call
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {*} 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.
*/
var Call = function (items, callback, context)
{
for (var i = 0; i < items.length; i++)
{
var item = items[i];
callback.call(context, item);
}
return items;
};
module.exports = Call;

View file

@ -1,52 +1,52 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* 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.
*
* To use this with a Group: `GetFirst(group.getChildren(), compare, index)`
*
* @function Phaser.Actions.GetFirst
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items]
*
* @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 {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.
*/
var GetFirst = function (items, compare, index)
{
if (index === undefined) { index = 0; }
for (var i = index; i < items.length; i++)
{
var item = items[i];
var match = true;
for (var property in compare)
{
if (item[property] !== compare[property])
{
match = false;
}
}
if (match)
{
return item;
}
}
return null;
};
module.exports = GetFirst;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* 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.
*
* To use this with a Group: `GetFirst(group.getChildren(), compare, index)`
*
* @function Phaser.Actions.GetFirst
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items]
*
* @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 {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.
*/
var GetFirst = function (items, compare, index)
{
if (index === undefined) { index = 0; }
for (var i = index; i < items.length; i++)
{
var item = items[i];
var match = true;
for (var property in compare)
{
if (item[property] !== compare[property])
{
match = false;
}
}
if (match)
{
return item;
}
}
return null;
};
module.exports = GetFirst;

View file

@ -1,52 +1,52 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* 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.
*
* To use this with a Group: `GetLast(group.getChildren(), compare, index)`
*
* @function Phaser.Actions.GetLast
* @since 3.3.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items]
*
* @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 {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.
*/
var GetLast = function (items, compare, index)
{
if (index === undefined) { index = 0; }
for (var i = index; i < items.length; i++)
{
var item = items[i];
var match = true;
for (var property in compare)
{
if (item[property] !== compare[property])
{
match = false;
}
}
if (match)
{
return item;
}
}
return null;
};
module.exports = GetLast;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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
* 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.
*
* To use this with a Group: `GetLast(group.getChildren(), compare, index)`
*
* @function Phaser.Actions.GetLast
* @since 3.3.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items]
*
* @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 {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.
*/
var GetLast = function (items, compare, index)
{
if (index === undefined) { index = 0; }
for (var i = index; i < items.length; i++)
{
var item = items[i];
var match = true;
for (var property in compare)
{
if (item[property] !== compare[property])
{
match = false;
}
}
if (match)
{
return item;
}
}
return null;
};
module.exports = GetLast;

View file

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

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncAlpha
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var IncAlpha = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'alpha', value, step, index, direction);
};
module.exports = IncAlpha;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncAlpha
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var IncAlpha = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'alpha', value, step, index, direction);
};
module.exports = IncAlpha;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var IncX = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'x', value, step, index, direction);
};
module.exports = IncX;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var IncX = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'x', value, step, index, direction);
};
module.exports = IncX;

View file

@ -1,41 +1,41 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncXY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var IncXY = function (items, x, y, stepX, stepY, index, direction)
{
if (y === undefined || y === null) { y = x; }
PropertyValueInc(items, 'x', x, stepX, index, direction);
return PropertyValueInc(items, 'y', y, stepY, index, direction);
};
module.exports = IncXY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncXY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var IncXY = function (items, x, y, stepX, stepY, index, direction)
{
if (y === undefined || y === null) { y = x; }
PropertyValueInc(items, 'x', x, stepX, index, direction);
return PropertyValueInc(items, 'y', y, stepY, index, direction);
};
module.exports = IncXY;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var IncY = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'y', value, step, index, direction);
};
module.exports = IncY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.IncY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var IncY = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'y', value, step, index, direction);
};
module.exports = IncY;

View file

@ -1,43 +1,43 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property.
*
* @function Phaser.Actions.PlaceOnCircle
* @since 3.0.0
*
* @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 {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} [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.
*/
var PlaceOnCircle = function (items, circle, startAngle, endAngle)
{
if (startAngle === undefined) { startAngle = 0; }
if (endAngle === undefined) { endAngle = 6.28; }
var angle = startAngle;
var angleStep = (endAngle - startAngle) / items.length;
for (var i = 0; i < items.length; i++)
{
items[i].x = circle.x + (circle.radius * Math.cos(angle));
items[i].y = circle.y + (circle.radius * Math.sin(angle));
angle += angleStep;
}
return items;
};
module.exports = PlaceOnCircle;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* If you wish to pass a `Phaser.GameObjects.Circle` Shape to this function, you should pass its `geom` property.
*
* @function Phaser.Actions.PlaceOnCircle
* @since 3.0.0
*
* @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 {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} [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.
*/
var PlaceOnCircle = function (items, circle, startAngle, endAngle)
{
if (startAngle === undefined) { startAngle = 0; }
if (endAngle === undefined) { endAngle = 6.28; }
var angle = startAngle;
var angleStep = (endAngle - startAngle) / items.length;
for (var i = 0; i < items.length; i++)
{
items[i].x = circle.x + (circle.radius * Math.cos(angle));
items[i].y = circle.y + (circle.radius * Math.sin(angle));
angle += angleStep;
}
return items;
};
module.exports = PlaceOnCircle;

View file

@ -1,46 +1,46 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property.
*
* @function Phaser.Actions.PlaceOnEllipse
* @since 3.0.0
*
* @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 {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} [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.
*/
var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle)
{
if (startAngle === undefined) { startAngle = 0; }
if (endAngle === undefined) { endAngle = 6.28; }
var angle = startAngle;
var angleStep = (endAngle - startAngle) / items.length;
var a = ellipse.width / 2;
var b = ellipse.height / 2;
for (var i = 0; i < items.length; i++)
{
items[i].x = ellipse.x + a * Math.cos(angle);
items[i].y = ellipse.y + b * Math.sin(angle);
angle += angleStep;
}
return items;
};
module.exports = PlaceOnEllipse;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* If you wish to pass a `Phaser.GameObjects.Ellipse` Shape to this function, you should pass its `geom` property.
*
* @function Phaser.Actions.PlaceOnEllipse
* @since 3.0.0
*
* @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 {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} [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.
*/
var PlaceOnEllipse = function (items, ellipse, startAngle, endAngle)
{
if (startAngle === undefined) { startAngle = 0; }
if (endAngle === undefined) { endAngle = 6.28; }
var angle = startAngle;
var angleStep = (endAngle - startAngle) / items.length;
var a = ellipse.width / 2;
var b = ellipse.height / 2;
for (var i = 0; i < items.length; i++)
{
items[i].x = ellipse.x + a * Math.cos(angle);
items[i].y = ellipse.y + b * Math.sin(angle);
angle += angleStep;
}
return items;
};
module.exports = PlaceOnEllipse;

View file

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

View file

@ -1,52 +1,52 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var MarchingAnts = require('../geom/rectangle/MarchingAnts');
var RotateLeft = require('../utils/array/RotateLeft');
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.
*
* 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.
*
* @function Phaser.Actions.PlaceOnRectangle
* @since 3.0.0
*
* @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 {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on.
* @param {integer} [shift=1] - An optional positional offset.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var PlaceOnRectangle = function (items, rect, shift)
{
if (shift === undefined) { shift = 0; }
var points = MarchingAnts(rect, false, items.length);
if (shift > 0)
{
RotateLeft(points, shift);
}
else if (shift < 0)
{
RotateRight(points, Math.abs(shift));
}
for (var i = 0; i < items.length; i++)
{
items[i].x = points[i].x;
items[i].y = points[i].y;
}
return items;
};
module.exports = PlaceOnRectangle;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var MarchingAnts = require('../geom/rectangle/MarchingAnts');
var RotateLeft = require('../utils/array/RotateLeft');
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.
*
* 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.
*
* @function Phaser.Actions.PlaceOnRectangle
* @since 3.0.0
*
* @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 {Phaser.Geom.Rectangle} rect - The Rectangle to position the Game Objects on.
* @param {integer} [shift=1] - An optional positional offset.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var PlaceOnRectangle = function (items, rect, shift)
{
if (shift === undefined) { shift = 0; }
var points = MarchingAnts(rect, false, items.length);
if (shift > 0)
{
RotateLeft(points, shift);
}
else if (shift < 0)
{
RotateRight(points, Math.abs(shift));
}
for (var i = 0; i < items.length; i++)
{
items[i].x = points[i].x;
items[i].y = points[i].y;
}
return items;
};
module.exports = PlaceOnRectangle;

View file

@ -1,55 +1,55 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
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.
*
* If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property.
*
* @function Phaser.Actions.PlaceOnTriangle
* @since 3.0.0
*
* @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 {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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var PlaceOnTriangle = function (items, triangle, 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 p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate);
// Remove overlaps
p1.pop();
p2.pop();
p3.pop();
p1 = p1.concat(p2, p3);
var step = p1.length / items.length;
var p = 0;
for (var i = 0; i < items.length; i++)
{
var item = items[i];
var point = p1[Math.floor(p)];
item.x = point.x;
item.y = point.y;
p += step;
}
return items;
};
module.exports = PlaceOnTriangle;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
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.
*
* If you wish to pass a `Phaser.GameObjects.Triangle` Shape to this function, you should pass its `geom` property.
*
* @function Phaser.Actions.PlaceOnTriangle
* @since 3.0.0
*
* @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 {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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var PlaceOnTriangle = function (items, triangle, 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 p3 = BresenhamPoints({ x1: triangle.x3, y1: triangle.y3, x2: triangle.x1, y2: triangle.y1 }, stepRate);
// Remove overlaps
p1.pop();
p2.pop();
p3.pop();
p1 = p1.concat(p2, p3);
var step = p1.length / items.length;
var p = 0;
for (var i = 0; i < items.length; i++)
{
var item = items[i];
var point = p1[Math.floor(p)];
item.x = point.x;
item.y = point.y;
p += step;
}
return items;
};
module.exports = PlaceOnTriangle;

View file

@ -1,31 +1,31 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* @function Phaser.Actions.PlayAnimation
* @since 3.0.0
*
* @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 {string} key - The name of the animation to play.
* @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.
*/
var PlayAnimation = function (items, key, startFrame)
{
for (var i = 0; i < items.length; i++)
{
items[i].anims.play(key, startFrame);
}
return items;
};
module.exports = PlayAnimation;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* @function Phaser.Actions.PlayAnimation
* @since 3.0.0
*
* @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 {string} key - The name of the animation to play.
* @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.
*/
var PlayAnimation = function (items, key, startFrame)
{
for (var i = 0; i < items.length; i++)
{
items[i].anims.play(key, startFrame);
}
return items;
};
module.exports = PlayAnimation;

View file

@ -1,61 +1,61 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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`,
* and then adds the given value to it.
*
* 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)`
*
* @function Phaser.Actions.PropertyValueInc
* @since 3.3.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {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 {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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/
var PropertyValueInc = function (items, key, value, step, index, direction)
{
if (step === undefined) { step = 0; }
if (index === undefined) { index = 0; }
if (direction === undefined) { direction = 1; }
var i;
var t = 0;
var end = items.length;
if (direction === 1)
{
// Start to End
for (i = index; i < end; i++)
{
items[i][key] += value + (t * step);
t++;
}
}
else
{
// End to Start
for (i = index; i >= 0; i--)
{
items[i][key] += value + (t * step);
t++;
}
}
return items;
};
module.exports = PropertyValueInc;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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`,
* and then adds the given value to it.
*
* 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)`
*
* @function Phaser.Actions.PropertyValueInc
* @since 3.3.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {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 {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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/
var PropertyValueInc = function (items, key, value, step, index, direction)
{
if (step === undefined) { step = 0; }
if (index === undefined) { index = 0; }
if (direction === undefined) { direction = 1; }
var i;
var t = 0;
var end = items.length;
if (direction === 1)
{
// Start to End
for (i = index; i < end; i++)
{
items[i][key] += value + (t * step);
t++;
}
}
else
{
// End to Start
for (i = index; i >= 0; i--)
{
items[i][key] += value + (t * step);
t++;
}
}
return items;
};
module.exports = PropertyValueInc;

View file

@ -1,61 +1,61 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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`,
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.PropertyValueSet
* @since 3.3.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {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 {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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/
var PropertyValueSet = function (items, key, value, step, index, direction)
{
if (step === undefined) { step = 0; }
if (index === undefined) { index = 0; }
if (direction === undefined) { direction = 1; }
var i;
var t = 0;
var end = items.length;
if (direction === 1)
{
// Start to End
for (i = index; i < end; i++)
{
items[i][key] = value + (t * step);
t++;
}
}
else
{
// End to Start
for (i = index; i >= 0; i--)
{
items[i][key] = value + (t * step);
t++;
}
}
return items;
};
module.exports = PropertyValueSet;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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`,
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.PropertyValueSet
* @since 3.3.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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 {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 {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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of objects that were passed to this Action.
*/
var PropertyValueSet = function (items, key, value, step, index, direction)
{
if (step === undefined) { step = 0; }
if (index === undefined) { index = 0; }
if (direction === undefined) { direction = 1; }
var i;
var t = 0;
var end = items.length;
if (direction === 1)
{
// Start to End
for (i = index; i < end; i++)
{
items[i][key] = value + (t * step);
t++;
}
}
else
{
// End to Start
for (i = index; i >= 0; i--)
{
items[i][key] = value + (t * step);
t++;
}
}
return items;
};
module.exports = PropertyValueSet;

View file

@ -1,34 +1,34 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/circle/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomCircle
* @since 3.0.0
*
* @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 {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.
*/
var RandomCircle = function (items, circle)
{
for (var i = 0; i < items.length; i++)
{
Random(circle, items[i]);
}
return items;
};
module.exports = RandomCircle;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/circle/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomCircle
* @since 3.0.0
*
* @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 {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.
*/
var RandomCircle = function (items, circle)
{
for (var i = 0; i < items.length; i++)
{
Random(circle, items[i]);
}
return items;
};
module.exports = RandomCircle;

View file

@ -1,34 +1,34 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/ellipse/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomEllipse
* @since 3.0.0
*
* @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 {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.
*/
var RandomEllipse = function (items, ellipse)
{
for (var i = 0; i < items.length; i++)
{
Random(ellipse, items[i]);
}
return items;
};
module.exports = RandomEllipse;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/ellipse/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomEllipse
* @since 3.0.0
*
* @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 {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.
*/
var RandomEllipse = function (items, ellipse)
{
for (var i = 0; i < items.length; i++)
{
Random(ellipse, items[i]);
}
return items;
};
module.exports = RandomEllipse;

View file

@ -1,34 +1,34 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/line/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomLine
* @since 3.0.0
*
* @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 {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.
*/
var RandomLine = function (items, line)
{
for (var i = 0; i < items.length; i++)
{
Random(line, items[i]);
}
return items;
};
module.exports = RandomLine;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/line/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomLine
* @since 3.0.0
*
* @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 {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.
*/
var RandomLine = function (items, line)
{
for (var i = 0; i < items.length; i++)
{
Random(line, items[i]);
}
return items;
};
module.exports = RandomLine;

View file

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

View file

@ -1,34 +1,34 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/triangle/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomTriangle
* @since 3.0.0
*
* @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 {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.
*/
var RandomTriangle = function (items, triangle)
{
for (var i = 0; i < items.length; i++)
{
Random(triangle, items[i]);
}
return items;
};
module.exports = RandomTriangle;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var Random = require('../geom/triangle/Random');
/**
* 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.
*
* @function Phaser.Actions.RandomTriangle
* @since 3.0.0
*
* @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 {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.
*/
var RandomTriangle = function (items, triangle)
{
for (var i = 0; i < items.length; i++)
{
Random(triangle, items[i]);
}
return items;
};
module.exports = RandomTriangle;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.Rotate
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var Rotate = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'rotation', value, step, index, direction);
};
module.exports = Rotate;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.Rotate
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var Rotate = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'rotation', value, step, index, direction);
};
module.exports = Rotate;

View file

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

View file

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

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.ScaleX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var ScaleX = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'scaleX', value, step, index, direction);
};
module.exports = ScaleX;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.ScaleX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var ScaleX = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'scaleX', value, step, index, direction);
};
module.exports = ScaleX;

View file

@ -1,41 +1,41 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.ScaleXY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction)
{
if (scaleY === undefined || scaleY === null) { scaleY = scaleX; }
PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction);
return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction);
};
module.exports = ScaleXY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.ScaleXY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var ScaleXY = function (items, scaleX, scaleY, stepX, stepY, index, direction)
{
if (scaleY === undefined || scaleY === null) { scaleY = scaleX; }
PropertyValueInc(items, 'scaleX', scaleX, stepX, index, direction);
return PropertyValueInc(items, 'scaleY', scaleY, stepY, index, direction);
};
module.exports = ScaleXY;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.ScaleY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var ScaleY = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'scaleY', value, step, index, direction);
};
module.exports = ScaleY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueInc = require('./PropertyValueInc');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.ScaleY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var ScaleY = function (items, value, step, index, direction)
{
return PropertyValueInc(items, 'scaleY', value, step, index, direction);
};
module.exports = ScaleY;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `alpha`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetAlpha
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetAlpha = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'alpha', value, step, index, direction);
};
module.exports = SetAlpha;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `alpha`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetAlpha
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetAlpha = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'alpha', value, step, index, direction);
};
module.exports = SetAlpha;

View file

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

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `depth`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetDepth
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetDepth = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'depth', value, step, index, direction);
};
module.exports = SetDepth;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `depth`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetDepth
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetDepth = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'depth', value, step, index, direction);
};
module.exports = SetDepth;

View file

@ -1,33 +1,33 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* @see {@link Phaser.GameObjects.GameObject#setInteractive}
*
* @function Phaser.Actions.SetHitArea
* @since 3.0.0
*
* @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 {*} 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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var SetHitArea = function (items, hitArea, hitAreaCallback)
{
for (var i = 0; i < items.length; i++)
{
items[i].setInteractive(hitArea, hitAreaCallback);
}
return items;
};
module.exports = SetHitArea;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* @see {@link Phaser.GameObjects.GameObject#setInteractive}
*
* @function Phaser.Actions.SetHitArea
* @since 3.0.0
*
* @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 {*} 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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var SetHitArea = function (items, hitArea, hitAreaCallback)
{
for (var i = 0; i < items.length; i++)
{
items[i].setInteractive(hitArea, hitAreaCallback);
}
return items;
};
module.exports = SetHitArea;

View file

@ -1,41 +1,41 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetOrigin
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction)
{
if (originY === undefined || originY === null) { originY = originX; }
PropertyValueSet(items, 'originX', originX, stepX, index, direction);
return PropertyValueSet(items, 'originY', originY, stepY, index, direction);
};
module.exports = SetOrigin;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetOrigin
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetOrigin = function (items, originX, originY, stepX, stepY, index, direction)
{
if (originY === undefined || originY === null) { originY = originX; }
PropertyValueSet(items, 'originX', originX, stepX, index, direction);
return PropertyValueSet(items, 'originY', originY, stepY, index, direction);
};
module.exports = SetOrigin;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `rotation`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetRotation
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetRotation = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'rotation', value, step, index, direction);
};
module.exports = SetRotation;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `rotation`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetRotation
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetRotation = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'rotation', value, step, index, direction);
};
module.exports = SetRotation;

View file

@ -1,41 +1,41 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetScale
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction)
{
if (scaleY === undefined || scaleY === null) { scaleY = scaleX; }
PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction);
return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction);
};
module.exports = SetScale;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetScale
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetScale = function (items, scaleX, scaleY, stepX, stepY, index, direction)
{
if (scaleY === undefined || scaleY === null) { scaleY = scaleX; }
PropertyValueSet(items, 'scaleX', scaleX, stepX, index, direction);
return PropertyValueSet(items, 'scaleY', scaleY, stepY, index, direction);
};
module.exports = SetScale;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scaleX`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScaleX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScaleX = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scaleX', value, step, index, direction);
};
module.exports = SetScaleX;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scaleX`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScaleX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScaleX = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scaleX', value, step, index, direction);
};
module.exports = SetScaleX;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scaleY`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScaleY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScaleY = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scaleY', value, step, index, direction);
};
module.exports = SetScaleY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scaleY`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScaleY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScaleY = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scaleY', value, step, index, direction);
};
module.exports = SetScaleY;

View file

@ -1,41 +1,41 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetScrollFactor
* @since 3.21.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetScrollFactor = function (items, scrollFactorX, scrollFactorY, stepX, stepY, index, direction)
{
if (scrollFactorY === undefined || scrollFactorY === null) { scrollFactorY = scrollFactorX; }
PropertyValueSet(items, 'scrollFactorX', scrollFactorX, stepX, index, direction);
return PropertyValueSet(items, 'scrollFactorY', scrollFactorY, stepY, index, direction);
};
module.exports = SetScrollFactor;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetScrollFactor
* @since 3.21.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetScrollFactor = function (items, scrollFactorX, scrollFactorY, stepX, stepY, index, direction)
{
if (scrollFactorY === undefined || scrollFactorY === null) { scrollFactorY = scrollFactorX; }
PropertyValueSet(items, 'scrollFactorX', scrollFactorX, stepX, index, direction);
return PropertyValueSet(items, 'scrollFactorY', scrollFactorY, stepY, index, direction);
};
module.exports = SetScrollFactor;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorX`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScrollFactorX
* @since 3.21.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScrollFactorX = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scrollFactorX', value, step, index, direction);
};
module.exports = SetScrollFactorX;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorX`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScrollFactorX
* @since 3.21.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScrollFactorX = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scrollFactorX', value, step, index, direction);
};
module.exports = SetScrollFactorX;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorY`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScrollFactorY
* @since 3.21.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScrollFactorY = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scrollFactorY', value, step, index, direction);
};
module.exports = SetScrollFactorY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `scrollFactorY`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetScrollFactorY
* @since 3.21.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetScrollFactorY = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'scrollFactorY', value, step, index, direction);
};
module.exports = SetScrollFactorY;

View file

@ -1,33 +1,33 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* @function Phaser.Actions.SetTint
* @since 3.0.0
*
* @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 {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} [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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight)
{
for (var i = 0; i < items.length; i++)
{
items[i].setTint(topLeft, topRight, bottomLeft, bottomRight);
}
return items;
};
module.exports = SetTint;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @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.
*
* @function Phaser.Actions.SetTint
* @since 3.0.0
*
* @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 {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} [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.
*
* @return {(array|Phaser.GameObjects.GameObject[])} The array of Game Objects that was passed to this Action.
*/
var SetTint = function (items, topLeft, topRight, bottomLeft, bottomRight)
{
for (var i = 0; i < items.length; i++)
{
items[i].setTint(topLeft, topRight, bottomLeft, bottomRight);
}
return items;
};
module.exports = SetTint;

View file

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

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `x`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetX = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'x', value, step, index, direction);
};
module.exports = SetX;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `x`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetX
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetX = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'x', value, step, index, direction);
};
module.exports = SetX;

View file

@ -1,41 +1,41 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetXY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetXY = function (items, x, y, stepX, stepY, index, direction)
{
if (y === undefined || y === null) { y = x; }
PropertyValueSet(items, 'x', x, stepX, index, direction);
return PropertyValueSet(items, 'y', y, stepY, index, direction);
};
module.exports = SetXY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* 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.
*
* 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)`
*
* @function Phaser.Actions.SetXY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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} [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.
*/
var SetXY = function (items, x, y, stepX, stepY, index, direction)
{
if (y === undefined || y === null) { y = x; }
PropertyValueSet(items, 'x', x, stepX, index, direction);
return PropertyValueSet(items, 'y', y, stepY, index, direction);
};
module.exports = SetXY;

View file

@ -1,35 +1,35 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `y`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetY = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'y', value, step, index, direction);
};
module.exports = SetY;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var PropertyValueSet = require('./PropertyValueSet');
/**
* Takes an array of Game Objects, or any objects that have the public property `y`
* and then sets it to the given value.
*
* 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)`
*
* @function Phaser.Actions.SetY
* @since 3.0.0
*
* @generic {Phaser.GameObjects.GameObject[]} G - [items,$return]
*
* @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} [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} [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.
*/
var SetY = function (items, value, step, index, direction)
{
return PropertyValueSet(items, 'y', value, step, index, direction);
};
module.exports = SetY;

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