diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 4180e55..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "src/common"] - path = src/common - url = https://code.thunderk.net/michael/tscommon.git diff --git a/TODO.md b/TODO.md index 7db6056..f3f6c9c 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,6 @@ To-Do-list Phaser 3 migration ------------------ -* Restore fullscreen mode (and add a fullscreen incentive before the menu) * Fix valuebar requiring to be in root display list * Restore unit tests about boundaries (in UITools) @@ -96,6 +95,7 @@ Artificial Intelligence Common UI --------- +* Add a fullscreen incentive at game start * Fix calling setHoverClick several times on the same button not working as expected * Fix tooltip remaining when the hovered object is hidden by animations * If ProgressiveMessage animation performance is bad, show the text directly @@ -108,6 +108,7 @@ Common UI Technical --------- +* Use tk-serializer package (may need to switch to webpack) * Fix tooltips and input events on mobile * Pause timers when the game is paused (at least animation timers) * Pack sounds diff --git a/activate_node b/activate_node index d718b3e..9cc5da8 100644 --- a/activate_node +++ b/activate_node @@ -2,13 +2,15 @@ # Usage: # source activate_node +vdir="./.venv" +expected="10.15.3" + if [ \! -f "./activate_node" ] then echo "Not in project directory" exit 1 fi -vdir="./.venv" -test -x "${vdir}/bin/nodeenv" || ( virtualenv -p python3 "${vdir}" && "${vdir}/bin/pip" install --upgrade nodeenv ) -test -e "${vdir}/node/bin/activate" || "${vdir}/bin/nodeenv" --node=10.3.0 --force "${vdir}/node" +test -x "${vdir}/bin/nodeenv" || ( python3 -m venv "${vdir}" && "${vdir}/bin/pip" install --upgrade nodeenv ) +test "$(${vdir}/node/bin/nodejs --version)" = "v${expected}" || "${vdir}/bin/nodeenv" --node=${expected} --force "${vdir}/node" source "${vdir}/node/bin/activate" diff --git a/package-lock.json b/package-lock.json index 14b0f5d..c84f2c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,10 +4,25 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/runtime": { + "version": "7.4.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.4.3.tgz", + "integrity": "sha512-9lsJwJLxDh/T3Q3SZszfWOTkk3pHbkmH+3KY+zwIDmsNlxsumuhS2TH3NIpktU4kNvfzy+k3eLT7aTJSPTo0OA==", + "requires": { + "regenerator-runtime": "^0.13.2" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.13.2", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.2.tgz", + "integrity": "sha512-S/TQAZJO+D3m9xeN1WTI8dLKBBiRgXBlTJvbWjCThHWZj9EvHK70Ff50/tYj2J/fvBY6JtFVwRuazHN2E7M9BA==" + } + } + }, "@types/jasmine": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-2.8.8.tgz", - "integrity": "sha512-OJSUxLaxXsjjhob2DBzqzgrkLmukM3+JMpRp0r0E4HTdT1nwDCWhaswjYxazPij6uOdzHCJfNbDjmQ1/rnNbCg==", + "version": "3.3.12", + "resolved": "https://registry.npmjs.org/@types/jasmine/-/jasmine-3.3.12.tgz", + "integrity": "sha512-lXvr2xFQEVQLkIhuGaR3GC1L9lMU1IxeWnAF/wNY5ZWpC4p9dgxkKkzMp7pntpAdv9pZSnYqgsBkCg32MXSZMg==", "dev": true }, "abbrev": { @@ -17,22 +32,32 @@ "dev": true }, "accepts": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", - "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "version": "1.3.7", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", + "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", "dev": true, "requires": { - "mime-types": "~2.1.18", - "negotiator": "0.6.1" + "mime-types": "~2.1.24", + "negotiator": "0.6.2" + }, + "dependencies": { + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + } } }, - "addressparser": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/addressparser/-/addressparser-1.0.1.tgz", - "integrity": "sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y=", - "dev": true, - "optional": true - }, "after": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", @@ -40,9 +65,9 @@ "dev": true }, "agent-base": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.0.tgz", - "integrity": "sha512-c+R/U5X+2zz2+UCrCFv6odQzJdoqI+YecuhnAJLa1zYaMc13zPfwMwZrr91Pd1DYNo/yPRbiM4WVf9whgwFsIg==", + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz", + "integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==", "dev": true, "requires": { "es6-promisify": "^5.0.0" @@ -60,113 +85,28 @@ "json-schema-traverse": "^0.3.0" } }, - "align-text": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/align-text/-/align-text-0.1.4.tgz", - "integrity": "sha1-DNkKVhCT810KmSVsIrcGlDP60Rc=", - "dev": true, - "requires": { - "kind-of": "^3.0.2", - "longest": "^1.0.1", - "repeat-string": "^1.5.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - } - } - }, "amdefine": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/amdefine/-/amdefine-1.0.1.tgz", "integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=" }, - "amqplib": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/amqplib/-/amqplib-0.5.2.tgz", - "integrity": "sha512-l9mCs6LbydtHqRniRwYkKdqxVa6XMz3Vw1fh+2gJaaVgTM6Jk3o8RccAKWKtlhT1US5sWrFh+KKxsVUALURSIA==", - "dev": true, - "optional": true, - "requires": { - "bitsyntax": "~0.0.4", - "bluebird": "^3.4.6", - "buffer-more-ints": "0.0.2", - "readable-stream": "1.x >=1.1.9", - "safe-buffer": "^5.0.1" - }, - "dependencies": { - "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", - "dev": true, - "optional": true - }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true - } - } - }, - "ansi-cyan": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz", - "integrity": "sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=", + "ansi-colors": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-1.1.0.tgz", + "integrity": "sha512-SFKX67auSNoVR38N3L+nvsPjOE0bybKTYbkf5tRvushrAPQ9V75huw0ZxBkKVeRU9kqH3d6HA4xTckbwZ4ixmA==", "dev": true, "requires": { - "ansi-wrap": "0.1.0" + "ansi-wrap": "^0.1.0" } }, - "ansi-red": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz", - "integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=", - "dev": true, - "requires": { - "ansi-wrap": "0.1.0" - } - }, - "ansi-regex": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", - "dev": true - }, "ansi-styles": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, - "optional": true + "requires": { + "color-convert": "^1.9.0" + } }, "ansi-wrap": { "version": "0.1.0", @@ -280,13 +220,6 @@ "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", "dev": true }, - "ast-types": { - "version": "0.11.5", - "resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.11.5.tgz", - "integrity": "sha512-oJjo+5e7/vEc2FBK8gUalV0pba4L3VdBIs2EKhOLHLcOd2FgQIVQN9xb0eZ9IjEWyAL7vq6fGJxOvVvdCHNyMw==", - "dev": true, - "optional": true - }, "async": { "version": "1.5.2", "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", @@ -306,9 +239,9 @@ } }, "async-each": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.1.tgz", - "integrity": "sha1-GdOGodntxufByF04iu28xW0zYC0=", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/async-each/-/async-each-1.0.3.tgz", + "integrity": "sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ==", "dev": true }, "async-limiter": { @@ -323,9 +256,9 @@ "dev": true }, "atob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.1.tgz", - "integrity": "sha1-ri1acpR38onWDdf5amMUoi3Wwio=", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", + "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", "dev": true }, "aws-sign2": { @@ -340,28 +273,6 @@ "integrity": "sha512-32NDda82rhwD9/JBCCkB+MRYDp0oSvlo2IL6rQWA10PQi7tDUM3eqMSltXmY+Oyl/7N3P3qNtAlv7X0d9bI28w==", "dev": true }, - "axios": { - "version": "0.15.3", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.15.3.tgz", - "integrity": "sha1-LJ1jiy4ZGgjqHWzJiOrda6W9wFM=", - "dev": true, - "optional": true, - "requires": { - "follow-redirects": "1.0.0" - }, - "dependencies": { - "follow-redirects": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.0.0.tgz", - "integrity": "sha1-jjQpjL0uF28lTv/sdaHHjMhJ/Tc=", - "dev": true, - "optional": true, - "requires": { - "debug": "^2.2.0" - } - } - } - }, "babel-polyfill": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-polyfill/-/babel-polyfill-6.26.0.tgz", @@ -385,6 +296,7 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.26.0.tgz", "integrity": "sha1-llxwWGaOgrVde/4E/yM3vItWR/4=", + "dev": true, "requires": { "core-js": "^2.4.0", "regenerator-runtime": "^0.11.0" @@ -470,20 +382,12 @@ "dev": true }, "basic-auth": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.0.tgz", - "integrity": "sha1-AV2z81PgLlY3d1X5YnQuiYHnu7o=", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", + "integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==", "dev": true, "requires": { - "safe-buffer": "5.1.1" - }, - "dependencies": { - "safe-buffer": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", - "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==", - "dev": true - } + "safe-buffer": "5.1.2" } }, "batch": { @@ -517,60 +421,21 @@ "callsite": "1.0.0" } }, + "big.js": { + "version": "5.2.2", + "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", + "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==" + }, "binary-extensions": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.11.0.tgz", - "integrity": "sha1-RqoXUftqL5PuXmibsQh9SxTGwgU=", + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz", + "integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw==", "dev": true }, - "bitsyntax": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/bitsyntax/-/bitsyntax-0.0.4.tgz", - "integrity": "sha1-6xDMb4K4xJDj6FaY8H6D1G4MuoI=", - "dev": true, - "optional": true, - "requires": { - "buffer-more-ints": "0.0.2" - } - }, - "bl": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/bl/-/bl-1.1.2.tgz", - "integrity": "sha1-/cqHGplxOqANGeO7ukHER4emU5g=", - "dev": true, - "optional": true, - "requires": { - "readable-stream": "~2.0.5" - }, - "dependencies": { - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true - } - } - }, "blob": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz", - "integrity": "sha1-vPEwUspURj8w+fx+lbmkdjCpSSE=", + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz", + "integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==", "dev": true }, "bluebird": { @@ -579,30 +444,29 @@ "integrity": "sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=" }, "body-parser": { - "version": "1.18.3", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", - "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "version": "1.19.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", + "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", "dev": true, "requires": { - "bytes": "3.0.0", + "bytes": "3.1.0", "content-type": "~1.0.4", "debug": "2.6.9", "depd": "~1.1.2", - "http-errors": "~1.6.3", - "iconv-lite": "0.4.23", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "on-finished": "~2.3.0", - "qs": "6.5.2", - "raw-body": "2.3.3", - "type-is": "~1.6.16" - } - }, - "boom": { - "version": "2.10.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-2.10.1.tgz", - "integrity": "sha1-OciRjO/1eZ+D+UkqhI9iWt0Mdm8=", - "dev": true, - "requires": { - "hoek": "2.x.x" + "qs": "6.7.0", + "raw-body": "2.4.0", + "type-is": "~1.6.17" + }, + "dependencies": { + "qs": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", + "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==", + "dev": true + } } }, "brace-expansion": { @@ -644,34 +508,34 @@ } } }, + "buffer-alloc": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", + "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "dev": true, + "requires": { + "buffer-alloc-unsafe": "^1.1.0", + "buffer-fill": "^1.0.0" + } + }, + "buffer-alloc-unsafe": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", + "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", + "dev": true + }, + "buffer-fill": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", + "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=", + "dev": true + }, "buffer-from": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz", "integrity": "sha512-c5mRlguI/Pe2dSZmpER62rSCu0ryKmWddzRYsuXc50U2/g8jMOulc31VZMa4mYx31U5xsmSOpDCgH88Vl9cDGQ==", "dev": true }, - "buffer-more-ints": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/buffer-more-ints/-/buffer-more-ints-0.0.2.tgz", - "integrity": "sha1-JrOIXRD6E9t/wBquOquHAZngEkw=", - "dev": true - }, - "buildmail": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/buildmail/-/buildmail-4.0.1.tgz", - "integrity": "sha1-h393OLeHKYccmhBeO4N9K+EaenI=", - "dev": true, - "optional": true, - "requires": { - "addressparser": "1.0.1", - "libbase64": "0.1.0", - "libmime": "3.0.0", - "libqp": "1.1.0", - "nodemailer-fetch": "1.6.0", - "nodemailer-shared": "1.1.0", - "punycode": "1.4.1" - } - }, "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", @@ -679,9 +543,9 @@ "dev": true }, "bytes": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", - "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", + "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==", "dev": true }, "cache-base": { @@ -729,57 +593,45 @@ "integrity": "sha1-G2gcIf+EAzyCZUMJBolCDRhxUdw=", "dev": true }, - "center-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/center-align/-/center-align-0.1.3.tgz", - "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=", - "dev": true, - "optional": true, - "requires": { - "align-text": "^0.1.3", - "lazy-cache": "^1.0.3" - } - }, "chalk": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", - "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", "dev": true, - "optional": true, "requires": { - "ansi-styles": "^2.2.1", - "escape-string-regexp": "^1.0.2", - "has-ansi": "^2.0.0", - "strip-ansi": "^3.0.0", - "supports-color": "^2.0.0" + "ansi-styles": "^3.1.0", + "escape-string-regexp": "^1.0.5", + "supports-color": "^4.0.0" } }, "chokidar": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.0.3.tgz", - "integrity": "sha512-zW8iXYZtXMx4kux/nuZVXjkLP+CyIK5Al5FHnj1OgTKGZfp4Oy6/ymtMSKFv3GD8DviEmUPmJg9eFdJ/JzudMg==", + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.5.tgz", + "integrity": "sha512-i0TprVWp+Kj4WRPtInjexJ8Q+BqTE909VpH8xVhXrJkoc5QC8VO9TryGOqTr+2hljzc1sC62t22h5tZePodM/A==", "dev": true, "requires": { "anymatch": "^2.0.0", - "async-each": "^1.0.0", - "braces": "^2.3.0", - "fsevents": "^1.1.2", + "async-each": "^1.0.1", + "braces": "^2.3.2", + "fsevents": "^1.2.7", "glob-parent": "^3.1.0", - "inherits": "^2.0.1", + "inherits": "^2.0.3", "is-binary-path": "^1.0.0", "is-glob": "^4.0.0", - "normalize-path": "^2.1.1", + "normalize-path": "^3.0.0", "path-is-absolute": "^1.0.0", - "readdirp": "^2.0.0", - "upath": "^1.0.0" + "readdirp": "^2.2.1", + "upath": "^1.1.1" + }, + "dependencies": { + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + } } }, - "circular-json": { - "version": "0.5.4", - "resolved": "https://registry.npmjs.org/circular-json/-/circular-json-0.5.4.tgz", - "integrity": "sha512-vnJA8KS0BfOihugYEUkLRcnmq21FbuivbxgzDLXNs3zIk4KllV4Mx4UuTzBXht9F00C7QfD1YqMXg1zP6EXpig==", - "dev": true - }, "class-utils": { "version": "0.3.6", "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", @@ -803,27 +655,6 @@ } } }, - "cliui": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", - "integrity": "sha1-S0dXYP+AJkx2LDoXGQMukcf+oNE=", - "dev": true, - "optional": true, - "requires": { - "center-align": "^0.1.1", - "right-align": "^0.1.1", - "wordwrap": "0.0.2" - }, - "dependencies": { - "wordwrap": { - "version": "0.0.2", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz", - "integrity": "sha1-t5Zpu0LstAn4PVg8rVLKF+qhZD8=", - "dev": true, - "optional": true - } - } - }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -831,14 +662,16 @@ "dev": true }, "codecov": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.0.2.tgz", - "integrity": "sha512-9ljtIROIjPIUmMRqO+XuDITDoV8xRrZmA0jcEq6p2hg2+wY9wGmLfreAZGIL72IzUfdEDZaU8+Vjidg1fBQ8GQ==", + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/codecov/-/codecov-3.3.0.tgz", + "integrity": "sha512-S70c3Eg9SixumOvxaKE/yKUxb9ihu/uebD9iPO2IR73IdP4i6ZzjXEULj3d0HeyWPr0DqBfDkjNBWxURjVO5hw==", "dev": true, "requires": { - "argv": "0.0.2", - "request": "^2.81.0", - "urlgrey": "0.4.4" + "argv": "^0.0.2", + "ignore-walk": "^3.0.1", + "js-yaml": "^3.12.0", + "teeny-request": "^3.7.0", + "urlgrey": "^0.4.4" } }, "collection-visit": { @@ -852,12 +685,12 @@ } }, "color-convert": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", - "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "dev": true, "requires": { - "color-name": "^1.1.1" + "color-name": "1.1.3" } }, "color-name": { @@ -872,23 +705,6 @@ "integrity": "sha512-EDpX3a7wHMWFA7PUHWPHNWqOxIIRSJetuwl0AS5Oi/5FMV8kWm69RTlgm00GKjBO1xFHMtBbL49yRtMMdticBw==", "dev": true }, - "combine-lists": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/combine-lists/-/combine-lists-1.0.1.tgz", - "integrity": "sha1-RYwH4J4NkA/Ci3Cj/sLazR0st/Y=", - "dev": true, - "requires": { - "lodash": "^4.5.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true - } - } - }, "combined-stream": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz", @@ -899,9 +715,9 @@ } }, "commander": { - "version": "2.15.1", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.15.1.tgz", - "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==", "dev": true }, "component-bind": { @@ -911,9 +727,9 @@ "dev": true }, "component-emitter": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", - "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.0.tgz", + "integrity": "sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==", "dev": true }, "component-inherit": { @@ -973,7 +789,8 @@ "core-js": { "version": "2.5.7", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", - "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==", + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -982,25 +799,15 @@ "dev": true }, "cors": { - "version": "2.8.4", - "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.4.tgz", - "integrity": "sha1-K9OB8usgECAQXNUOpZ2mMJBpRoY=", + "version": "2.8.5", + "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz", + "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==", "dev": true, "requires": { "object-assign": "^4", "vary": "^1" } }, - "cryptiles": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/cryptiles/-/cryptiles-2.0.5.tgz", - "integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=", - "dev": true, - "optional": true, - "requires": { - "boom": "2.x.x" - } - }, "currently-unhandled": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/currently-unhandled/-/currently-unhandled-0.4.1.tgz", @@ -1025,17 +832,10 @@ "assert-plus": "^1.0.0" } }, - "data-uri-to-buffer": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-1.2.0.tgz", - "integrity": "sha512-vKQ9DTQPN1FLYiiEEOQ6IBGFqvjCa5rSK3cWMy/Nespm5d/x3dGFT9UBZnkLxCwua/IXBi2TYnwTEpsOvhC4UQ==", - "dev": true, - "optional": true - }, "date-format": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/date-format/-/date-format-1.2.0.tgz", - "integrity": "sha1-YV6CjiM90aubua4JUODOzPpuytg=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/date-format/-/date-format-2.0.0.tgz", + "integrity": "sha512-M6UqVvZVgFYqZL1SfHsRGIQSz3ZL+qgbsV5Lp1Vj61LZVYuEwcMXYay7DRDtYs2HQQBK5hQtQ0fD9aEJ89V0LA==", "dev": true }, "dateformat": { @@ -1116,18 +916,6 @@ } } }, - "degenerator": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/degenerator/-/degenerator-1.0.4.tgz", - "integrity": "sha1-/PSQo37OJmRk2cxDGrmMWBnO0JU=", - "dev": true, - "optional": true, - "requires": { - "ast-types": "0.x.x", - "escodegen": "1.x.x", - "esprima": "3.x.x" - } - }, "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", @@ -1164,13 +952,6 @@ "void-elements": "^2.0.0" } }, - "double-ended-queue": { - "version": "2.1.0-0", - "resolved": "https://registry.npmjs.org/double-ended-queue/-/double-ended-queue-2.1.0-0.tgz", - "integrity": "sha1-ED01J/0xUo9AGIEwyEHv3XgmTlw=", - "dev": true, - "optional": true - }, "duplexer": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", @@ -1193,6 +974,11 @@ "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=", "dev": true }, + "emojis-list": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-2.1.0.tgz", + "integrity": "sha1-TapNnbAPmBmIDHn6RXrlsJof04k=" + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -1209,9 +995,9 @@ } }, "engine.io": { - "version": "3.1.5", - "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.1.5.tgz", - "integrity": "sha512-D06ivJkYxyRrcEe0bTpNnBQNgP9d3xog+qZlLbui8EsMr/DouQpf5o9FzJnWYHEYE0YsFHllUv2R1dkgYZXHcA==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/engine.io/-/engine.io-3.2.1.tgz", + "integrity": "sha512-+VlKzHzMhaU+GsCIg4AoXF1UdDFjHHwMmMKqMJNDNLlUlejz58FCy4LBqB2YVJskHGYl06BatYWKP2TVdVXE5w==", "dev": true, "requires": { "accepts": "~1.3.4", @@ -1219,7 +1005,6 @@ "cookie": "0.3.1", "debug": "~3.1.0", "engine.io-parser": "~2.1.0", - "uws": "~9.14.0", "ws": "~3.3.1" }, "dependencies": { @@ -1231,13 +1016,24 @@ "requires": { "ms": "2.0.0" } + }, + "ws": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" + } } } }, "engine.io-client": { - "version": "3.1.6", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.1.6.tgz", - "integrity": "sha512-hnuHsFluXnsKOndS4Hv6SvUrgdYx1pk2NqfaDMW+GWdgfU3+/V25Cj7I8a0x92idSpa5PIhJRKxPvp9mnoLsfg==", + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.2.1.tgz", + "integrity": "sha512-y5AbkytWeM4jQr7m/koQLc5AxpRKC1hEVUb/s1FUAWEJq5AzJJ4NLvzuKPuxtDi5Mq755WuDvZ6Iv2rXj4PTzw==", "dev": true, "requires": { "component-emitter": "1.2.1", @@ -1253,6 +1049,12 @@ "yeast": "0.1.2" }, "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -1261,19 +1063,30 @@ "requires": { "ms": "2.0.0" } + }, + "ws": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "dev": true, + "requires": { + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" + } } } }, "engine.io-parser": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.2.tgz", - "integrity": "sha512-dInLFzr80RijZ1rGpx1+56/uFoH7/7InhH3kZt+Ms6hT8tNx3NGW/WNSA/f8As1WkOfkuyb3tnRyuXGxusclMw==", + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-2.1.3.tgz", + "integrity": "sha512-6HXPre2O4Houl7c4g7Ic/XzPnHBvaEmN90vtRO9uLmwtRqQmTOw0QMevL1TOfL2Cpu1VzsaTmMotQgMdkzGkVA==", "dev": true, "requires": { "after": "0.8.2", "arraybuffer.slice": "~0.0.7", "base64-arraybuffer": "0.1.5", - "blob": "0.0.4", + "blob": "0.0.5", "has-binary2": "~1.0.2" } }, @@ -1319,42 +1132,12 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, - "escodegen": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.9.1.tgz", - "integrity": "sha512-6hTjO1NAWkHnDk3OqQ4YrCuwwmGHL9S3nPlzBOUG/R44rda3wLNrfvQ5fkSGjyhHFKM7ALPKcKGrwvCLe0lC7Q==", - "dev": true, - "optional": true, - "requires": { - "esprima": "^3.1.3", - "estraverse": "^4.2.0", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.6.1" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, - "optional": true - } - } - }, "esprima": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-3.1.3.tgz", - "integrity": "sha1-/cpRzuYTOJXjyI1TXOSdv/YqRjM=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, - "estraverse": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.2.0.tgz", - "integrity": "sha1-De4/7TH81GlhjOc0IJn8GvoL2xM=", - "dev": true, - "optional": true - }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", @@ -1369,7 +1152,7 @@ }, "event-stream": { "version": "3.3.4", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", + "resolved": "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz", "integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=", "dev": true, "requires": { @@ -1383,65 +1166,9 @@ } }, "eventemitter3": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", - "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==" - }, - "expand-braces": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/expand-braces/-/expand-braces-0.1.2.tgz", - "integrity": "sha1-SIsdHSRRyz06axks/AMPRMWFX+o=", - "dev": true, - "requires": { - "array-slice": "^0.2.3", - "array-unique": "^0.2.1", - "braces": "^0.1.2" - }, - "dependencies": { - "array-slice": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", - "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", - "dev": true - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "braces": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-0.1.5.tgz", - "integrity": "sha1-wIVxEIUpHYt1/ddOqw+FlygHEeY=", - "dev": true, - "requires": { - "expand-range": "^0.1.0" - } - }, - "expand-range": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-0.1.1.tgz", - "integrity": "sha1-TLjtoJk8pW+k9B/ELzy7TMrf8EQ=", - "dev": true, - "requires": { - "is-number": "^0.1.1", - "repeat-string": "^0.2.2" - } - }, - "is-number": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-0.1.1.tgz", - "integrity": "sha1-aaevEWlj1HIG7JvZtIoUIW8eOAY=", - "dev": true - }, - "repeat-string": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-0.2.2.tgz", - "integrity": "sha1-x6jTI2BoNiBZp+RlH8aITosftK4=", - "dev": true - } - } + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==" }, "expand-brackets": { "version": "2.1.4", @@ -1478,54 +1205,19 @@ } } }, - "expand-range": { - "version": "1.8.2", - "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", - "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true, + "exports-loader": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/exports-loader/-/exports-loader-0.7.0.tgz", + "integrity": "sha512-RKwCrO4A6IiKm0pG3c9V46JxIHcDplwwGJn6+JJ1RcVnh/WSGJa0xkmk5cRVtgOPzCAtTMGj2F7nluh9L0vpSA==", "requires": { - "fill-range": "^2.1.0" + "loader-utils": "^1.1.0", + "source-map": "0.5.0" }, "dependencies": { - "fill-range": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.4.tgz", - "integrity": "sha512-cnrcCbj01+j2gTG921VZPnHbjmdAf8oQV/iGeV2kZxGSyfYjjTyY79ErsK1WJWMpw6DaApEX72binqJE+/d+5Q==", - "dev": true, - "requires": { - "is-number": "^2.1.0", - "isobject": "^2.0.0", - "randomatic": "^3.0.0", - "repeat-element": "^1.1.2", - "repeat-string": "^1.5.2" - } - }, - "is-number": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", - "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true, - "requires": { - "kind-of": "^3.0.2" - } - }, - "isobject": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", - "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true, - "requires": { - "isarray": "1.0.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } + "source-map": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.0.tgz", + "integrity": "sha1-D+llA6yGpa213mP05BKuSHLNvoY=" } } }, @@ -1675,19 +1367,6 @@ "pend": "~1.2.0" } }, - "file-uri-to-path": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true, - "optional": true - }, - "filename-regex": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", - "integrity": "sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY=", - "dev": true - }, "fill-range": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", @@ -1744,23 +1423,35 @@ "pinkie-promise": "^2.0.0" } }, + "flatted": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz", + "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg==", + "dev": true + }, "follow-redirects": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.0.tgz", - "integrity": "sha512-fdrt472/9qQ6Kgjvb935ig6vJCuofpBUD14f9Vb+SLlm7xIe4Qva5gey8EKtv8lp7ahE1wilg3xL1znpVGtZIA==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.7.0.tgz", + "integrity": "sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==", "dev": true, "requires": { - "debug": "^3.1.0" + "debug": "^3.2.6" }, "dependencies": { "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, @@ -1835,14 +1526,14 @@ "dev": true }, "fsevents": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz", - "integrity": "sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==", + "version": "1.2.9", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-1.2.9.tgz", + "integrity": "sha512-oeyj2H3EjjonWcFjD5NvZNE9Rqe4UW+nQBU2HNeKw0koVLEFIhtyETyAakeAM3de7Z/SW5kcA+fZUait9EApnw==", "dev": true, "optional": true, "requires": { - "nan": "^2.9.2", - "node-pre-gyp": "^0.10.0" + "nan": "^2.12.1", + "node-pre-gyp": "^0.12.0" }, "dependencies": { "abbrev": { @@ -1863,7 +1554,7 @@ "optional": true }, "are-we-there-yet": { - "version": "1.1.4", + "version": "1.1.5", "bundled": true, "dev": true, "optional": true, @@ -1887,7 +1578,7 @@ } }, "chownr": { - "version": "1.0.1", + "version": "1.1.1", "bundled": true, "dev": true, "optional": true @@ -1914,16 +1605,16 @@ "optional": true }, "debug": { - "version": "2.6.9", + "version": "4.1.1", "bundled": true, "dev": true, "optional": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } }, "deep-extend": { - "version": "0.5.1", + "version": "0.6.0", "bundled": true, "dev": true, "optional": true @@ -1972,7 +1663,7 @@ } }, "glob": { - "version": "7.1.2", + "version": "7.1.3", "bundled": true, "dev": true, "optional": true, @@ -1992,12 +1683,12 @@ "optional": true }, "iconv-lite": { - "version": "0.4.21", + "version": "0.4.24", "bundled": true, "dev": true, "optional": true, "requires": { - "safer-buffer": "^2.1.0" + "safer-buffer": ">= 2.1.2 < 3" } }, "ignore-walk": { @@ -2058,16 +1749,16 @@ "dev": true }, "minipass": { - "version": "2.2.4", + "version": "2.3.5", "bundled": true, "dev": true, "requires": { - "safe-buffer": "^5.1.1", + "safe-buffer": "^5.1.2", "yallist": "^3.0.0" } }, "minizlib": { - "version": "1.1.0", + "version": "1.2.1", "bundled": true, "dev": true, "optional": true, @@ -2084,35 +1775,35 @@ } }, "ms": { - "version": "2.0.0", + "version": "2.1.1", "bundled": true, "dev": true, "optional": true }, "needle": { - "version": "2.2.0", + "version": "2.3.0", "bundled": true, "dev": true, "optional": true, "requires": { - "debug": "^2.1.2", + "debug": "^4.1.0", "iconv-lite": "^0.4.4", "sax": "^1.2.4" } }, "node-pre-gyp": { - "version": "0.10.0", + "version": "0.12.0", "bundled": true, "dev": true, "optional": true, "requires": { "detect-libc": "^1.0.2", "mkdirp": "^0.5.1", - "needle": "^2.2.0", + "needle": "^2.2.1", "nopt": "^4.0.1", "npm-packlist": "^1.1.6", "npmlog": "^4.0.2", - "rc": "^1.1.7", + "rc": "^1.2.7", "rimraf": "^2.6.1", "semver": "^5.3.0", "tar": "^4" @@ -2129,13 +1820,13 @@ } }, "npm-bundled": { - "version": "1.0.3", + "version": "1.0.6", "bundled": true, "dev": true, "optional": true }, "npm-packlist": { - "version": "1.1.10", + "version": "1.4.1", "bundled": true, "dev": true, "optional": true, @@ -2210,12 +1901,12 @@ "optional": true }, "rc": { - "version": "1.2.7", + "version": "1.2.8", "bundled": true, "dev": true, "optional": true, "requires": { - "deep-extend": "^0.5.1", + "deep-extend": "^0.6.0", "ini": "~1.3.0", "minimist": "^1.2.0", "strip-json-comments": "~2.0.1" @@ -2245,16 +1936,16 @@ } }, "rimraf": { - "version": "2.6.2", + "version": "2.6.3", "bundled": true, "dev": true, "optional": true, "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "safe-buffer": { - "version": "5.1.1", + "version": "5.1.2", "bundled": true, "dev": true }, @@ -2271,7 +1962,7 @@ "optional": true }, "semver": { - "version": "5.5.0", + "version": "5.7.0", "bundled": true, "dev": true, "optional": true @@ -2322,17 +2013,17 @@ "optional": true }, "tar": { - "version": "4.4.1", + "version": "4.4.8", "bundled": true, "dev": true, "optional": true, "requires": { - "chownr": "^1.0.1", + "chownr": "^1.1.1", "fs-minipass": "^1.2.5", - "minipass": "^2.2.4", - "minizlib": "^1.1.0", + "minipass": "^2.3.4", + "minizlib": "^1.1.1", "mkdirp": "^0.5.0", - "safe-buffer": "^5.1.1", + "safe-buffer": "^5.1.2", "yallist": "^3.0.2" } }, @@ -2343,12 +2034,12 @@ "optional": true }, "wide-align": { - "version": "1.1.2", + "version": "1.1.3", "bundled": true, "dev": true, "optional": true, "requires": { - "string-width": "^1.0.2" + "string-width": "^1.0.2 || 2" } }, "wrappy": { @@ -2357,52 +2048,12 @@ "dev": true }, "yallist": { - "version": "3.0.2", + "version": "3.0.3", "bundled": true, "dev": true } } }, - "ftp": { - "version": "0.3.10", - "resolved": "https://registry.npmjs.org/ftp/-/ftp-0.3.10.tgz", - "integrity": "sha1-kZfYYa2BQvPmPVqDv+TFn3MwiF0=", - "dev": true, - "optional": true, - "requires": { - "readable-stream": "1.1.x", - "xregexp": "2.0.0" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true, - "optional": true - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dev": true, - "optional": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true, - "optional": true - } - } - }, "gamefroot-texture-packer": { "version": "github:Gamefroot/Gamefroot-Texture-Packer#f3687111afc94f80ea8f2877c188fb8e2004e8ff", "from": "github:Gamefroot/Gamefroot-Texture-Packer#f3687111afc94f80ea8f2877c188fb8e2004e8ff", @@ -2429,44 +2080,12 @@ } } }, - "generate-function": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.0.0.tgz", - "integrity": "sha1-aFj+fAlpt9TpCTM3ZHrHn2DfvnQ=", - "dev": true, - "optional": true - }, - "generate-object-property": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/generate-object-property/-/generate-object-property-1.2.0.tgz", - "integrity": "sha1-nA4cQDCM6AT0eDYYuTf6iPmdUNA=", - "dev": true, - "optional": true, - "requires": { - "is-property": "^1.0.0" - } - }, "get-stdin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-4.0.1.tgz", "integrity": "sha1-uWjGsKBDhDJJAui/Gl3zJXmkUP4=", "dev": true }, - "get-uri": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/get-uri/-/get-uri-2.0.2.tgz", - "integrity": "sha512-ZD325dMZOgerGqF/rF6vZXyFGTAay62svjQIT+X/oU2PtxYpFxvSkbsdi+oxIrsNxlZVd4y8wUDqkaExWTI/Cw==", - "dev": true, - "optional": true, - "requires": { - "data-uri-to-buffer": "1", - "debug": "2", - "extend": "3", - "file-uri-to-path": "1", - "ftp": "~0.3.10", - "readable-stream": "2" - } - }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -2483,9 +2102,9 @@ } }, "glob": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", - "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", "dev": true, "requires": { "fs.realpath": "^1.0.0", @@ -2496,42 +2115,6 @@ "path-is-absolute": "^1.0.0" } }, - "glob-base": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", - "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true, - "requires": { - "glob-parent": "^2.0.0", - "is-glob": "^2.0.0" - }, - "dependencies": { - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "^2.0.0" - } - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - } - } - }, "glob-parent": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-3.1.0.tgz", @@ -2554,13 +2137,15 @@ } }, "glob-watcher": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.1.tgz", - "integrity": "sha512-fK92r2COMC199WCyGUblrZKhjra3cyVMDiypDdqg1vsSDmexnbYivK1kNR4QItiNXLKmGlqan469ks67RtNa2g==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/glob-watcher/-/glob-watcher-5.0.3.tgz", + "integrity": "sha512-8tWsULNEPHKQ2MR4zXuzSmqbdyV5PtwwCaWSGQ1WwHsJ07ilNeN1JB8ntxhckbnpSHaf9dXFUHzIWvm1I13dsg==", "dev": true, "requires": { + "anymatch": "^2.0.0", "async-done": "^1.2.0", "chokidar": "^2.0.0", + "is-negated-glob": "^1.0.0", "just-debounce": "^1.0.0", "object.defaults": "^1.1.0" } @@ -2572,37 +2157,22 @@ "dev": true }, "handlebars": { - "version": "4.0.11", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.0.11.tgz", - "integrity": "sha1-Ywo13+ApS8KB7a5v/F0yn8eYLcw=", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", + "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", "dev": true, "requires": { - "async": "^1.4.0", + "neo-async": "^2.6.0", "optimist": "^0.6.1", - "source-map": "^0.4.4", - "uglify-js": "^2.6" + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" }, "dependencies": { - "uglify-js": { - "version": "2.8.29", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.8.29.tgz", - "integrity": "sha1-KcVzMUgFe7Th913zW3qcty5qWd0=", - "dev": true, - "optional": true, - "requires": { - "source-map": "~0.5.1", - "uglify-to-browserify": "~1.0.0", - "yargs": "~3.10.0" - }, - "dependencies": { - "source-map": { - "version": "0.5.7", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", - "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "optional": true - } - } + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true } } }, @@ -2622,16 +2192,6 @@ "har-schema": "^2.0.0" } }, - "has-ansi": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", - "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, "has-binary2": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", @@ -2703,45 +2263,6 @@ "pinkie-promise": "^2.0.0" } }, - "hawk": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/hawk/-/hawk-3.1.3.tgz", - "integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=", - "dev": true, - "optional": true, - "requires": { - "boom": "2.x.x", - "cryptiles": "2.x.x", - "hoek": "2.x.x", - "sntp": "1.x.x" - } - }, - "hipchat-notifier": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/hipchat-notifier/-/hipchat-notifier-1.1.0.tgz", - "integrity": "sha1-ttJJdVQ3wZEII2d5nTupoPI7Ix4=", - "dev": true, - "optional": true, - "requires": { - "lodash": "^4.0.0", - "request": "^2.0.0" - }, - "dependencies": { - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true, - "optional": true - } - } - }, - "hoek": { - "version": "2.16.3", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz", - "integrity": "sha1-ILt0A9POo5jpHcRxCo/xuCdKJe0=", - "dev": true - }, "hosted-git-info": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", @@ -2761,21 +2282,22 @@ } }, "http-errors": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", - "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", + "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", "dev": true, "requires": { "depd": "~1.1.2", "inherits": "2.0.3", - "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" + "setprototypeof": "1.1.1", + "statuses": ">= 1.5.0 < 2", + "toidentifier": "1.0.0" } }, "http-parser-js": { - "version": "0.4.13", - "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.4.13.tgz", - "integrity": "sha1-O9bW/ebjFyyTNMOzO2wZPYD+ETc=", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/http-parser-js/-/http-parser-js-0.5.0.tgz", + "integrity": "sha512-cZdEF7r4gfRIq7ezX9J0T+kQmJNOub71dWbgAXVHDct80TKP4MCETtZQ31xyv38UwgzkWPYF/Xc0ge55dW9Z9w==", "dev": true }, "http-proxy": { @@ -2789,27 +2311,6 @@ "requires-port": "^1.0.0" } }, - "http-proxy-agent": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", - "integrity": "sha512-qwHbBLV7WviBl0rQsOzH6o5lwyOIvwp/BdFnvVxXORldu5TmjFfjzBcWUWS5kWAZhmv+JtiDhSuQCp4sBfbIgg==", - "dev": true, - "requires": { - "agent-base": "4", - "debug": "3.1.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, "http-signature": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", @@ -2821,22 +2322,6 @@ "sshpk": "^1.7.0" } }, - "httpntlm": { - "version": "1.6.1", - "resolved": "https://registry.npmjs.org/httpntlm/-/httpntlm-1.6.1.tgz", - "integrity": "sha1-rQFScUOi6Hc8+uapb1hla7UqNLI=", - "dev": true, - "requires": { - "httpreq": ">=0.4.22", - "underscore": "~1.7.0" - } - }, - "httpreq": { - "version": "0.4.24", - "resolved": "https://registry.npmjs.org/httpreq/-/httpreq-0.4.24.tgz", - "integrity": "sha1-QzX/2CzZaWaKOUZckprGHWOTYn8=", - "dev": true - }, "https-proxy-agent": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz", @@ -2848,25 +2333,56 @@ }, "dependencies": { "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, "iconv-lite": { - "version": "0.4.23", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", - "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3" } }, + "ignore-walk": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz", + "integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==", + "dev": true, + "requires": { + "minimatch": "^3.0.4" + } + }, + "imports-loader": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/imports-loader/-/imports-loader-0.8.0.tgz", + "integrity": "sha512-kXWL7Scp8KQ4552ZcdVTeaQCZSLW+e6nJfp3cwUMB673T7Hr98Xjx5JK+ql7ADlJUvj1JS5O01RLbKoutN5QDQ==", + "requires": { + "loader-utils": "^1.0.2", + "source-map": "^0.6.1" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + } + } + }, "indent-string": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-2.1.0.tgz", @@ -2882,13 +2398,6 @@ "integrity": "sha1-gtwzbSMrkGIXnQWrMpOmYFn9Q10=", "dev": true }, - "inflection": { - "version": "1.12.0", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.12.0.tgz", - "integrity": "sha1-ogCTVlbW9fa8TcdQLhrstwMihBY=", - "dev": true, - "optional": true - }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", @@ -2906,15 +2415,9 @@ "dev": true }, "interpret": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.1.0.tgz", - "integrity": "sha1-ftGxQQxqDg94z5XTuEQMY/eLhhQ=", - "dev": true - }, - "ip": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", - "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz", + "integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==", "dev": true }, "is-accessor-descriptor": { @@ -3006,21 +2509,6 @@ } } }, - "is-dotfile": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", - "integrity": "sha1-pqLzL/0t+wT1yiXs0Pa4PPeYoeE=", - "dev": true - }, - "is-equal-shallow": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", - "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true, - "requires": { - "is-primitive": "^2.0.0" - } - }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", @@ -3043,34 +2531,19 @@ } }, "is-glob": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.0.tgz", - "integrity": "sha1-lSHHaEXMJhCoUgPd8ICpWML/q8A=", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", + "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", "dev": true, "requires": { "is-extglob": "^2.1.1" } }, - "is-my-ip-valid": { + "is-negated-glob": { "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-my-ip-valid/-/is-my-ip-valid-1.0.0.tgz", - "integrity": "sha512-gmh/eWXROncUzRnIa1Ubrt5b8ep/MGSnfAUI3aRp+sqTCs1tv1Isl8d8F6JmkN3dXKc3ehZMrtiPN9eL03NuaQ==", - "dev": true, - "optional": true - }, - "is-my-json-valid": { - "version": "2.17.2", - "resolved": "https://registry.npmjs.org/is-my-json-valid/-/is-my-json-valid-2.17.2.tgz", - "integrity": "sha512-IBhBslgngMQN8DDSppmgDv7RNrlFotuuDsKcrCP3+HbFaVivIBU7u9oiiErw8sH4ynx3+gOGQ3q2otkgiSi6kg==", - "dev": true, - "optional": true, - "requires": { - "generate-function": "^2.0.0", - "generate-object-property": "^1.1.0", - "is-my-ip-valid": "^1.0.0", - "jsonpointer": "^4.0.0", - "xtend": "^4.0.0" - } + "resolved": "https://registry.npmjs.org/is-negated-glob/-/is-negated-glob-1.0.0.tgz", + "integrity": "sha1-aRC8pdqMleeEtXUbl2z1oQ/uNtI=", + "dev": true }, "is-number": { "version": "3.0.0", @@ -3092,23 +2565,6 @@ } } }, - "is-odd": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", - "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", - "dev": true, - "requires": { - "is-number": "^4.0.0" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", - "dev": true - } - } - }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -3118,25 +2574,6 @@ "isobject": "^3.0.1" } }, - "is-posix-bracket": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz", - "integrity": "sha1-MzTceXdDaOkvAW5vvAqI9c1ua8Q=", - "dev": true - }, - "is-primitive": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-primitive/-/is-primitive-2.0.0.tgz", - "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", - "dev": true - }, - "is-property": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-property/-/is-property-1.0.2.tgz", - "integrity": "sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=", - "dev": true, - "optional": true - }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -3174,10 +2611,13 @@ "dev": true }, "isbinaryfile": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.2.tgz", - "integrity": "sha1-Sj6XTsDLqQBNP8bN5yCeppNopiE=", - "dev": true + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/isbinaryfile/-/isbinaryfile-3.0.3.tgz", + "integrity": "sha512-8cJBL5tTd2OS0dM4jz07wQd5g0dCCqIhUxPIGtZfa5L6hWlvV5MHTITy/DBAsF+Oe2LS1X3krBUhNwaGUWpWxw==", + "dev": true, + "requires": { + "buffer-alloc": "^1.2.0" + } }, "isexe": { "version": "2.0.0", @@ -3285,36 +2725,28 @@ } }, "jasmine": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.1.0.tgz", - "integrity": "sha1-K9Wf1+xuwOistk4J9Fpo7SrRlSo=", + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jasmine/-/jasmine-3.4.0.tgz", + "integrity": "sha512-sR9b4n+fnBFDEd7VS2el2DeHgKcPiMVn44rtKFumq9q7P/t8WrxsVIZPob4UDdgcDNCwyDqwxCt4k9TDRmjPoQ==", "dev": true, "requires": { - "glob": "^7.0.6", - "jasmine-core": "~3.1.0" + "glob": "^7.1.3", + "jasmine-core": "~3.4.0" } }, "jasmine-core": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.1.0.tgz", - "integrity": "sha1-pHheE11d9lAk38kiSVPfWFvSdmw=" + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/jasmine-core/-/jasmine-core-3.4.0.tgz", + "integrity": "sha512-HU/YxV4i6GcmiH4duATwAbJQMlE0MsDIR5XmSVxURxKHn3aGAdbY1/ZJFmVRbKtnLwIxxMJD7gYaPsypcbYimg==" }, "js-yaml": { - "version": "3.12.0", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", - "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "version": "3.13.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", + "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" - }, - "dependencies": { - "esprima": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", - "dev": true - } } }, "jsbn": { @@ -3342,6 +2774,21 @@ "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", "dev": true }, + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "requires": { + "minimist": "^1.2.0" + }, + "dependencies": { + "minimist": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" + } + } + }, "jsonfile": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", @@ -3351,13 +2798,6 @@ "graceful-fs": "^4.1.6" } }, - "jsonpointer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/jsonpointer/-/jsonpointer-4.0.1.tgz", - "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", - "dev": true, - "optional": true - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -3377,177 +2817,52 @@ "dev": true }, "karma": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/karma/-/karma-2.0.2.tgz", - "integrity": "sha1-TS25QChQpmVR+nhLAWT7CCTtjEs=", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/karma/-/karma-4.1.0.tgz", + "integrity": "sha512-xckiDqyNi512U4dXGOOSyLKPwek6X/vUizSy2f3geYevbLj+UIdvNwbn7IwfUIL2g1GXEPWt/87qFD1fBbl/Uw==", "dev": true, "requires": { "bluebird": "^3.3.0", "body-parser": "^1.16.1", - "chokidar": "^1.4.1", + "braces": "^2.3.2", + "chokidar": "^2.0.3", "colors": "^1.1.0", - "combine-lists": "^1.0.0", "connect": "^3.6.0", "core-js": "^2.2.0", "di": "^0.0.1", "dom-serialize": "^2.2.0", - "expand-braces": "^0.1.1", + "flatted": "^2.0.0", "glob": "^7.1.1", "graceful-fs": "^4.1.2", "http-proxy": "^1.13.0", "isbinaryfile": "^3.0.0", - "lodash": "^4.17.4", - "log4js": "^2.3.9", - "mime": "^1.3.4", + "lodash": "^4.17.11", + "log4js": "^4.0.0", + "mime": "^2.3.1", "minimatch": "^3.0.2", "optimist": "^0.6.1", "qjobs": "^1.1.4", "range-parser": "^1.2.0", "rimraf": "^2.6.0", "safe-buffer": "^5.0.1", - "socket.io": "2.0.4", + "socket.io": "2.1.1", "source-map": "^0.6.1", "tmp": "0.0.33", - "useragent": "2.2.1" + "useragent": "2.3.0" }, "dependencies": { - "anymatch": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", - "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", - "dev": true, - "requires": { - "micromatch": "^2.1.5", - "normalize-path": "^2.0.0" - } - }, - "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1" - } - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, "bluebird": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.1.tgz", - "integrity": "sha512-MKiLiV+I1AA596t9w1sQJ8jkiSr5+ZKi0WKrYGUn6d1Fx+Ij4tIj+m2WMQSGczs5jZVxV339chE8iwk6F64wjA==", + "version": "3.5.4", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.4.tgz", + "integrity": "sha512-FG+nFEZChJrbQ9tIccIfZJBz3J7mLrAhxakAbnrJWn8d7aKOC+LWifa0G+p4ZqKp4y13T7juYvdhq9NzKdsrjw==", "dev": true }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" - } - }, - "chokidar": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", - "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", - "dev": true, - "requires": { - "anymatch": "^1.3.0", - "async-each": "^1.0.0", - "fsevents": "^1.0.0", - "glob-parent": "^2.0.0", - "inherits": "^2.0.1", - "is-binary-path": "^1.0.0", - "is-glob": "^2.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.0.0" - } - }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "^0.1.0" - } - }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "^2.0.0" - } - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" - } - }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", @@ -3570,9 +2885,9 @@ }, "dependencies": { "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true }, "source-map": { @@ -3584,10 +2899,13 @@ } }, "karma-jasmine": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-1.1.2.tgz", - "integrity": "sha1-OU8rJf+0pkS5rabyLUQ+L9CIhsM=", - "dev": true + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/karma-jasmine/-/karma-jasmine-2.0.1.tgz", + "integrity": "sha512-iuC0hmr9b+SNn1DaUD2QEYtUxkS1J+bSJSn7ejdEexs7P8EYvA1CWkEdrDQ+8jVH3AgWlCNwjYsT1chjcNW9lA==", + "dev": true, + "requires": { + "jasmine-core": "^3.3" + } }, "karma-phantomjs-launcher": { "version": "1.0.4", @@ -3600,9 +2918,9 @@ }, "dependencies": { "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true } } @@ -3637,13 +2955,6 @@ "graceful-fs": "^4.1.9" } }, - "lazy-cache": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", - "integrity": "sha1-odePw6UEdMuAhF07O24dpJpEbo4=", - "dev": true, - "optional": true - }, "levn": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", @@ -3654,227 +2965,31 @@ "type-check": "~0.3.2" } }, - "libbase64": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-0.1.0.tgz", - "integrity": "sha1-YjUag5VjrF/1vSbxL2Dpgwu3UeY=", - "dev": true - }, - "libmime": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/libmime/-/libmime-3.0.0.tgz", - "integrity": "sha1-UaGp50SOy9Ms2lRCFnW7IbwJPaY=", - "dev": true, - "requires": { - "iconv-lite": "0.4.15", - "libbase64": "0.1.0", - "libqp": "1.1.0" - }, - "dependencies": { - "iconv-lite": { - "version": "0.4.15", - "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.15.tgz", - "integrity": "sha1-/iZaIYrGpXz+hUkn6dBMGYJe3es=", - "dev": true - } - } - }, - "libqp": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/libqp/-/libqp-1.1.0.tgz", - "integrity": "sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g=", - "dev": true - }, "live-server": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/live-server/-/live-server-1.2.0.tgz", - "integrity": "sha1-RJhkS7+Bpm8Y3Y3/3vYcTBw3TKM=", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/live-server/-/live-server-1.2.1.tgz", + "integrity": "sha512-Yn2XCVjErTkqnM3FfTmM7/kWy3zP7+cEtC7x6u+wUzlQ+1UW3zEYbbyJrc0jNDwiMDZI0m4a0i3dxlGHVyXczw==", "dev": true, "requires": { - "chokidar": "^1.6.0", - "colors": "^1.3.0", - "connect": "3.5.x", - "cors": "^2.8.4", - "event-stream": "^3.3.4", + "chokidar": "^2.0.4", + "colors": "^1.3.3", + "connect": "^3.6.6", + "cors": "^2.8.5", + "event-stream": "3.3.4", "faye-websocket": "0.11.x", "http-auth": "3.1.x", - "morgan": "^1.6.1", + "morgan": "^1.9.1", "object-assign": "^4.1.1", - "opn": "^5.3.0", + "opn": "^6.0.0", "proxy-middleware": "^0.15.0", - "send": "^0.16.2", - "serve-index": "^1.7.2" + "send": "^0.17.0", + "serve-index": "^1.9.1" }, "dependencies": { - "anymatch": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-1.3.2.tgz", - "integrity": "sha512-0XNayC8lTHQ2OI8aljNCN3sSx6hsr/1+rlcDAotXJR7C1oZZHCNsfpbKwMjRA3Uqb5tF1Rae2oloTr4xpq+WjA==", - "dev": true, - "requires": { - "micromatch": "^2.1.5", - "normalize-path": "^2.0.0" - } - }, - "arr-diff": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", - "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1" - } - }, - "array-unique": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.2.1.tgz", - "integrity": "sha1-odl8yvy8JiXMcPrc6zalDFiwGlM=", - "dev": true - }, - "braces": { - "version": "1.8.5", - "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", - "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true, - "requires": { - "expand-range": "^1.8.1", - "preserve": "^0.2.0", - "repeat-element": "^1.1.2" - } - }, - "chokidar": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", - "integrity": "sha1-eY5ol3gVHIB2tLNg5e3SjNortGg=", - "dev": true, - "requires": { - "anymatch": "^1.3.0", - "async-each": "^1.0.0", - "fsevents": "^1.0.0", - "glob-parent": "^2.0.0", - "inherits": "^2.0.1", - "is-binary-path": "^1.0.0", - "is-glob": "^2.0.0", - "path-is-absolute": "^1.0.0", - "readdirp": "^2.0.0" - } - }, "colors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.0.tgz", - "integrity": "sha512-EDpX3a7wHMWFA7PUHWPHNWqOxIIRSJetuwl0AS5Oi/5FMV8kWm69RTlgm00GKjBO1xFHMtBbL49yRtMMdticBw==", - "dev": true - }, - "connect": { - "version": "3.5.1", - "resolved": "https://registry.npmjs.org/connect/-/connect-3.5.1.tgz", - "integrity": "sha1-bTDXpjx/FwhXprOqazY9lz3KWI4=", - "dev": true, - "requires": { - "debug": "~2.2.0", - "finalhandler": "0.5.1", - "parseurl": "~1.3.1", - "utils-merge": "1.0.0" - } - }, - "debug": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "integrity": "sha1-+HBX6ZWxofauaklgZkE3vFbwOdo=", - "dev": true, - "requires": { - "ms": "0.7.1" - } - }, - "expand-brackets": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", - "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true, - "requires": { - "is-posix-bracket": "^0.1.0" - } - }, - "extglob": { - "version": "0.3.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", - "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "finalhandler": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.5.1.tgz", - "integrity": "sha1-LEANjUUwk1vCMlScX6OF7Afeb80=", - "dev": true, - "requires": { - "debug": "~2.2.0", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "statuses": "~1.3.1", - "unpipe": "~1.0.0" - } - }, - "glob-parent": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", - "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true, - "requires": { - "is-glob": "^2.0.0" - } - }, - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } - }, - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true, - "requires": { - "is-buffer": "^1.1.5" - } - }, - "micromatch": { - "version": "2.3.11", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", - "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true, - "requires": { - "arr-diff": "^2.0.0", - "array-unique": "^0.2.1", - "braces": "^1.8.2", - "expand-brackets": "^0.1.4", - "extglob": "^0.3.1", - "filename-regex": "^2.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.1", - "kind-of": "^3.0.2", - "normalize-path": "^2.0.1", - "object.omit": "^2.0.0", - "parse-glob": "^3.0.4", - "regex-cache": "^0.4.2" - } - }, - "ms": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "integrity": "sha1-nNE8A62/8ltl7/3nzoZO6VIBcJg=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/colors/-/colors-1.3.3.tgz", + "integrity": "sha512-mmGt/1pZqYRjMxB1axhTo16/snVZ5krrKkcmMeVKxzECMMXoCgnvTPp10QgHfcbQZw8Dq2jMNG6je4JlWU0gWg==", "dev": true }, "object-assign": { @@ -3882,18 +2997,6 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", "dev": true - }, - "statuses": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.3.1.tgz", - "integrity": "sha1-+vUbnrdKrvOzrPStX2Gr8ky3uT4=", - "dev": true - }, - "utils-merge": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.0.tgz", - "integrity": "sha1-ApT7kiu5N1FTVBxPcJYjHyh8ivg=", - "dev": true } } }, @@ -3910,6 +3013,16 @@ "strip-bom": "^2.0.0" } }, + "loader-utils": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.2.3.tgz", + "integrity": "sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA==", + "requires": { + "big.js": "^5.2.2", + "emojis-list": "^2.0.0", + "json5": "^1.0.1" + } + }, "lodash": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", @@ -3922,166 +3035,35 @@ "dev": true }, "log4js": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/log4js/-/log4js-2.8.0.tgz", - "integrity": "sha512-PjsaE4ElS0e2jWOY14Ef2PrC1Y+fny4AWPPT3xD6+2k2Aa5golhqJ4DSzP+5kXRL5bSw/5j1ocU5A9ceaxZeGA==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/log4js/-/log4js-4.1.1.tgz", + "integrity": "sha512-tSQUF9bBMdcBtuLD6vD7hBM9Ci6Lng/NVHZEq4YbuRGo7ObmLiZuhxz33HKAmJItit74pAjvZgirqYX2LRaoGA==", "dev": true, "requires": { - "amqplib": "^0.5.2", - "axios": "^0.15.3", - "circular-json": "^0.5.4", - "date-format": "^1.2.0", - "debug": "^3.1.0", - "hipchat-notifier": "^1.1.0", - "loggly": "^1.1.0", - "mailgun-js": "^0.18.0", - "nodemailer": "^2.5.0", - "redis": "^2.7.1", - "semver": "^5.5.0", - "slack-node": "~0.2.0", - "streamroller": "0.7.0" + "date-format": "^2.0.0", + "debug": "^4.1.1", + "flatted": "^2.0.0", + "rfdc": "^1.1.2", + "streamroller": "^1.0.4" }, "dependencies": { "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", "dev": true, "requires": { - "ms": "2.0.0" + "ms": "^2.1.1" } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, - "loggly": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/loggly/-/loggly-1.1.1.tgz", - "integrity": "sha1-Cg/B0/o6XsRP3HuJe+uipGlc6+4=", - "dev": true, - "optional": true, - "requires": { - "json-stringify-safe": "5.0.x", - "request": "2.75.x", - "timespan": "2.3.x" - }, - "dependencies": { - "assert-plus": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-0.2.0.tgz", - "integrity": "sha1-104bh+ev/A24qttwIfP+SBAasjQ=", - "dev": true, - "optional": true - }, - "aws-sign2": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz", - "integrity": "sha1-FDQt0428yU0OW4fXY81jYSwOeU8=", - "dev": true, - "optional": true - }, - "caseless": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.11.0.tgz", - "integrity": "sha1-cVuW6phBWTzDMGeSP17GDr2k99c=", - "dev": true, - "optional": true - }, - "form-data": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.0.0.tgz", - "integrity": "sha1-bwrrrcxdoWwT4ezBETfYX5uIOyU=", - "dev": true, - "optional": true, - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.5", - "mime-types": "^2.1.11" - } - }, - "har-validator": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-2.0.6.tgz", - "integrity": "sha1-zcvAgYgmWtEZtqWnyKtw7s+10n0=", - "dev": true, - "optional": true, - "requires": { - "chalk": "^1.1.1", - "commander": "^2.9.0", - "is-my-json-valid": "^2.12.4", - "pinkie-promise": "^2.0.0" - } - }, - "http-signature": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.1.1.tgz", - "integrity": "sha1-33LiZwZs0Kxn+3at+OE0qPvPkb8=", - "dev": true, - "optional": true, - "requires": { - "assert-plus": "^0.2.0", - "jsprim": "^1.2.2", - "sshpk": "^1.7.0" - } - }, - "node-uuid": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz", - "integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=", - "dev": true, - "optional": true - }, - "qs": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.2.3.tgz", - "integrity": "sha1-HPyyXBCpsrSDBT/zn138kjOQjP4=", - "dev": true, - "optional": true - }, - "request": { - "version": "2.75.0", - "resolved": "https://registry.npmjs.org/request/-/request-2.75.0.tgz", - "integrity": "sha1-0rgmiihtoT6qXQGt9dGMyQ9lfZM=", - "dev": true, - "optional": true, - "requires": { - "aws-sign2": "~0.6.0", - "aws4": "^1.2.1", - "bl": "~1.1.2", - "caseless": "~0.11.0", - "combined-stream": "~1.0.5", - "extend": "~3.0.0", - "forever-agent": "~0.6.1", - "form-data": "~2.0.0", - "har-validator": "~2.0.6", - "hawk": "~3.1.3", - "http-signature": "~1.1.0", - "is-typedarray": "~1.0.0", - "isstream": "~0.1.2", - "json-stringify-safe": "~5.0.1", - "mime-types": "~2.1.7", - "node-uuid": "~1.4.7", - "oauth-sign": "~0.8.1", - "qs": "~6.2.0", - "stringstream": "~0.0.4", - "tough-cookie": "~2.3.0", - "tunnel-agent": "~0.4.1" - } - }, - "tunnel-agent": { - "version": "0.4.3", - "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.4.3.tgz", - "integrity": "sha1-Y3PbdpCf5XDgjXNYM2Xtgop07us=", - "dev": true, - "optional": true - } - } - }, - "longest": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", - "integrity": "sha1-MKCy2jj3N3DoKUoNIuZiXtd9AJc=", - "dev": true - }, "loud-rejection": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz", @@ -4093,74 +3075,15 @@ } }, "lru-cache": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.3.tgz", - "integrity": "sha512-fFEhvcgzuIoJVUF8fYr5KR0YqxD238zgObTps31YdADwPPAp82a4M8TrckkWyx7ekNlf9aBcVn81cFwwXngrJA==", + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.5.tgz", + "integrity": "sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==", "dev": true, - "optional": true, "requires": { "pseudomap": "^1.0.2", "yallist": "^2.1.2" } }, - "mailcomposer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/mailcomposer/-/mailcomposer-4.0.1.tgz", - "integrity": "sha1-DhxEsqB890DuF9wUm6AJ8Zyt/rQ=", - "dev": true, - "optional": true, - "requires": { - "buildmail": "4.0.1", - "libmime": "3.0.0" - } - }, - "mailgun-js": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/mailgun-js/-/mailgun-js-0.18.0.tgz", - "integrity": "sha512-o0P6jjZlx5CQj12tvVgDTbgjTqVN0+5h6/6P1+3c6xmozVKBwniQ6Qt3MkCSF0+ueVTbobAfWyGpWRZMJu8t1g==", - "dev": true, - "optional": true, - "requires": { - "async": "~2.6.0", - "debug": "~3.1.0", - "form-data": "~2.3.0", - "inflection": "~1.12.0", - "is-stream": "^1.1.0", - "path-proxy": "~1.0.0", - "promisify-call": "^2.0.2", - "proxy-agent": "~3.0.0", - "tsscmp": "~1.0.0" - }, - "dependencies": { - "async": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz", - "integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==", - "dev": true, - "optional": true, - "requires": { - "lodash": "^4.17.10" - } - }, - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - }, - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true, - "optional": true - } - } - }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -4188,12 +3111,6 @@ "object-visit": "^1.0.0" } }, - "math-random": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/math-random/-/math-random-1.0.1.tgz", - "integrity": "sha1-izqsWIuKZuSXXjzepn97sylgH6w=", - "dev": true - }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -4227,25 +3144,25 @@ } }, "microargs": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/microargs/-/microargs-1.1.0.tgz", - "integrity": "sha1-XsPNi9dzf1fUhVlBMZM+qUMJ+1k=", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/microargs/-/microargs-1.1.2.tgz", + "integrity": "sha512-fUrX9ozzzUX6JlDoNXmUM5i4B0uBF5xPznZ0Y/izM9wOtAaTf44V2vUCRgGBLUq/SeGIcDgfnEZDVoT92HId0g==", "dev": true }, "microcli": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/microcli/-/microcli-1.3.1.tgz", - "integrity": "sha512-0MQ0w457h33GuktLJwzA/EmZK9B7QwcG5FqWM+7Ep5XPkFJvT3vZ6XIDaqUXYLpDAqsCSnhTKTWzWiDbXkn8mQ==", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/microcli/-/microcli-1.3.3.tgz", + "integrity": "sha512-1isRaEBpfRC8vJMJymKknAH8CdPFABuWPVc18rlRWHOCcHLYEkJxcoH7FNkX7AuTGrB4Uf1ve6B0s/FfwzGWKg==", "dev": true, "requires": { - "lodash": "4.17.4", - "microargs": "1.1.0" + "lodash": "4.17.11", + "microargs": "1.1.2" }, "dependencies": { "lodash": { - "version": "4.17.4", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", - "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=", + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", "dev": true } } @@ -4272,9 +3189,9 @@ } }, "mime": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.2.tgz", + "integrity": "sha512-zJBfZDkwRu+j3Pdd2aHsR5GfH2jIWhmL1ZzBoc+X+3JEti2hbArWcyJ+1laC1D2/U/W1a/+Cegj0/OnEU2ybjg==", "dev": true }, "mime-db": { @@ -4346,14 +3263,14 @@ } }, "morgan": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.0.tgz", - "integrity": "sha1-0B+mxlhZt2/PMbPLU6OCGjEdgFE=", + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz", + "integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==", "dev": true, "requires": { "basic-auth": "~2.0.0", "debug": "2.6.9", - "depd": "~1.1.1", + "depd": "~1.1.2", "on-finished": "~2.3.0", "on-headers": "~1.0.1" } @@ -4365,22 +3282,22 @@ "dev": true }, "mustache": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/mustache/-/mustache-2.3.0.tgz", - "integrity": "sha1-QCj3d4sXcIpImTCm5SrDvKDaQdA=", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-2.3.2.tgz", + "integrity": "sha512-KpMNwdQsYz3O/SBS1qJ/o3sqUJ5wSb8gb0pul8CO0S56b9Y2ALm8zCfsjPXsqGFfoNBkDwZuZIAjhsZI03gYVQ==", "dev": true }, "nan": { - "version": "2.10.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.10.0.tgz", - "integrity": "sha512-bAdJv7fBLhWC+/Bls0Oza+mvTaNQtP+1RyhhhvD95pgUJz6XM5IzgmxOkItJ9tkoCiplvAnXI1tNmmUD/eScyA==", + "version": "2.13.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.13.2.tgz", + "integrity": "sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw==", "dev": true, "optional": true }, "nanomatch": { - "version": "1.2.9", - "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.9.tgz", - "integrity": "sha512-n8R9bS8yQ6eSXaV6jHUpKzD8gLsin02w1HSFiegwrs9E098Ylhw5jdyKPaYqvHknHaSCKTPp7C8dGCQ0q9koXA==", + "version": "1.2.13", + "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", + "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", "dev": true, "requires": { "arr-diff": "^4.0.0", @@ -4388,7 +3305,6 @@ "define-property": "^2.0.2", "extend-shallow": "^3.0.2", "fragment-cache": "^0.2.1", - "is-odd": "^2.0.0", "is-windows": "^1.0.2", "kind-of": "^6.0.2", "object.pick": "^1.3.0", @@ -4398,101 +3314,21 @@ } }, "negotiator": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", - "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", + "version": "0.6.2", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", + "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==", "dev": true }, - "netmask": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/netmask/-/netmask-1.0.6.tgz", - "integrity": "sha1-ICl+idhvb2QA8lDZ9Pa0wZRfzTU=", - "dev": true, - "optional": true - }, - "nodemailer": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-2.7.2.tgz", - "integrity": "sha1-8kLmSa7q45tsftdA73sGHEBNMPk=", - "dev": true, - "optional": true, - "requires": { - "libmime": "3.0.0", - "mailcomposer": "4.0.1", - "nodemailer-direct-transport": "3.3.2", - "nodemailer-shared": "1.1.0", - "nodemailer-smtp-pool": "2.8.2", - "nodemailer-smtp-transport": "2.7.2", - "socks": "1.1.9" - }, - "dependencies": { - "socks": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/socks/-/socks-1.1.9.tgz", - "integrity": "sha1-Yo1+TQSRJDVEWsC25Fk3bLPm1pE=", - "dev": true, - "optional": true, - "requires": { - "ip": "^1.1.2", - "smart-buffer": "^1.0.4" - } - } - } - }, - "nodemailer-direct-transport": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/nodemailer-direct-transport/-/nodemailer-direct-transport-3.3.2.tgz", - "integrity": "sha1-6W+vuQNYVglH5WkBfZfmBzilCoY=", - "dev": true, - "optional": true, - "requires": { - "nodemailer-shared": "1.1.0", - "smtp-connection": "2.12.0" - } - }, - "nodemailer-fetch": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/nodemailer-fetch/-/nodemailer-fetch-1.6.0.tgz", - "integrity": "sha1-ecSQihwPXzdbc/6IjamCj23JY6Q=", + "neo-async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.0.tgz", + "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", "dev": true }, - "nodemailer-shared": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/nodemailer-shared/-/nodemailer-shared-1.1.0.tgz", - "integrity": "sha1-z1mU4v0mjQD1zw+nZ6CBae2wfsA=", - "dev": true, - "requires": { - "nodemailer-fetch": "1.6.0" - } - }, - "nodemailer-smtp-pool": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/nodemailer-smtp-pool/-/nodemailer-smtp-pool-2.8.2.tgz", - "integrity": "sha1-LrlNbPhXgLG0clzoU7nL1ejajHI=", - "dev": true, - "optional": true, - "requires": { - "nodemailer-shared": "1.1.0", - "nodemailer-wellknown": "0.1.10", - "smtp-connection": "2.12.0" - } - }, - "nodemailer-smtp-transport": { - "version": "2.7.2", - "resolved": "https://registry.npmjs.org/nodemailer-smtp-transport/-/nodemailer-smtp-transport-2.7.2.tgz", - "integrity": "sha1-A9ccdjFPFKx9vHvwM6am0W1n+3c=", - "dev": true, - "optional": true, - "requires": { - "nodemailer-shared": "1.1.0", - "nodemailer-wellknown": "0.1.10", - "smtp-connection": "2.12.0" - } - }, - "nodemailer-wellknown": { - "version": "0.1.10", - "resolved": "https://registry.npmjs.org/nodemailer-wellknown/-/nodemailer-wellknown-0.1.10.tgz", - "integrity": "sha1-WG24EB2zDLRDjrVGc3pBqtDPE9U=", + "node-fetch": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.5.0.tgz", + "integrity": "sha512-YuZKluhWGJwCcUu4RlZstdAxr8bFfOVHakc1mplwHkk8J+tqM1Y5yraYvIUpeX8aY7+crCwiELJq7Vl0o0LWXw==", "dev": true }, "nopt": { @@ -4601,27 +3437,6 @@ "isobject": "^3.0.0" } }, - "object.omit": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", - "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true, - "requires": { - "for-own": "^0.1.4", - "is-extendable": "^0.1.1" - }, - "dependencies": { - "for-own": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", - "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true, - "requires": { - "for-in": "^1.0.1" - } - } - } - }, "object.pick": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", @@ -4647,9 +3462,9 @@ } }, "on-headers": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz", - "integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.2.tgz", + "integrity": "sha512-pZAE+FJLoyITytdqK0U5s+FIpjN0JP3OzFi/u8Rx+EV5/W+JTWGXG8xFzevE7AjBfDqHv/8vL8qQsIhHnqRkrA==", "dev": true }, "once": { @@ -4662,9 +3477,9 @@ } }, "opn": { - "version": "5.3.0", - "resolved": "https://registry.npmjs.org/opn/-/opn-5.3.0.tgz", - "integrity": "sha512-bYJHo/LOmoTd+pfiYhfZDnf9zekVJrY+cnS2a5F2x+w5ppvTqObojTP7WiFG+kVZs9Inw+qQ/lw7TroWwhdd2g==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/opn/-/opn-6.0.0.tgz", + "integrity": "sha512-I9PKfIZC+e4RXZ/qr1RhgyCnGgYX0UEIlXgWnCOVACIvFgaC9rz6Won7xbdhoHrd8IIhV7YEpHjreNUNkqCGkQ==", "dev": true, "requires": { "is-wsl": "^1.1.0" @@ -4708,85 +3523,21 @@ "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", "dev": true }, - "pac-proxy-agent": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-2.0.2.tgz", - "integrity": "sha512-cDNAN1Ehjbf5EHkNY5qnRhGPUCp6SnpyVof5fRzN800QV1Y2OkzbH9rmjZkbBRa8igof903yOnjIl6z0SlAhxA==", - "dev": true, - "optional": true, - "requires": { - "agent-base": "^4.2.0", - "debug": "^3.1.0", - "get-uri": "^2.0.0", - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^2.2.1", - "pac-resolver": "^3.0.0", - "raw-body": "^2.2.0", - "socks-proxy-agent": "^3.0.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "pac-resolver": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-3.0.0.tgz", - "integrity": "sha512-tcc38bsjuE3XZ5+4vP96OfhOugrX+JcnpUbhfuc4LuXBLQhoTthOstZeoQJBDnQUDYzYmdImKsbz0xSl1/9qeA==", - "dev": true, - "optional": true, - "requires": { - "co": "^4.6.0", - "degenerator": "^1.0.4", - "ip": "^1.1.5", - "netmask": "^1.0.6", - "thunkify": "^2.1.2" - } - }, "parse": { - "version": "1.11.1", - "resolved": "https://registry.npmjs.org/parse/-/parse-1.11.1.tgz", - "integrity": "sha1-VY5TnULZ+4khDggiCdbzsD1frtU=", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/parse/-/parse-2.4.0.tgz", + "integrity": "sha512-H6PDiML1CFnswInFL9dAszPaHkXH9eEzH1sGKUs/sf0R9h8eZQjYO8QoO/xObZJe3gHJMHx4StGE/zs4G3NLDw==", "requires": { - "babel-runtime": "^6.11.6", - "ws": "^3.3.1", - "xmlhttprequest": "^1.7.0" - } - }, - "parse-glob": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", - "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true, - "requires": { - "glob-base": "^0.3.0", - "is-dotfile": "^1.0.0", - "is-extglob": "^1.0.0", - "is-glob": "^2.0.0" + "@babel/runtime": "7.4.3", + "uuid": "3.3.2", + "ws": "6.2.1", + "xmlhttprequest": "1.8.0" }, "dependencies": { - "is-extglob": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-1.0.0.tgz", - "integrity": "sha1-rEaBd8SUNAWgkvyPKXYMb/xiBsA=", - "dev": true - }, - "is-glob": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", - "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true, - "requires": { - "is-extglob": "^1.0.0" - } + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" } } }, @@ -4818,9 +3569,9 @@ } }, "parseurl": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", - "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=", + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==", "dev": true }, "pascalcase": { @@ -4850,25 +3601,6 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, - "path-proxy": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/path-proxy/-/path-proxy-1.0.0.tgz", - "integrity": "sha1-GOijaFn8nS8aU7SN7hOFQ8Ag3l4=", - "dev": true, - "optional": true, - "requires": { - "inflection": "~1.3.0" - }, - "dependencies": { - "inflection": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.3.8.tgz", - "integrity": "sha1-y9Fg2p91sUw8xjV41POWeEvzAU4=", - "dev": true, - "optional": true - } - } - }, "path-type": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz", @@ -4919,11 +3651,13 @@ } }, "phaser": { - "version": "3.10.1", - "resolved": "https://registry.npmjs.org/phaser/-/phaser-3.10.1.tgz", - "integrity": "sha512-+JBisNlWvY/T+YjyuoswSG62S/j6Y0YYd5gjt2uY5KAXl4v7QCPnto4Wpx8XXWrJ0R5RV0p4jZXAPgKEYjVynQ==", + "version": "3.16.2", + "resolved": "https://registry.npmjs.org/phaser/-/phaser-3.16.2.tgz", + "integrity": "sha512-r1SipuO4Lq17cmQOegZV6zBdqmQyJH2A6CZz/dNYPIPfGQl8Clay0hWqI/FluMi7uPrSFvaY63VeRpr1IP10iA==", "requires": { - "eventemitter3": "^3.1.0" + "eventemitter3": "^3.1.0", + "exports-loader": "^0.7.0", + "imports-loader": "^0.8.0" } }, "pify": { @@ -4948,55 +3682,15 @@ } }, "plugin-error": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz", - "integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-1.0.1.tgz", + "integrity": "sha512-L1zP0dk7vGweZME2i+EeakvUNqSrdiI3F91TwEoYiGrAfUXmVv6fJIq4g82PAXxNsWOp0J7ZqQy/3Szz0ajTxA==", "dev": true, "requires": { - "ansi-cyan": "^0.1.1", - "ansi-red": "^0.1.1", - "arr-diff": "^1.0.1", - "arr-union": "^2.0.1", - "extend-shallow": "^1.1.2" - }, - "dependencies": { - "arr-diff": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz", - "integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=", - "dev": true, - "requires": { - "arr-flatten": "^1.0.1", - "array-slice": "^0.2.3" - } - }, - "arr-union": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz", - "integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=", - "dev": true - }, - "array-slice": { - "version": "0.2.3", - "resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz", - "integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=", - "dev": true - }, - "extend-shallow": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz", - "integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=", - "dev": true, - "requires": { - "kind-of": "^1.1.0" - } - }, - "kind-of": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz", - "integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=", - "dev": true - } + "ansi-colors": "^1.0.1", + "arr-diff": "^4.0.0", + "arr-union": "^3.1.0", + "extend-shallow": "^3.0.2" } }, "posix-character-classes": { @@ -5011,12 +3705,6 @@ "integrity": "sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ=", "dev": true }, - "preserve": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/preserve/-/preserve-0.2.0.tgz", - "integrity": "sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks=", - "dev": true - }, "process-nextick-args": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-1.0.7.tgz", @@ -5040,52 +3728,6 @@ "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", "dev": true }, - "promisify-call": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/promisify-call/-/promisify-call-2.0.4.tgz", - "integrity": "sha1-1IwtRWUszM1SgB3ey9UzptS9X7o=", - "dev": true, - "optional": true, - "requires": { - "with-callback": "^1.0.2" - } - }, - "proxy-agent": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-3.0.0.tgz", - "integrity": "sha512-g6n6vnk8fRf705ShN+FEXFG/SDJaW++lSs0d9KaJh4uBWW/wi7en4Cpo5VYQW3SZzAE121lhB/KLQrbURoubZw==", - "dev": true, - "optional": true, - "requires": { - "agent-base": "^4.2.0", - "debug": "^3.1.0", - "http-proxy-agent": "^2.1.0", - "https-proxy-agent": "^2.2.1", - "lru-cache": "^4.1.2", - "pac-proxy-agent": "^2.0.1", - "proxy-from-env": "^1.0.0", - "socks-proxy-agent": "^3.0.0" - }, - "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", - "dev": true, - "optional": true, - "requires": { - "ms": "2.0.0" - } - } - } - }, - "proxy-from-env": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", - "integrity": "sha1-M8UDmPcOp+uW0h97gXYwpVeRx+4=", - "dev": true, - "optional": true - }, "proxy-middleware": { "version": "0.15.0", "resolved": "https://registry.npmjs.org/proxy-middleware/-/proxy-middleware-0.15.0.tgz", @@ -5096,8 +3738,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true, - "optional": true + "dev": true }, "punycode": { "version": "1.4.1", @@ -5117,25 +3758,6 @@ "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", "dev": true }, - "randomatic": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.0.0.tgz", - "integrity": "sha512-VdxFOIEY3mNO5PtSRkkle/hPJDHvQhK21oa73K4yAc9qmp6N429gAyF1gZMOTMeS0/AYzaV/2Trcef+NaIonSA==", - "dev": true, - "requires": { - "is-number": "^4.0.0", - "kind-of": "^6.0.0", - "math-random": "^1.0.1" - }, - "dependencies": { - "is-number": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", - "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", - "dev": true - } - } - }, "range-parser": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", @@ -5143,14 +3765,14 @@ "dev": true }, "raw-body": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", - "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", + "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", "dev": true, "requires": { - "bytes": "3.0.0", - "http-errors": "1.6.3", - "iconv-lite": "0.4.23", + "bytes": "3.1.0", + "http-errors": "1.7.2", + "iconv-lite": "0.4.24", "unpipe": "1.0.0" } }, @@ -5199,15 +3821,14 @@ } }, "readdirp": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.1.0.tgz", - "integrity": "sha1-TtCtBg3zBzMAxIRANz9y0cxkLXg=", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-2.2.1.tgz", + "integrity": "sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ==", "dev": true, "requires": { - "graceful-fs": "^4.1.2", - "minimatch": "^3.0.2", - "readable-stream": "^2.0.2", - "set-immediate-shim": "^1.0.1" + "graceful-fs": "^4.1.11", + "micromatch": "^3.1.10", + "readable-stream": "^2.0.2" } }, "rechoir": { @@ -5229,45 +3850,11 @@ "strip-indent": "^1.0.1" } }, - "redis": { - "version": "2.8.0", - "resolved": "https://registry.npmjs.org/redis/-/redis-2.8.0.tgz", - "integrity": "sha512-M1OkonEQwtRmZv4tEWF2VgpG0JWJ8Fv1PhlgT5+B+uNq2cA3Rt1Yt/ryoR+vQNOQcIEgdCdfH0jr3bDpihAw1A==", - "dev": true, - "optional": true, - "requires": { - "double-ended-queue": "^2.1.0-0", - "redis-commands": "^1.2.0", - "redis-parser": "^2.6.0" - } - }, - "redis-commands": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.3.5.tgz", - "integrity": "sha512-foGF8u6MXGFF++1TZVC6icGXuMYPftKXt1FBT2vrfU9ZATNtZJ8duRC5d1lEfE8hyVe3jhelHGB91oB7I6qLsA==", - "dev": true, - "optional": true - }, - "redis-parser": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-2.6.0.tgz", - "integrity": "sha1-Uu0J2srBCPGmMcB+m2mUHnoZUEs=", - "dev": true, - "optional": true - }, "regenerator-runtime": { "version": "0.11.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz", - "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==" - }, - "regex-cache": { - "version": "0.4.4", - "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", - "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", - "dev": true, - "requires": { - "is-equal-shallow": "^0.1.3" - } + "integrity": "sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg==", + "dev": true }, "regex-not": { "version": "1.0.2", @@ -5280,17 +3867,16 @@ } }, "remap-istanbul": { - "version": "0.11.1", - "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.11.1.tgz", - "integrity": "sha512-Itv3XvYjD6G+9xDzAeFohx4GUwbFjfqFt0UXlC826jHR18E49fEiEGqZUxUASwMq4z7wwUv2H9/XF2d6qj0iaQ==", + "version": "0.13.0", + "resolved": "https://registry.npmjs.org/remap-istanbul/-/remap-istanbul-0.13.0.tgz", + "integrity": "sha512-rS5ZpVAx3fGtKZkiBe1esXg5mKYbgW9iz8kkADFt3p6lo3NsBBUX1q6SwdhwUtYCGnr7nK6gRlbYK3i8R0jbRA==", "dev": true, "requires": { - "amdefine": "^1.0.0", "istanbul": "0.4.5", - "minimatch": "^3.0.3", - "plugin-error": "^0.1.2", - "source-map": "^0.6.1", - "through2": "2.0.1" + "minimatch": "^3.0.4", + "plugin-error": "^1.0.1", + "source-map": "0.6.1", + "through2": "3.0.0" }, "dependencies": { "source-map": { @@ -5308,9 +3894,9 @@ "dev": true }, "repeat-element": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", - "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.3.tgz", + "integrity": "sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g==", "dev": true }, "repeat-string": { @@ -5365,28 +3951,6 @@ "throttleit": "^1.0.0" } }, - "requestretry": { - "version": "1.13.0", - "resolved": "https://registry.npmjs.org/requestretry/-/requestretry-1.13.0.tgz", - "integrity": "sha512-Lmh9qMvnQXADGAQxsXHP4rbgO6pffCfuR8XUBdP9aitJcLQJxhp7YZK4xAVYXnPJ5E52mwrfiKQtKonPL8xsmg==", - "dev": true, - "optional": true, - "requires": { - "extend": "^3.0.0", - "lodash": "^4.15.0", - "request": "^2.74.0", - "when": "^3.7.7" - }, - "dependencies": { - "lodash": { - "version": "4.17.10", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", - "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", - "dev": true, - "optional": true - } - } - }, "requires-port": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", @@ -5416,78 +3980,38 @@ "resolved": "https://registry.npmjs.org/rewire/-/rewire-2.5.2.tgz", "integrity": "sha1-ZCfee3/u+n02QBUH62SlOFvFjcc=" }, - "right-align": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/right-align/-/right-align-0.1.3.tgz", - "integrity": "sha1-YTObci/mo1FWiSENJOFMlhSGE+8=", - "dev": true, - "optional": true, - "requires": { - "align-text": "^0.1.1" - } + "rfdc": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.1.2.tgz", + "integrity": "sha512-92ktAgvZhBzYTIK0Mja9uen5q5J3NRVMoDkJL2VMwq6SXjVCgqvQeVP2XAaUY6HT+XpQYeLSjb3UoitBryKmdA==", + "dev": true }, "rimraf": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", - "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", + "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", "dev": true, "requires": { - "glob": "^7.0.5" + "glob": "^7.1.3" } }, "runjs": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/runjs/-/runjs-4.3.2.tgz", - "integrity": "sha512-HPXoaK7Dop2z4nb+EGkwvT5v5zz2Kl79e4jN5Eugt8CPHvtJyCx/5T/Y9FLdLWX951OnW192OHVT+4ymIlK2BQ==", + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/runjs/-/runjs-4.4.2.tgz", + "integrity": "sha512-/DB54HRJnxfGA/a9QLZMyAn8H84SMt8oVGF7Vz+OS4BMCve312DXNRpy6Z8yohLuoMctoalXQtvmpd2ChQYD4Q==", "dev": true, "requires": { "chalk": "2.3.0", "lodash.padend": "4.6.1", - "microcli": "1.3.1", + "microcli": "1.3.3", "omelette": "0.4.5" - }, - "dependencies": { - "ansi-styles": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", - "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", - "dev": true, - "requires": { - "color-convert": "^1.9.0" - } - }, - "chalk": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", - "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", - "dev": true, - "requires": { - "ansi-styles": "^3.1.0", - "escape-string-regexp": "^1.0.5", - "supports-color": "^4.0.0" - } - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "supports-color": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", - "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", - "dev": true, - "requires": { - "has-flag": "^2.0.0" - } - } } }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true }, "safe-regex": { "version": "1.1.0", @@ -5511,9 +4035,9 @@ "dev": true }, "send": { - "version": "0.16.2", - "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", - "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "version": "0.17.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.17.0.tgz", + "integrity": "sha512-NYR0jCuwnBaGA2X5bO3+QDZmmJ+PUCvFCRTED5nx9l/BK3Pr8mD8Ryvk9bw08JJUdXxt2u+tVIGoqJPrHWGqSA==", "dev": true, "requires": { "debug": "2.6.9", @@ -5523,24 +4047,24 @@ "escape-html": "~1.0.3", "etag": "~1.8.1", "fresh": "0.5.2", - "http-errors": "~1.6.2", - "mime": "1.4.1", - "ms": "2.0.0", + "http-errors": "~1.7.2", + "mime": "1.6.0", + "ms": "2.1.1", "on-finished": "~2.3.0", "range-parser": "~1.2.0", - "statuses": "~1.4.0" + "statuses": "~1.5.0" }, "dependencies": { "mime": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", - "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", "dev": true }, - "statuses": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", - "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==", + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "dev": true } } @@ -5558,14 +4082,28 @@ "http-errors": "~1.6.2", "mime-types": "~2.1.17", "parseurl": "~1.3.2" + }, + "dependencies": { + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "dev": true, + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", + "dev": true + } } }, - "set-immediate-shim": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz", - "integrity": "sha1-SysbJ+uAip+NzEgaWOXlb1mfP2E=", - "dev": true - }, "set-value": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", @@ -5590,15 +4128,15 @@ } }, "setprototypeof": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", - "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", + "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==", "dev": true }, "shelljs": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.2.tgz", - "integrity": "sha512-pRXeNrCA2Wd9itwhvLp5LZQvPJ0wU6bcjaTMywHHGX5XWhVN2nzSu7WV0q+oUY7mGK3mgSkDDzP3MgjqdyIgbQ==", + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz", + "integrity": "sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A==", "dev": true, "requires": { "glob": "^7.0.0", @@ -5612,32 +4150,6 @@ "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", "dev": true }, - "slack-node": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/slack-node/-/slack-node-0.2.0.tgz", - "integrity": "sha1-3kuN3aqLeT9h29KTgQT9q/N9+jA=", - "dev": true, - "optional": true, - "requires": { - "requestretry": "^1.2.2" - } - }, - "smart-buffer": { - "version": "1.1.15", - "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-1.1.15.tgz", - "integrity": "sha1-fxFLW2X6s+KjWqd1uxLw0cZJvxY=", - "dev": true - }, - "smtp-connection": { - "version": "2.12.0", - "resolved": "https://registry.npmjs.org/smtp-connection/-/smtp-connection-2.12.0.tgz", - "integrity": "sha1-1275EnyyPCJZ7bHoNJwujV4tdME=", - "dev": true, - "requires": { - "httpntlm": "1.6.1", - "nodemailer-shared": "1.1.0" - } - }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -5751,27 +4263,29 @@ } } }, - "sntp": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/sntp/-/sntp-1.0.9.tgz", - "integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=", - "dev": true, - "optional": true, - "requires": { - "hoek": "2.x.x" - } - }, "socket.io": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.0.4.tgz", - "integrity": "sha1-waRZDO/4fs8TxyZS8Eb3FrKeYBQ=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-2.1.1.tgz", + "integrity": "sha512-rORqq9c+7W0DAK3cleWNSyfv/qKXV99hV4tZe+gGLfBECw3XEhBy7x85F3wypA9688LKjtwO9pX9L33/xQI8yA==", "dev": true, "requires": { - "debug": "~2.6.6", - "engine.io": "~3.1.0", + "debug": "~3.1.0", + "engine.io": "~3.2.0", + "has-binary2": "~1.0.2", "socket.io-adapter": "~1.1.0", - "socket.io-client": "2.0.4", - "socket.io-parser": "~3.1.1" + "socket.io-client": "2.1.1", + "socket.io-parser": "~3.2.0" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } } }, "socket.io-adapter": { @@ -5781,38 +4295,61 @@ "dev": true }, "socket.io-client": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.0.4.tgz", - "integrity": "sha1-CRilUkBtxeVAs4Dc2Xr8SmQzL44=", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-2.1.1.tgz", + "integrity": "sha512-jxnFyhAuFxYfjqIgduQlhzqTcOEQSn+OHKVfAxWaNWa7ecP7xSNk2Dx/3UEsDcY7NcFafxvNvKPmmO7HTwTxGQ==", "dev": true, "requires": { "backo2": "1.0.2", "base64-arraybuffer": "0.1.5", "component-bind": "1.0.0", "component-emitter": "1.2.1", - "debug": "~2.6.4", - "engine.io-client": "~3.1.0", + "debug": "~3.1.0", + "engine.io-client": "~3.2.0", + "has-binary2": "~1.0.2", "has-cors": "1.1.0", "indexof": "0.0.1", "object-component": "0.0.3", "parseqs": "0.0.5", "parseuri": "0.0.5", - "socket.io-parser": "~3.1.1", + "socket.io-parser": "~3.2.0", "to-array": "0.1.4" + }, + "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + } } }, "socket.io-parser": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.1.3.tgz", - "integrity": "sha512-g0a2HPqLguqAczs3dMECuA1RgoGFPyvDqcbaDEdCWY9g59kdUAz3YRmaJBNKXflrHNwB7Q12Gkf/0CZXfdHR7g==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.2.0.tgz", + "integrity": "sha512-FYiBx7rc/KORMJlgsXysflWx/RIvtqZbyGLlHZvjfmPTPeuD/I8MaW7cfFrj5tRltICJdgwflhfZ3NVVbVLFQA==", "dev": true, "requires": { "component-emitter": "1.2.1", "debug": "~3.1.0", - "has-binary2": "~1.0.2", "isarray": "2.0.1" }, "dependencies": { + "component-emitter": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz", + "integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=", + "dev": true + }, "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", @@ -5830,26 +4367,6 @@ } } }, - "socks": { - "version": "1.1.10", - "resolved": "https://registry.npmjs.org/socks/-/socks-1.1.10.tgz", - "integrity": "sha1-W4t/x8jzQcU+0FbpKbe/Tei6e1o=", - "dev": true, - "requires": { - "ip": "^1.1.4", - "smart-buffer": "^1.0.13" - } - }, - "socks-proxy-agent": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-3.0.1.tgz", - "integrity": "sha512-ZwEDymm204mTzvdqyUqOdovVr2YRd2NYskrYrF2LXyZ9qDiMAoFESGK8CRphiO7rtbo2Y757k2Nia3x2hGtalA==", - "dev": true, - "requires": { - "agent-base": "^4.1.0", - "socks": "^1.1.10" - } - }, "source-map": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.4.4.tgz", @@ -5992,25 +4509,67 @@ "dev": true }, "streamroller": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-0.7.0.tgz", - "integrity": "sha512-WREzfy0r0zUqp3lGO096wRuUp7ho1X6uo/7DJfTlEi0Iv/4gT7YHqXDjKC2ioVGBZtE8QzsQD9nx1nIuoZ57jQ==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/streamroller/-/streamroller-1.0.4.tgz", + "integrity": "sha512-Wc2Gm5ygjSX8ZpW9J7Y9FwiSzTlKSvcl0FTTMd3rn7RoxDXpBW+xD9TY5sWL2n0UR61COB0LG1BQvN6nTUQbLQ==", "dev": true, "requires": { - "date-format": "^1.2.0", + "async": "^2.6.1", + "date-format": "^2.0.0", "debug": "^3.1.0", - "mkdirp": "^0.5.1", - "readable-stream": "^2.3.0" + "fs-extra": "^7.0.0", + "lodash": "^4.17.10" }, "dependencies": { - "debug": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz", + "integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==", "dev": true, "requires": { - "ms": "2.0.0" + "lodash": "^4.17.11" } + }, + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "fs-extra": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-7.0.1.tgz", + "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^4.0.0", + "universalify": "^0.1.0" + } + }, + "jsonfile": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true } } }, @@ -6023,23 +4582,6 @@ "safe-buffer": "~5.1.0" } }, - "stringstream": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.6.tgz", - "integrity": "sha512-87GEBAkegbBcweToUrdzf3eLhWNg06FJTebl4BVJz/JgWy8CvEr9dRtX5qWphiynMSQlxxi+QqN0z5T32SLlhA==", - "dev": true, - "optional": true - }, - "strip-ansi": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", - "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", - "dev": true, - "optional": true, - "requires": { - "ansi-regex": "^2.0.0" - } - }, "strip-bom": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-2.0.0.tgz", @@ -6059,11 +4601,40 @@ } }, "supports-color": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", "dev": true, - "optional": true + "requires": { + "has-flag": "^2.0.0" + }, + "dependencies": { + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + } + } + }, + "teeny-request": { + "version": "3.11.3", + "resolved": "https://registry.npmjs.org/teeny-request/-/teeny-request-3.11.3.tgz", + "integrity": "sha512-CKncqSF7sH6p4rzCgkb/z/Pcos5efl0DmolzvlqRQUNcpRIruOhY9+T1FsIlyEbfWd7MsFpodROOwHYh2BaXzw==", + "dev": true, + "requires": { + "https-proxy-agent": "^2.2.1", + "node-fetch": "^2.2.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "uuid": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", + "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", + "dev": true + } + } }, "throttleit": { "version": "1.0.0", @@ -6078,51 +4649,15 @@ "dev": true }, "through2": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.1.tgz", - "integrity": "sha1-OE51MU1J8y3hLuu4E2uOtrXVnak=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.0.tgz", + "integrity": "sha512-8B+sevlqP4OiCjonI1Zw03Sf8PuV1eRsYQgLad5eonILOdyeRsY27A/2Ze8IlvlMvq31OH+3fz/styI7Ya62yQ==", "dev": true, "requires": { - "readable-stream": "~2.0.0", - "xtend": "~4.0.0" - }, - "dependencies": { - "readable-stream": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.0.6.tgz", - "integrity": "sha1-j5A0HmilPMySh4jaz80Rs265t44=", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "~1.0.0", - "process-nextick-args": "~1.0.6", - "string_decoder": "~0.10.x", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - } + "readable-stream": "2 || 3", + "xtend": "~4.0.1" } }, - "thunkify": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/thunkify/-/thunkify-2.1.2.tgz", - "integrity": "sha1-+qDp0jDFGsyVyhOjYawFyn4EVT0=", - "dev": true, - "optional": true - }, - "timespan": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/timespan/-/timespan-2.3.0.tgz", - "integrity": "sha1-SQLOBAvRPYRcj1myfp1ZutbzmSk=", - "dev": true, - "optional": true - }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -6180,6 +4715,12 @@ "repeat-string": "^1.6.1" } }, + "toidentifier": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", + "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", + "dev": true + }, "tough-cookie": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", @@ -6195,13 +4736,6 @@ "integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=", "dev": true }, - "tsscmp": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/tsscmp/-/tsscmp-1.0.5.tgz", - "integrity": "sha1-fcSjOvcVgatDN9qR2FylQn69mpc=", - "dev": true, - "optional": true - }, "tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", @@ -6228,13 +4762,30 @@ } }, "type-is": { - "version": "1.6.16", - "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", "dev": true, "requires": { "media-typer": "0.3.0", - "mime-types": "~2.1.18" + "mime-types": "~2.1.24" + }, + "dependencies": { + "mime-db": { + "version": "1.40.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", + "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==", + "dev": true + }, + "mime-types": { + "version": "2.1.24", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", + "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", + "dev": true, + "requires": { + "mime-db": "1.40.0" + } + } } }, "typedarray": { @@ -6244,18 +4795,18 @@ "dev": true }, "typescript": { - "version": "2.9.1", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.1.tgz", - "integrity": "sha512-h6pM2f/GDchCFlldnriOhs1QHuwbnmj6/v7499eMHqPeW4V2G0elua2eIc2nu8v2NdHV0Gm+tzX83Hr6nUFjQA==", + "version": "3.4.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", + "integrity": "sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==", "dev": true }, "uglify-js": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.4.0.tgz", - "integrity": "sha512-Jcf5naPkX3rVPSQpRn9Vm6Rr572I1gTtR9LnqKgXjmOgfYQ/QS0V2WRStFR53Bdj520M66aCZqt9uzYXgtGrJQ==", + "version": "3.5.11", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.5.11.tgz", + "integrity": "sha512-izPJg8RsSyqxbdnqX36ExpbH3K7tDBsAU/VfNv89VkMFy3z39zFjunQGsSHOlGlyIfGLGprGeosgQno3bo2/Kg==", "dev": true, "requires": { - "commander": "~2.15.0", + "commander": "~2.20.0", "source-map": "~0.6.1" }, "dependencies": { @@ -6267,22 +4818,10 @@ } } }, - "uglify-to-browserify": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz", - "integrity": "sha1-bgkk1r2mta/jSeOabWMoUKD4grc=", - "dev": true, - "optional": true - }, "ultron": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", - "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==" - }, - "underscore": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", - "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", + "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", "dev": true }, "union-value": { @@ -6320,6 +4859,12 @@ } } }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, "unix-crypt-td-js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unix-crypt-td-js/-/unix-crypt-td-js-1.0.0.tgz", @@ -6373,9 +4918,9 @@ } }, "upath": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.0.tgz", - "integrity": "sha512-bzpH/oBhoS/QI/YtbkqCg6VEiPYjSZtrHQM6/QnJS6OL9pKUFLqb3aFh4Scvwm45+7iAgiMkLhSbaZxUqmrprw==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/upath/-/upath-1.1.2.tgz", + "integrity": "sha512-kXpym8nmDmlCBr7nKdIx8P2jNBa+pBpIUFRnKJ4dr8htyYGJFokkr2ZvERRtUN+9SY+JqXouNgUPtv6JQva/2Q==", "dev": true }, "urix": { @@ -6391,30 +4936,19 @@ "dev": true }, "use": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/use/-/use-3.1.0.tgz", - "integrity": "sha512-6UJEQM/L+mzC3ZJNM56Q4DFGLX/evKGRg15UJHGB9X5j5Z3AFbgZvjUh2yq/UJUY4U5dh7Fal++XbNg1uzpRAw==", - "dev": true, - "requires": { - "kind-of": "^6.0.2" - } + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", + "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", + "dev": true }, "useragent": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.2.1.tgz", - "integrity": "sha1-z1k+9PLRdYdei7ZY6pLhik/QbY4=", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/useragent/-/useragent-2.3.0.tgz", + "integrity": "sha512-4AoH4pxuSvHCjqLO04sU6U/uE65BYza8l/KKBS0b0hnUPWi+cQ2BpeTEwejCSx9SPV5/U03nniDTrWx5NrmKdw==", "dev": true, "requires": { - "lru-cache": "2.2.x", + "lru-cache": "4.1.x", "tmp": "0.0.x" - }, - "dependencies": { - "lru-cache": { - "version": "2.2.4", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.2.4.tgz", - "integrity": "sha1-bGWGGb7PFAMdDQtZSxYELOTcBj0=", - "dev": true - } } }, "util-deprecate": { @@ -6435,13 +4969,6 @@ "integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA==", "dev": true }, - "uws": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/uws/-/uws-9.14.0.tgz", - "integrity": "sha512-HNMztPP5A1sKuVFmdZ6BPVpBQd5bUjNC8EFMFiICK+oho/OQsAJy5hnIx4btMHiOk8j04f/DbIlqnEZ9d72dqg==", - "dev": true, - "optional": true - }, "validate-npm-package-license": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", @@ -6491,13 +5018,6 @@ "integrity": "sha512-nqHUnMXmBzT0w570r2JpJxfiSD1IzoI+HGVdd3aZ0yNi3ngvQ4jv1dtHt5VGxfI2yj5yqImPhOK4vmIh2xMbGg==", "dev": true }, - "when": { - "version": "3.7.8", - "resolved": "https://registry.npmjs.org/when/-/when-3.7.8.tgz", - "integrity": "sha1-xxMLan6gRpPoQs3J56Hyqjmjn4I=", - "dev": true, - "optional": true - }, "which": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", @@ -6507,20 +5027,6 @@ "isexe": "^2.0.0" } }, - "window-size": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/window-size/-/window-size-0.1.0.tgz", - "integrity": "sha1-VDjNLqk7IC76Ohn+iIeu58lPnJ0=", - "dev": true, - "optional": true - }, - "with-callback": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/with-callback/-/with-callback-1.0.2.tgz", - "integrity": "sha1-oJYpuakgAo1yFAT7Q1vc/1yRvCE=", - "dev": true, - "optional": true - }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", @@ -6534,13 +5040,11 @@ "dev": true }, "ws": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", - "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz", + "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==", "requires": { - "async-limiter": "~1.0.0", - "safe-buffer": "~5.1.0", - "ultron": "~1.1.0" + "async-limiter": "~1.0.0" } }, "xmlhttprequest": { @@ -6554,13 +5058,6 @@ "integrity": "sha1-wodrBhaKrcQOV9l+gRkayPQ5iz4=", "dev": true }, - "xregexp": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz", - "integrity": "sha1-UqY+VsoLhKfzpfPWGHLxJq16WUM=", - "dev": true, - "optional": true - }, "xtend": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", @@ -6571,30 +5068,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true, - "optional": true - }, - "yargs": { - "version": "3.10.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-3.10.0.tgz", - "integrity": "sha1-9+572FfdfB0tOMDnTvvWgdFDH9E=", - "dev": true, - "optional": true, - "requires": { - "camelcase": "^1.0.2", - "cliui": "^2.1.0", - "decamelize": "^1.0.0", - "window-size": "0.1.0" - }, - "dependencies": { - "camelcase": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz", - "integrity": "sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=", - "dev": true, - "optional": true - } - } + "dev": true }, "yauzl": { "version": "2.4.1", diff --git a/package.json b/package.json index beb0589..c770120 100644 --- a/package.json +++ b/package.json @@ -18,29 +18,29 @@ "author": "Michael Lemaire", "license": "MIT", "devDependencies": { - "@types/jasmine": "^2.8.8", + "@types/jasmine": "^3.3.12", "babel-polyfill": "6.26.0", - "codecov": "^3.0.2", + "codecov": "^3.3.0", "gamefroot-texture-packer": "github:Gamefroot/Gamefroot-Texture-Packer#f3687111afc94f80ea8f2877c188fb8e2004e8ff", - "glob": "^7.1.2", - "glob-watcher": "^5.0.1", - "jasmine": "^3.1.0", - "karma": "^2.0.2", + "glob": "^7.1.3", + "glob-watcher": "^5.0.3", + "jasmine": "^3.4.0", + "karma": "^4.1.0", "karma-coverage": "^1.1.2", - "karma-jasmine": "^1.1.2", + "karma-jasmine": "^2.0.1", "karma-phantomjs-launcher": "1.0.4", "karma-spec-reporter": "^0.0.32", - "live-server": "1.2.0", - "remap-istanbul": "^0.11.1", - "runjs": "^4.3.2", - "shelljs": "^0.8.2", - "typescript": "^2.9.1", - "uglify-js": "^3.4.0" + "live-server": "1.2.1", + "remap-istanbul": "^0.13.0", + "runjs": "^4.4.2", + "shelljs": "^0.8.3", + "typescript": "^3.4.5", + "uglify-js": "^3.5.11" }, "dependencies": { - "jasmine-core": "^3.1.0", - "parse": "^1.11.1", - "phaser": "^3.10.1", + "jasmine-core": "^3.4.0", + "parse": "^2.4.0", + "phaser": "^3.16.2", "process-pool": "^0.3.5" } } diff --git a/src/MainUI.ts b/src/MainUI.ts index f12e1b2..c9c9dff 100644 --- a/src/MainUI.ts +++ b/src/MainUI.ts @@ -41,15 +41,18 @@ module TK.SpaceTac { // Current scaling scaling = 1 - constructor(headless: boolean = false) { + constructor(private testmode = false) { super({ width: 1920, height: 1080, - type: headless ? Phaser.HEADLESS : Phaser.AUTO, + type: Phaser.AUTO, // cannot really use HEADLESS because of bugs backgroundColor: '#000000', parent: '-space-tac', disableContextMenu: true, - "render.autoResize": true, + scale: { + mode: Phaser.Scale.FIT, + autoCenter: Phaser.Scale.CENTER_BOTH + }, }); this.storage = localStorage; @@ -57,7 +60,7 @@ module TK.SpaceTac { this.session = new GameSession(); this.session_token = null; - if (!headless) { + if (!testmode) { this.events.on("blur", () => { this.scene.scenes.forEach(scene => this.scene.pause(scene)); }); @@ -74,34 +77,17 @@ module TK.SpaceTac { this.scene.add('creation', UI.FleetCreationView); this.scene.add('universe', UI.UniverseMapView); - this.resizeToFitWindow(); - window.addEventListener("resize", () => this.resizeToFitWindow()); - this.goToScene('boot'); } } - resize(width: number, height: number, scaling?: number) { - super.resize(width, height); - - this.scaling = scaling ? scaling : 1; - cfilter(this.scene.scenes, UI.BaseView).forEach(scene => scene.resize()); - } - - resizeToFitWindow() { - let width = window.innerWidth; - let height = window.innerHeight; - let scale = Math.min(width / 1920, height / 1080); - this.resize(1920 * scale, 1080 * scale, scale); - } - boot() { super.boot(); this.options = new UI.GameOptions(this); } - get headless(): boolean { - return this.config.renderType == Phaser.HEADLESS; + get isTesting(): boolean { + return this.testmode; } /** @@ -124,7 +110,7 @@ module TK.SpaceTac { if (active) { let scene = this.scene.getScene(active); return (scene instanceof UI.BaseView) ? scene : null; - } else if (this.headless) { + } else if (this.isTesting) { return this.scene.scenes[0]; } else { return null; @@ -237,9 +223,7 @@ module TK.SpaceTac { * Check if the game is currently fullscreen */ isFullscreen(): boolean { - // FIXME - return false; - //return this.scale.isFullScreen; + return this.scale.isFullscreen; } /** @@ -248,15 +232,13 @@ module TK.SpaceTac { * Returns true if the result is fullscreen */ toggleFullscreen(active: boolean | null = null): boolean { - // FIXME - /*if (active === false || (active !== true && this.isFullscreen())) { - this.scale.stopFullScreen(); + if (active === false || (active !== true && this.isFullscreen())) { + this.scale.stopFullscreen(); return false; } else { - this.scale.startFullScreen(true); + this.scale.startFullscreen(); return true; - }*/ - return false; + } } } } diff --git a/src/common b/src/common deleted file mode 160000 index 1425cb0..0000000 --- a/src/common +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1425cb08935dd996a4c7a644ab793ff3b8355c9b diff --git a/src/common/DiffLog.spec.ts b/src/common/DiffLog.spec.ts new file mode 100644 index 0000000..5e0d38a --- /dev/null +++ b/src/common/DiffLog.spec.ts @@ -0,0 +1,232 @@ +/// + +module TK.Specs { + class TestState { + counter = 0 + } + + class TestDiff extends Diff { + private value: number + constructor(value = 1) { + super(); + this.value = value; + } + apply(state: TestState) { + state.counter += this.value; + } + getReverse() { + return new TestDiff(-this.value); + } + } + + testing("DiffLog", test => { + test.case("stores sequential events", check => { + let log = new DiffLog(); + check.equals(log.count(), 0); + check.equals(log.get(0), null); + check.equals(log.get(1), null); + check.equals(log.get(2), null); + + log.add(new TestDiff(2)); + check.equals(log.count(), 1); + check.equals(log.get(0), new TestDiff(2)); + check.equals(log.get(1), null); + check.equals(log.get(2), null); + + log.add(new TestDiff(-4)); + check.equals(log.count(), 2); + check.equals(log.get(0), new TestDiff(2)); + check.equals(log.get(1), new TestDiff(-4)); + check.equals(log.get(2), null); + + log.clear(1); + check.equals(log.count(), 1); + check.equals(log.get(0), new TestDiff(2)); + + log.clear(); + check.equals(log.count(), 0); + }) + }) + + testing("DiffLogClient", test => { + test.case("adds diffs to the log", check => { + let log = new DiffLog(); + let state = new TestState(); + let client = new DiffLogClient(state, log); + + check.equals(client.atEnd(), true, "client is empty, should be at end"); + check.equals(log.count(), 0, "log is empty initially"); + check.equals(state.counter, 0, "initial state is 0"); + + client.add(new TestDiff(3)); + check.equals(client.atEnd(), true, "client still at end"); + check.equals(log.count(), 1, "diff added to log"); + check.equals(state.counter, 3, "diff applied to state"); + + client.add(new TestDiff(2), false); + check.equals(client.atEnd(), false, "client lapsing behind"); + check.equals(log.count(), 2, "diff added to log"); + check.equals(state.counter, 3, "diff not applied to state"); + }) + + test.case("initializes at current state (end of log)", check => { + let state = new TestState(); + let log = new DiffLog(); + log.add(new TestDiff(7)); + let client = new DiffLogClient(state, log); + check.equals(client.atStart(), false); + check.equals(client.atEnd(), true); + check.equals(state.counter, 0); + client.forward(); + check.equals(state.counter, 0); + client.backward(); + check.equals(state.counter, -7); + }) + + test.case("moves forward or backward in the log", check => { + let log = new DiffLog(); + let state = new TestState(); + let client = new DiffLogClient(state, log); + + log.add(new TestDiff(7)); + log.add(new TestDiff(-2)); + log.add(new TestDiff(4)); + + check.equals(state.counter, 0, "initial state is 0"); + check.equals(client.atStart(), true, "client is at start"); + check.equals(client.atEnd(), false, "client is not at end"); + + client.forward(); + check.equals(state.counter, 7, "0+7 => 7"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), false, "client is not at end"); + + client.forward(); + check.equals(state.counter, 5, "7-2 => 5"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), false, "client is not at end"); + + client.forward(); + check.equals(state.counter, 9, "5+4 => 9"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), true, "client is at end"); + + client.forward(); + check.equals(state.counter, 9, "at end, still 9"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), true, "client is at end"); + + client.backward(); + check.equals(state.counter, 5, "9-4=>5"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), false, "client is not at end"); + + client.backward(); + check.equals(state.counter, 7, "5+2=>7"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), false, "client is not at end"); + + client.backward(); + check.equals(state.counter, 0, "7-7=>0"); + check.equals(client.atStart(), true, "client is back at start"); + check.equals(client.atEnd(), false, "client is not at end"); + + client.backward(); + check.equals(state.counter, 0, "at start, still 0"); + check.equals(client.atStart(), true, "client is at start"); + check.equals(client.atEnd(), false, "client is not at end"); + }) + + test.case("jumps to start or end of the log", check => { + let log = new DiffLog(); + let state = new TestState(); + let client = new DiffLogClient(state, log); + + client.add(new TestDiff(7)); + log.add(new TestDiff(-2)); + log.add(new TestDiff(4)); + + check.equals(state.counter, 7, "initial state is 7"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), false, "client is not at end"); + + client.jumpToEnd(); + check.equals(state.counter, 9, "7-2+4=>9"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), true, "client at end"); + + client.jumpToEnd(); + check.equals(state.counter, 9, "still 9"); + check.equals(client.atStart(), false, "client is not at start"); + check.equals(client.atEnd(), true, "client at end"); + + client.jumpToStart(); + check.equals(state.counter, 0, "9-4+2-7=>0"); + check.equals(client.atStart(), true, "client is at start"); + check.equals(client.atEnd(), false, "client at not end"); + + client.jumpToStart(); + check.equals(state.counter, 0, "still 0"); + check.equals(client.atStart(), true, "client is at start"); + check.equals(client.atEnd(), false, "client at not end"); + }) + + test.case("truncate the log", check => { + let log = new DiffLog(); + let state = new TestState(); + let client = new DiffLogClient(state, log); + + client.add(new TestDiff(7)); + client.add(new TestDiff(3)); + client.add(new TestDiff(5)); + + check.in("initial state", check => { + check.equals(state.counter, 15, "state=15"); + check.equals(log.count(), 3, "count=3"); + }); + + client.backward(); + + check.in("after backward", check => { + check.equals(state.counter, 10, "state=10"); + check.equals(log.count(), 3, "count=3"); + }); + + client.truncate(); + + check.in("after truncate", check => { + check.equals(state.counter, 10, "state=10"); + check.equals(log.count(), 2, "count=2"); + }); + + client.truncate(); + + check.in("after another truncate", check => { + check.equals(state.counter, 10, "state=10"); + check.equals(log.count(), 2, "count=2"); + }); + }) + + test.acase("plays the log continuously", async check => { + let log = new DiffLog(); + let state = new TestState(); + let client = new DiffLogClient(state, log); + + let inter: number[] = []; + let promise = client.play(diff => { + inter.push((diff).value); + return Promise.resolve(); + }); + + log.add(new TestDiff(5)); + log.add(new TestDiff(-1)); + log.add(new TestDiff(2)); + client.stop(false); + + await promise; + + check.equals(state.counter, 6); + check.equals(inter, [5, -1, 2]); + }) + }) +} \ No newline at end of file diff --git a/src/common/DiffLog.ts b/src/common/DiffLog.ts new file mode 100644 index 0000000..f5c06d3 --- /dev/null +++ b/src/common/DiffLog.ts @@ -0,0 +1,249 @@ +/** + * Framework to maintain a state from a log of changes + * + * This allows for repeatable, serializable and revertable state modifications. + */ +module TK { + /** + * Base class for a single diff. + * + * This represents an atomic change of the state, that can be applied, or reverted. + */ + export class Diff { + /** + * Apply the diff on a given state + * + * By default it does nothing + */ + apply(state: T): void { + } + + /** + * Reverts the diff from a given state + * + * By default it applies the reverse event + */ + revert(state: T): void { + this.getReverse().apply(state); + } + + /** + * Get the reverse event + * + * By default it returns a stub event that does nothing + */ + protected getReverse(): Diff { + return new Diff(); + } + } + + /** + * Collection of sequential diffs + */ + export class DiffLog { + private diffs: Diff[] = [] + + /** + * Add a single diff at the end of the log + */ + add(diff: Diff): void { + this.diffs.push(diff); + } + + /** + * Get the diff at a specific index + */ + get(idx: number): Diff | null { + return this.diffs[idx] || null; + } + + /** + * Return the total count of diffs + */ + count(): number { + return this.diffs.length; + } + + /** + * Clean all stored diffs, starting at a given index + * + * The caller should be sure that no log client is beyond the cut index. + */ + clear(start = 0): void { + this.diffs = this.diffs.slice(0, start); + } + } + + /** + * Client for a DiffLog, able to go forward or backward in the log, applying diffs as needed + */ + export class DiffLogClient { + private state: T + private log: DiffLog + private cursor = -1 + private playing = false + private stopping = false + private paused = false + private timer = Timer.global + + constructor(state: T, log: DiffLog) { + this.state = state; + this.log = log; + this.cursor = log.count() - 1; + } + + /** + * Returns true if the log is currently playing + */ + isPlaying(): boolean { + return this.playing && !this.paused && !this.stopping; + } + + /** + * Get the current diff pointed at + */ + getCurrent(): Diff | null { + return this.log.get(this.cursor); + } + + /** + * Push a diff to the underlying log, applying it immediately if required + */ + add(diff: Diff, apply = true): void { + this.log.add(diff); + if (apply) { + this.jumpToEnd(); + } + } + + /** + * Apply the underlying log continuously, until *stop* is called + * + * If *after_apply* is provided, it will be called after each diff is applied, and waited upon before resuming + */ + async play(after_apply?: (diff: Diff) => Promise): Promise { + if (this.playing) { + console.error("DiffLogClient already playing", this); + return; + } + + this.playing = true; + this.stopping = false; + + while (this.playing) { + if (!this.paused) { + let diff = this.forward(); + if (diff && after_apply) { + await after_apply(diff); + } + } + + if (this.atEnd()) { + if (this.stopping) { + break; + } else { + await this.timer.sleep(50); + } + } + } + } + + /** + * Stop the previous *play* + */ + stop(immediate = true): void { + if (!this.playing) { + console.error("DiffLogClient not playing", this); + return; + } + + if (immediate) { + this.playing = false; + } + this.stopping = true; + } + + /** + * Make a step backward in time (revert one diff) + */ + backward(): Diff | null { + if (!this.atStart()) { + this.cursor -= 1; + this.paused = true; + + let diff = this.log.get(this.cursor + 1); + if (diff) { + diff.revert(this.state); + } + return diff; + } else { + return null; + } + } + + /** + * Make a step forward in time (apply one diff) + */ + forward(): Diff | null { + if (!this.atEnd()) { + this.cursor += 1; + if (this.atEnd()) { + this.paused = false; + } + + let diff = this.log.get(this.cursor); + if (diff) { + diff.apply(this.state); + } + return diff; + } else { + return null; + } + } + + /** + * Jump to the start of the log + * + * This will rewind all applied event + */ + jumpToStart() { + while (!this.atStart()) { + this.backward(); + } + } + + /** + * Jump to the end of the log + * + * This will apply all remaining event + */ + jumpToEnd() { + while (!this.atEnd()) { + this.forward(); + } + } + + /** + * Check if we are currently at the start of the log + */ + atStart(): boolean { + return this.cursor < 0; + } + + /** + * Check if we are currently at the end of the log + */ + atEnd(): boolean { + return this.cursor >= this.log.count() - 1; + } + + /** + * Truncate all diffs after the current position + * + * This is useful when using the log to "undo" something + */ + truncate(): void { + this.log.clear(this.cursor + 1); + } + } +} diff --git a/src/common/Iterators.spec.ts b/src/common/Iterators.spec.ts new file mode 100644 index 0000000..20e7a31 --- /dev/null +++ b/src/common/Iterators.spec.ts @@ -0,0 +1,207 @@ +module TK { + testing("Iterators", test => { + function checkit(base_iterator: Iterator, ...values: (T | null)[]) { + let iterator = base_iterator; + values.forEach(value => { + let [head, tail] = iterator(); + test.check.equals(head, value); + iterator = tail; + }); + + // second iteration to check for repeatability + iterator = base_iterator; + values.forEach(value => { + let [head, tail] = iterator(); + test.check.equals(head, value); + iterator = tail; + }); + } + + function checkarray(iterator: Iterator, values: T[]) { + test.check.equals(imaterialize(iterator), values); + + // second iteration to check for repeatability + test.check.equals(imaterialize(iterator), values); + } + + test.case("calls a function for each yielded value", check => { + let iterator = iarray([1, 2, 3]); + let result: number[] = []; + iforeach(iterator, bound(result, "push")); + check.equals(result, [1, 2, 3]); + + result = []; + iforeach(iterator, i => { + result.push(i); + if (i == 2) { + return null; + } else { + return undefined; + } + }); + check.equals(result, [1, 2]); + + result = []; + iforeach(iterator, i => { + result.push(i); + return i; + }, 2); + check.equals(result, [1, 2]); + }); + + test.case("creates an iterator from an array", check => { + checkit(iarray([]), null, null, null); + checkit(iarray([1, 2, 3]), 1, 2, 3, null, null, null); + }); + + test.case("creates an iterator from a single value", check => { + checkarray(isingle(1), [1]); + checkarray(isingle("a"), ["a"]); + }); + + test.case("finds the first item passing a predicate", check => { + check.equals(ifirst(iarray([]), i => i % 2 == 0), null); + check.equals(ifirst(iarray([1, 2, 3]), i => i % 2 == 0), 2); + check.equals(ifirst(iarray([1, 3, 5]), i => i % 2 == 0), null); + }); + + test.case("finds the first item mapping to a value", check => { + let predicate = (i: number) => i % 2 == 0 ? (i * 4).toString() : null + check.equals(ifirstmap(iarray([]), predicate), null); + check.equals(ifirstmap(iarray([1, 2, 3]), predicate), "8"); + check.equals(ifirstmap(iarray([1, 3, 5]), predicate), null); + }); + + test.case("materializes an array from an iterator", check => { + check.equals(imaterialize(iarray([1, 2, 3])), [1, 2, 3]); + + check.throw(() => imaterialize(iarray([1, 2, 3, 4, 5]), 2), "Length limit on iterator materialize"); + }); + + test.case("creates an iterator in a range of integers", check => { + checkarray(irange(4), [0, 1, 2, 3]); + checkarray(irange(4, 1), [1, 2, 3, 4]); + checkarray(irange(5, 3, 2), [3, 5, 7, 9, 11]); + checkit(irange(), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); + }); + + test.case("uses a step iterator to scan numbers", check => { + checkit(istep(), 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); + checkit(istep(3), 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); + checkarray(istep(3, irepeat(1, 4)), [3, 4, 5, 6, 7]); + checkarray(istep(8, IEMPTY), [8]); + checkit(istep(1, irange()), 1, 1, 2, 4, 7, 11, 16); + }); + + test.case("skips a number of values", check => { + checkarray(iskip(irange(7), 3), [3, 4, 5, 6]); + checkarray(iskip(irange(7), 12), []); + checkarray(iskip(IEMPTY, 3), []); + }); + + test.case("gets a value at an iterator position", check => { + check.equals(iat(irange(), -1), null); + check.equals(iat(irange(), 0), 0); + check.equals(iat(irange(), 8), 8); + check.equals(iat(irange(5), 8), null); + check.equals(iat(IEMPTY, 0), null); + }); + + test.case("chains iterators", check => { + checkarray(ichain(), []); + checkarray(ichain(irange(3)), [0, 1, 2]); + checkarray(ichain(iarray([1, 2]), iarray([]), iarray([3, 4, 5])), [1, 2, 3, 4, 5]); + }); + + test.case("chains iterator of iterators", check => { + checkarray(ichainit(IEMPTY), []); + checkarray(ichainit(iarray([iarray([1, 2, 3]), iarray([]), iarray([4, 5])])), [1, 2, 3, 4, 5]); + }); + + test.case("repeats a value", check => { + checkit(irepeat("a"), "a", "a", "a", "a"); + checkarray(irepeat("a", 3), ["a", "a", "a"]); + }); + + test.case("loops an iterator", check => { + checkarray(iloop(irange(3), 2), [0, 1, 2, 0, 1, 2]); + checkit(iloop(irange(1)), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + let onloop = check.mockfunc("onloop"); + let iterator = iloop(irange(2), 3, onloop.func); + function next() { + let value; + [value, iterator] = iterator(); + return value; + } + check.equals(next(), 0); + check.called(onloop, 0); + check.equals(next(), 1); + check.called(onloop, 0); + check.equals(next(), 0); + check.called(onloop, 1); + check.equals(next(), 1); + check.called(onloop, 0); + check.equals(next(), 0); + check.called(onloop, 1); + check.equals(next(), 1); + check.called(onloop, 0); + check.equals(next(), null); + check.called(onloop, 0); + }); + + test.case("maps an iterator", check => { + checkarray(imap(IEMPTY, i => i * 2), []); + checkarray(imap(irange(3), i => i * 2), [0, 2, 4]); + }); + + test.case("filters an iterator", check => { + checkarray(imap(IEMPTY, i => i % 3 == 0), []); + checkarray(ifilter(irange(12), i => i % 3 == 0), [0, 3, 6, 9]); + }); + + test.case("combines iterators", check => { + let iterator = icombine(iarray([1, 2, 3]), iarray(["a", "b"])); + checkarray(iterator, [[1, "a"], [1, "b"], [2, "a"], [2, "b"], [3, "a"], [3, "b"]]); + }); + + test.case("zips iterators", check => { + checkarray(izip(IEMPTY, IEMPTY), []); + checkarray(izip(iarray([1, 2, 3]), iarray(["a", "b"])), [[1, "a"], [2, "b"]]); + + checkarray(izipg(IEMPTY, IEMPTY), []); + checkarray(izipg(iarray([1, 2, 3]), iarray(["a", "b"])), <[number | null, string | null][]>[[1, "a"], [2, "b"], [3, null]]); + }); + + test.case("partitions iterators", check => { + let [it1, it2] = ipartition(IEMPTY, () => true); + checkarray(it1, []); + checkarray(it2, []); + + [it1, it2] = ipartition(irange(5), i => i % 2 == 0); + checkarray(it1, [0, 2, 4]); + checkarray(it2, [1, 3]); + }); + + test.case("returns unique items", check => { + checkarray(iunique(IEMPTY), []); + checkarray(iunique(iarray([5, 3, 2, 3, 4, 5])), [5, 3, 2, 4]); + checkarray(iunique(iarray([5, 3, 2, 3, 4, 5]), 4), [5, 3, 2, 4]); + check.throw(() => imaterialize(iunique(iarray([5, 3, 2, 3, 4, 5]), 3)), "Unique count limit on iterator"); + }); + + test.case("uses ireduce for some common functions", check => { + check.equals(isum(IEMPTY), 0); + check.equals(isum(irange(4)), 6); + + check.equals(icat(IEMPTY), ""); + check.equals(icat(iarray(["a", "bc", "d"])), "abcd"); + + check.equals(imin(IEMPTY), Infinity); + check.equals(imin(iarray([3, 8, 2, 4])), 2); + + check.equals(imax(IEMPTY), -Infinity); + check.equals(imax(iarray([3, 8, 2, 4])), 8); + }); + }); +} \ No newline at end of file diff --git a/src/common/Iterators.ts b/src/common/Iterators.ts new file mode 100644 index 0000000..fb81ca4 --- /dev/null +++ b/src/common/Iterators.ts @@ -0,0 +1,363 @@ +/** + * Lazy iterators to work on dynamic data sets without materializing them. + * + * They allow to work on infinite streams of values, with limited memory consumption. + * + * Functions in this file that do not return an Iterator are "materializing", meaning that they + * may consume iterators up to the end, and will not work well on infinite iterators. + */ +module TK { + /** + * An iterator is a function without side effect, that returns the current value + * and an iterator over the next values. + */ + export type Iterator = () => [T | null, Iterator]; + + function _getIEND(): [null, Iterator] { + return [null, _getIEND]; + } + + /** + * IEND is a return value for iterators, indicating end of iteration. + */ + export const IEND: [null, Iterator] = [null, _getIEND]; + + /** + * Empty iterator, returning IEND + */ + export const IEMPTY = () => IEND; + + /** + * Equivalent of Array.forEach for lazy iterators. + * + * If the callback returns *stopper*, the iteration is stopped. + */ + export function iforeach(iterator: Iterator, callback: (_: T) => any, stopper: any = null) { + let value: T | null; + [value, iterator] = iterator(); + while (value !== null) { + let returned = callback(value); + if (returned === stopper) { + return; + } + [value, iterator] = iterator(); + } + } + + /** + * Get an iterator on an array + * + * The iterator will yield the next value each time it is called, then null when the array's end is reached. + */ + export function iarray(array: T[], offset = 0): Iterator { + return () => { + if (offset < array.length) { + return [array[offset], iarray(array, offset + 1)]; + } else { + return IEND; + } + } + } + + /** + * Get an iterator yielding a single value + */ + export function isingle(value: T): Iterator { + return iarray([value]); + } + + /** + * Returns the first item passing a predicate + */ + export function ifirst(iterator: Iterator, predicate: (item: T) => boolean): T | null { + let result: T | null = null; + iforeach(iterator, item => { + if (predicate(item)) { + result = item; + return null; + } else { + return undefined; + } + }); + return result; + } + + /** + * Returns the first non-null result of a value-yielding predicate, applied to each iterator element + */ + export function ifirstmap(iterator: Iterator, predicate: (item: T1) => T2 | null): T2 | null { + let result: T2 | null = null; + iforeach(iterator, item => { + let mapped = predicate(item); + if (mapped) { + result = mapped; + return null; + } else { + return undefined; + } + }); + return result; + } + + /** + * Materialize an array from consuming an iterator + * + * To avoid materializing infinite iterators (and bursting memory), the item count is limited to 1 million, and an + * exception is thrown when this limit is reached. + */ + export function imaterialize(iterator: Iterator, limit = 1000000): T[] { + let result: T[] = []; + iforeach(iterator, value => { + result.push(value); + if (result.length >= limit) { + throw new Error("Length limit on iterator materialize"); + } + }); + return result; + } + + /** + * Iterate over natural integers + * + * If *count* is not specified, the iterator is infinite + */ + export function irange(count: number = -1, start = 0, step = 1): Iterator { + return () => (count != 0) ? [start, irange(count - 1, start + step, step)] : IEND; + } + + /** + * Iterate over numbers, by applying a step taken from an other iterator + * + * This iterator stops when the "step iterator" stops + * + * With no argument, istep() == irange() + */ + export function istep(start = 0, step = irepeat(1)): Iterator { + return () => { + let [value, iterator] = step(); + return [start, value === null ? IEMPTY : istep(start + value, iterator)]; + } + } + + /** + * Skip a given number of values from an iterator, discarding them. + */ + export function iskip(iterator: Iterator, count = 1): Iterator { + let value: T | null; + while (count--) { + [value, iterator] = iterator(); + } + return iterator; + } + + /** + * Return the value at a given position in the iterator + */ + export function iat(iterator: Iterator, position: number): T | null { + if (position < 0) { + return null; + } else { + if (position > 0) { + iterator = iskip(iterator, position); + } + return iterator()[0]; + } + } + + /** + * Chain an iterator of iterators. + * + * This will yield values from the first yielded iterator, then the second one, and so on... + */ + export function ichainit(iterators: Iterator>): Iterator { + return function () { + let [iterators_head, iterators_tail] = iterators(); + if (iterators_head == null) { + return IEND; + } else { + let [head, tail] = iterators_head(); + while (head == null) { + [iterators_head, iterators_tail] = iterators_tail(); + if (iterators_head == null) { + break; + } + [head, tail] = iterators_head(); + } + return [head, ichain(tail, ichainit(iterators_tail))]; + } + } + } + + /** + * Chain iterators. + * + * This will yield values from the first iterator, then the second one, and so on... + */ + export function ichain(...iterators: Iterator[]): Iterator { + if (iterators.length == 0) { + return IEMPTY; + } else { + return ichainit(iarray(iterators)); + } + } + + /** + * Wrap an iterator, calling *onstart* when the first value of the wrapped iterator is yielded. + */ + function ionstart(iterator: Iterator, onstart: Function): Iterator { + return () => { + let [head, tail] = iterator(); + if (head !== null) { + onstart(); + } + return [head, tail]; + } + } + + /** + * Iterator that repeats the same value. + */ + export function irepeat(value: T, count = -1): Iterator { + return iloop(iarray([value]), count); + } + + /** + * Loop an iterator for a number of times. + * + * If count is negative, if will loop forever (infinite iterator). + * + * onloop may be used to know when the iterator resets. + */ + export function iloop(base: Iterator, count = -1, onloop?: Function): Iterator { + if (count == 0) { + return IEMPTY; + } else { + let next = onloop ? ionstart(base, onloop) : base; + return ichainit(() => [base, iarray([iloop(next, count - 1)])]); + } + } + + /** + * Iterator version of "map". + */ + export function imap(iterator: Iterator, mapfunc: (_: T1) => T2): Iterator { + return () => { + let [head, tail] = iterator(); + if (head === null) { + return IEND; + } else { + return [mapfunc(head), imap(tail, mapfunc)]; + } + } + } + + /** + * Iterator version of "reduce". + */ + export function ireduce(iterator: Iterator, reduce: (item1: T, item2: T) => T, init: T): T { + let result = init; + iforeach(iterator, item => { + result = reduce(result, item); + }); + return result; + } + + /** + * Iterator version of "filter". + */ + export function ifilter(iterator: Iterator, filterfunc: (_: T) => boolean): Iterator { + return () => { + let [value, iter] = iterator(); + while (value !== null && !filterfunc(value)) { + [value, iter] = iter(); + } + return [value, ifilter(iter, filterfunc)]; + } + } + + /** + * Combine two iterators. + * + * This iterates through the second one several times, so if one iterator may be infinite, + * it should be the first one. + */ + export function icombine(it1: Iterator, it2: Iterator): Iterator<[T1, T2]> { + return ichainit(imap(it1, v1 => imap(it2, (v2): [T1, T2] => [v1, v2]))); + } + + /** + * Advance two iterators at the same time, yielding item pairs + * + * Iteration will stop at the first of the two iterators that stops. + */ + export function izip(it1: Iterator, it2: Iterator): Iterator<[T1, T2]> { + return () => { + let [val1, nit1] = it1(); + let [val2, nit2] = it2(); + if (val1 !== null && val2 !== null) { + return [[val1, val2], izip(nit1, nit2)]; + } else { + return IEND; + } + } + } + + /** + * Advance two iterators at the same time, yielding item pairs (greedy version) + * + * Iteration will stop when both iterators are consumed, returning partial couples (null in the peer) if needed. + */ + export function izipg(it1: Iterator, it2: Iterator): Iterator<[T1 | null, T2 | null]> { + return () => { + let [val1, nit1] = it1(); + let [val2, nit2] = it2(); + if (val1 === null && val2 === null) { + return IEND; + } else { + return [[val1, val2], izipg(nit1, nit2)]; + } + } + } + + /** + * Partition in two iterators, one with values that pass the predicate, the other with values that don't + */ + export function ipartition(it: Iterator, predicate: (item: T) => boolean): [Iterator, Iterator] { + return [ifilter(it, predicate), ifilter(it, x => !predicate(x))]; + } + + /** + * Yield items from an iterator only once. + * + * Beware that even if this function is not materializing, it keeps track of yielded item, and may choke on + * infinite or very long streams. Thus, no more than *limit* items will be yielded (an error is thrown + * when this limit is reached). + * + * This function is O(n²) + */ + export function iunique(it: Iterator, limit = 1000000): Iterator { + function internal(it: Iterator, limit: number, done: T[]): Iterator { + let [value, iterator] = it(); + while (value !== null && contains(done, value)) { + [value, iterator] = iterator(); + } + if (value === null) { + return IEMPTY; + } else if (limit <= 0) { + throw new Error("Unique count limit on iterator"); + } else { + let head = value; + return () => [head, internal(it, limit - 1, done.concat([head]))]; + } + } + return internal(it, limit, []); + } + + /** + * Common reduce shortcuts + */ + export const isum = (iterator: Iterator) => ireduce(iterator, (a, b) => a + b, 0); + export const icat = (iterator: Iterator) => ireduce(iterator, (a, b) => a + b, ""); + export const imin = (iterator: Iterator) => ireduce(iterator, Math.min, Infinity); + export const imax = (iterator: Iterator) => ireduce(iterator, Math.max, -Infinity); +} diff --git a/src/common/README.md b/src/common/README.md new file mode 100644 index 0000000..5ba1bc7 --- /dev/null +++ b/src/common/README.md @@ -0,0 +1,3 @@ +# tscommon + +Typescript tools shared between projects diff --git a/src/common/RObject.spec.ts b/src/common/RObject.spec.ts new file mode 100644 index 0000000..6e03243 --- /dev/null +++ b/src/common/RObject.spec.ts @@ -0,0 +1,127 @@ +/// + +module TK.Specs { + export class TestRObject extends RObject { + x: number + constructor(x = RandomGenerator.global.random()) { + super(); + this.x = x; + } + }; + + testing("RObject", test => { + test.setup(function () { + (RObject)._next_id = 0; + }) + + test.case("gets a sequential id", check => { + let o1 = new TestRObject(); + check.equals(o1.id, 0); + let o2 = new TestRObject(); + let o3 = new TestRObject(); + check.equals(o2.id, 1); + check.equals(o3.id, 2); + + check.equals(rid(o3), 2); + check.equals(rid(o3.id), 2); + }) + + test.case("checks object identity", check => { + let o1 = new TestRObject(1); + let o2 = new TestRObject(1); + let o3 = duplicate(o1, TK.Specs); + + check.equals(o1.is(o1), true, "o1 is o1"); + check.equals(o1.is(o2), false, "o1 is not o2"); + check.equals(o1.is(o3), true, "o1 is o3"); + check.equals(o1.is(null), false, "o1 is not null"); + + check.equals(o2.is(o1), false, "o2 is not o1"); + check.equals(o2.is(o2), true, "o2 is o2"); + check.equals(o2.is(o3), false, "o2 is not o3"); + check.equals(o2.is(null), false, "o2 is not null"); + + check.equals(o3.is(o1), true, "o3 is o1"); + check.equals(o3.is(o2), false, "o3 is not o2"); + check.equals(o3.is(o3), true, "o3 is o3"); + check.equals(o3.is(null), false, "o3 is not null"); + }) + + test.case("resets global id on unserialize", check => { + let o1 = new TestRObject(); + check.equals(o1.id, 0); + let o2 = new TestRObject(); + check.equals(o2.id, 1); + + let serializer = new Serializer(TK.Specs); + let packed = serializer.serialize({ objs: [o1, o2] }); + + (RObject)._next_id = 0; + + check.equals(new TestRObject().id, 0); + let unpacked = serializer.unserialize(packed); + check.equals(unpacked, { objs: [o1, o2] }); + check.equals(new TestRObject().id, 2); + serializer.unserialize(packed); + check.equals(new TestRObject().id, 3); + }) + }) + + testing("RObjectContainer", test => { + test.case("stored objects and get them by their id", check => { + let o1 = new TestRObject(); + let store = new RObjectContainer([o1]); + + let o2 = new TestRObject(); + check.same(store.get(o1.id), o1); + check.equals(store.get(o2.id), null); + + store.add(o2); + check.same(store.get(o1.id), o1); + check.same(store.get(o2.id), o2); + }) + + test.case("lists contained objects", check => { + let store = new RObjectContainer(); + let o1 = store.add(new TestRObject()); + let o2 = store.add(new TestRObject()); + + check.equals(store.count(), 2, "count=2"); + + let objects = store.list(); + check.equals(objects.length, 2, "list length=2"); + check.contains(objects, o1, "list contains o1"); + check.contains(objects, o2, "list contains o2"); + + objects = imaterialize(store.iterator()); + check.equals(objects.length, 2, "list length=2"); + check.contains(objects, o1, "list contains o1"); + check.contains(objects, o2, "list contains o2"); + + let ids = store.ids(); + check.equals(ids.length, 2, "ids length=2"); + check.contains(ids, o1.id, "list contains o1.id"); + check.contains(ids, o2.id, "list contains o2.id"); + }) + + test.case("removes objects", check => { + let store = new RObjectContainer(); + let o1 = store.add(new TestRObject()); + let o2 = store.add(new TestRObject()); + + check.in("initial", check => { + check.equals(store.count(), 2, "count=2"); + check.same(store.get(o1.id), o1, "o1 present"); + check.same(store.get(o2.id), o2, "o2 present"); + }); + + store.remove(o1); + + check.in("removed o1", check => { + check.equals(store.count(), 1, "count=1"); + check.same(store.get(o1.id), null, "o1 missing"); + check.same(store.get(o2.id), o2, "o2 present"); + }); + }) + }) +} \ No newline at end of file diff --git a/src/common/RObject.ts b/src/common/RObject.ts new file mode 100644 index 0000000..049b2dd --- /dev/null +++ b/src/common/RObject.ts @@ -0,0 +1,100 @@ +module TK { + export type RObjectId = number + + /** + * Returns the id of an object + */ + export function rid(obj: RObject | RObjectId): number { + return (obj instanceof RObject) ? obj.id : obj; + } + + /** + * Referenced objects, with unique ID. + * + * Objects extending this class will have an automatic unique ID, and may be tracked from an RObjectContainer. + */ + export class RObject { + readonly id: RObjectId = RObject._next_id++ + private static _next_id = 0 + + postUnserialize() { + if (this.id >= RObject._next_id) { + RObject._next_id = this.id + 1; + } + } + + /** + * Check that two objects are the same (only by comparing their ID) + */ + is(other: RObject | RObjectId | null): boolean { + if (other === null) { + return false; + } else if (other instanceof RObject) { + return this.id === other.id; + } else { + return this.id === other; + } + } + } + + /** + * Container to track referenced objects + */ + export class RObjectContainer { + private objects: { [index: number]: T } = {} + + constructor(objects: T[] = []) { + objects.forEach(obj => this.add(obj)); + } + + /** + * Add an object to the container + */ + add(object: T): T { + this.objects[object.id] = object; + return object; + } + + /** + * Remove an object from the container + */ + remove(object: T): void { + delete this.objects[object.id]; + } + + /** + * Get an object from the container by its id + */ + get(id: RObjectId): T | null { + return this.objects[id] || null; + } + + /** + * Count the number of objects + */ + count(): number { + return this.list().length; + } + + /** + * Get all contained ids (list) + */ + ids(): RObjectId[] { + return this.list().map(obj => obj.id); + } + + /** + * Get all contained objects (list) + */ + list(): T[] { + return values(this.objects); + } + + /** + * Get all contained objects (iterator) + */ + iterator(): Iterator { + return iarray(this.list()); + } + } +} diff --git a/src/common/RandomGenerator.spec.ts b/src/common/RandomGenerator.spec.ts new file mode 100644 index 0000000..c55edf3 --- /dev/null +++ b/src/common/RandomGenerator.spec.ts @@ -0,0 +1,92 @@ +module TK { + testing("RandomGenerator", test => { + test.case("produces floats", check => { + var gen = new RandomGenerator(); + + var i = 100; + while (i--) { + var value = gen.random(); + check.greaterorequal(value, 0); + check.greater(1, value); + } + }); + + test.case("produces integers", check => { + var gen = new RandomGenerator(); + + var i = 100; + while (i--) { + var value = gen.randInt(5, 12); + check.equals(Math.round(value), value); + check.greater(value, 4); + check.greater(13, value); + } + }); + + test.case("chooses from an array", check => { + var gen = new RandomGenerator(); + + check.equals(gen.choice([5]), 5); + + var i = 100; + while (i--) { + var value = gen.choice(["test", "thing"]); + check.contains(["thing", "test"], value); + } + }); + + test.case("samples from an array", check => { + var gen = new RandomGenerator(); + + var i = 100; + while (i-- > 1) { + var input = [1, 2, 3, 4, 5]; + var sample = gen.sample(input, i % 5 + 1); + check.same(sample.length, i % 5 + 1); + sample.forEach((num, idx) => { + check.contains(input, num); + check.notcontains(sample.filter((ival, iidx) => iidx != idx), num); + }); + } + }); + + test.case("choose from weighted ranges", check => { + let gen = new RandomGenerator(); + + check.equals(gen.weighted([]), -1); + check.equals(gen.weighted([1]), 0); + check.equals(gen.weighted([0, 1, 0]), 1); + check.equals(gen.weighted([0, 12, 0]), 1); + + gen = new SkewedRandomGenerator([0, 0.5, 0.7, 0.8, 0.9999]); + check.equals(gen.weighted([4, 3, 0, 2, 1]), 0); + check.equals(gen.weighted([4, 3, 0, 2, 1]), 1); + check.equals(gen.weighted([4, 3, 0, 2, 1]), 3); + check.equals(gen.weighted([4, 3, 0, 2, 1]), 3); + check.equals(gen.weighted([4, 3, 0, 2, 1]), 4); + }); + + test.case("generates ids", check => { + let gen = new SkewedRandomGenerator([0, 0.4, 0.2, 0.1, 0.3, 0.8]); + check.equals(gen.id(6, "abcdefghij"), "aecbdi"); + }); + + test.case("can be skewed", check => { + var gen = new SkewedRandomGenerator([0, 0.5, 0.2, 0.9]); + + check.equals(gen.random(), 0); + check.equals(gen.random(), 0.5); + check.equals(gen.randInt(4, 8), 5); + check.equals(gen.random(), 0.9); + + var value = gen.random(); + check.greaterorequal(value, 0); + check.greater(1, value); + + gen = new SkewedRandomGenerator([0.7], true); + check.equals(gen.random(), 0.7); + check.equals(gen.random(), 0.7); + check.equals(gen.random(), 0.7); + }); + }); +} diff --git a/src/common/RandomGenerator.ts b/src/common/RandomGenerator.ts new file mode 100644 index 0000000..e8f8a09 --- /dev/null +++ b/src/common/RandomGenerator.ts @@ -0,0 +1,114 @@ +module TK { + /* + * Random generator. + */ + export class RandomGenerator { + static global: RandomGenerator = new RandomGenerator(); + + postUnserialize() { + this.random = Math.random; + } + + /** + * Get a random number in the (0.0 included -> 1.0 excluded) range + */ + random = Math.random; + + /** + * Get a random number in the (*from* included -> *to* included) range + */ + randInt(from: number, to: number): number { + return Math.floor(this.random() * (to - from + 1)) + from; + } + + /** + * Choose a random item in an array + */ + choice(input: T[]): T { + return input[this.randInt(0, input.length - 1)]; + } + + /** + * Choose a random sample of items from an array + */ + sample(input: T[], count: number): T[] { + var minput = input.slice(); + var result: T[] = []; + while (count--) { + var idx = this.randInt(0, minput.length - 1); + result.push(minput[idx]); + minput.splice(idx, 1); + } + return result; + } + + /** + * Get a random boolean (coin toss) + */ + bool(): boolean { + return this.randInt(0, 1) == 0; + } + + /** + * Get the range in which the number falls, ranges being weighted + */ + weighted(weights: number[]): number { + if (weights.length == 0) { + return -1; + } + + let total = sum(weights); + if (total == 0) { + return 0; + } else { + let cumul = 0; + weights = weights.map(weight => { + cumul += weight / total; + return cumul; + }); + let r = this.random(); + for (let i = 0; i < weights.length; i++) { + if (r < weights[i]) { + return i; + } + } + return weights.length - 1; + } + } + + /** + * Generate a random id string, composed of ascii characters + */ + id(length: number, chars?: string): string { + if (!chars) { + chars = range(94).map(i => String.fromCharCode(i + 33)).join(""); + } + return range(length).map(() => this.choice(chars)).join(""); + } + } + + /* + * Random generator that produces a series of fixed numbers before going back to random ones. + */ + export class SkewedRandomGenerator extends RandomGenerator { + i = 0; + suite: number[]; + loop: boolean; + + constructor(suite: number[], loop = false) { + super(); + + this.suite = suite; + this.loop = loop; + } + + random = () => { + var result = this.suite[this.i]; + this.i += 1; + if (this.loop && this.i == this.suite.length) { + this.i = 0; + } + return (typeof result == "undefined") ? Math.random() : result; + } + } +} \ No newline at end of file diff --git a/src/common/Serializer.spec.ts b/src/common/Serializer.spec.ts new file mode 100644 index 0000000..7ffee31 --- /dev/null +++ b/src/common/Serializer.spec.ts @@ -0,0 +1,104 @@ +module TK.Specs { + export class TestSerializerObj1 { + a: number; + constructor(a = 0) { + this.a = a; + } + } + + export class TestSerializerObj2 { + a = () => 1 + b = [(obj: any) => 2] + } + + export class TestSerializerObj3 { + a = [1, 2]; + postUnserialize() { + remove(this.a, 2); + } + } + + testing("Serializer", test => { + function checkReversability(obj: any, namespace = TK.Specs): any { + var serializer = new Serializer(TK.Specs); + var data = serializer.serialize(obj); + serializer = new Serializer(TK.Specs); + var loaded = serializer.unserialize(data); + test.check.equals(loaded, obj); + return loaded; + } + + test.case("serializes simple objects", check => { + var obj = { + "a": 5, + "b": null, + "c": [{ "a": 2 }, "test"] + }; + checkReversability(obj); + }); + + test.case("restores objects constructed from class", check => { + var loaded = checkReversability(new TestSerializerObj1(5)); + check.equals(loaded.a, 5); + check.same(loaded instanceof TestSerializerObj1, true, "not a TestSerializerObj1 instance"); + }); + + test.case("stores one version of the same object", check => { + var a = new TestSerializerObj1(8); + var b = new TestSerializerObj1(8); + var c = { + 'r': a, + 's': ["test", a], + 't': a, + 'u': b + }; + var loaded = checkReversability(c); + check.same(loaded.t, loaded.r); + check.same(loaded.s[1], loaded.r); + check.notsame(loaded.u, loaded.r); + }); + + test.case("handles circular references", check => { + var a: any = { b: {} }; + a.b.c = a; + + var loaded = checkReversability(a); + }); + + test.case("ignores some classes", check => { + var serializer = new Serializer(TK.Specs); + serializer.addIgnoredClass("TestSerializerObj1"); + + var data = serializer.serialize({ a: 5, b: new TestSerializerObj1() }); + var loaded = serializer.unserialize(data); + + check.equals(loaded, { a: 5, b: undefined }); + }); + + test.case("ignores functions", check => { + let serializer = new Serializer(TK.Specs); + let data = serializer.serialize({ obj: new TestSerializerObj2() }); + let loaded = serializer.unserialize(data); + + let expected = new TestSerializerObj2(); + expected.a = undefined; + expected.b[0] = undefined; + check.equals(loaded, { obj: expected }); + }); + + test.case("calls specific postUnserialize", check => { + let serializer = new Serializer(TK.Specs); + let data = serializer.serialize({ obj: new TestSerializerObj3() }); + let loaded = serializer.unserialize(data); + + let expected = new TestSerializerObj3(); + expected.a = [1]; + check.equals(loaded, { obj: expected }); + }); + + test.case("finds TS namespace, even from sub-namespace", check => { + checkReversability(new Timer()); + checkReversability(new RandomGenerator()); + }); + }); +} diff --git a/src/common/Serializer.ts b/src/common/Serializer.ts new file mode 100644 index 0000000..669f446 --- /dev/null +++ b/src/common/Serializer.ts @@ -0,0 +1,111 @@ +module TK { + + function isObject(value: any): boolean { + return value instanceof Object && !Array.isArray(value); + } + + /** + * A typescript object serializer. + */ + export class Serializer { + namespace: any; + ignored: string[] = []; + + constructor(namespace: any = TK) { + this.namespace = namespace; + } + + /** + * Add a class to the ignore list + */ + addIgnoredClass(name: string) { + this.ignored.push(name); + } + + /** + * Construct an object from a constructor name + */ + constructObject(ctype: string): Object { + if (ctype == "Object") { + return {}; + } else { + let cl = this.namespace[ctype]; + if (cl) { + return Object.create(cl.prototype); + } else { + cl = (TK)[ctype]; + if (cl) { + return Object.create(cl.prototype); + } else { + console.error("Can't find class", ctype); + return {}; + } + } + } + } + + /** + * Serialize an object to a string + */ + serialize(obj: any): string { + // Collect objects + var objects: Object[] = []; + var stats: any = {}; + crawl(obj, value => { + if (isObject(value)) { + var vtype = classname(value); + if (vtype != "" && this.ignored.indexOf(vtype) < 0) { + stats[vtype] = (stats[vtype] || 0) + 1; + add(objects, value); + return value; + } else { + return TK.STOP_CRAWLING; + } + } else { + return value; + } + }); + //console.log("Serialize stats", stats); + + // Serialize objects list, transforming deeper objects to links + var fobjects = objects.map(value => { $c: classname(value), $f: merge({}, value) }); + return JSON.stringify(fobjects, (key, value) => { + if (key != "$f" && isObject(value) && !value.hasOwnProperty("$c") && !value.hasOwnProperty("$i")) { + return { $i: objects.indexOf(value) }; + } else { + return value; + } + }); + } + + /** + * Unserialize a string to an object + */ + unserialize(data: string): any { + // Unserialize objects list + var fobjects = JSON.parse(data); + + // Reconstruct objects + var objects = fobjects.map((objdata: any) => merge(this.constructObject(objdata['$c']), objdata['$f'])); + + // Reconnect links + crawl(objects, value => { + if (value instanceof Object && value.hasOwnProperty('$i')) { + return objects[value['$i']]; + } else { + return value; + } + }, true); + + // Post unserialize hooks + crawl(objects[0], value => { + if (value instanceof Object && typeof value.postUnserialize == "function") { + value.postUnserialize(); + } + }); + + // First object was the root + return objects[0]; + } + } +} diff --git a/src/common/Testing.ts b/src/common/Testing.ts new file mode 100644 index 0000000..bce9d07 --- /dev/null +++ b/src/common/Testing.ts @@ -0,0 +1,330 @@ +/** + * Various testing functions. + */ +module TK { + export type FakeClock = { forward: (milliseconds: number) => void } + export type Mock = { func: F, getCalls: () => any[][], reset: () => void } + + /** + * Main test suite descriptor + */ + export function testing(desc: string, body: (test: TestSuite) => void) { + if (typeof describe != "undefined") { + describe(desc, () => { + beforeEach(() => jasmine.addMatchers(CUSTOM_MATCHERS)); + + let test = new TestSuite(desc); + body(test); + }); + } + } + + /** + * Test suite (group of test cases) + */ + export class TestSuite { + private desc: string + constructor(desc: string) { + this.desc = desc; + } + + /** + * Add a setup step for each case of the suite + */ + setup(body: Function, cleanup?: Function): void { + beforeEach(() => body()); + if (cleanup) { + afterEach(() => cleanup()); + } + } + + /** + * Add an asynchronous setup step for each case of the suite + */ + asetup(body: () => Promise, cleanup?: Function): void { + beforeEach((done) => body().then(done)); + if (cleanup) { + afterEach(() => cleanup()); + } + } + + /** + * Describe a single test case + */ + case(desc: string, body: (ctx: TestContext) => void): void { + it(desc, () => { + console.debug(`${this.desc} ${desc}`); + body(new TestContext()) + }); + } + + /** + * Describe an asynchronous test case + */ + acase(desc: string, body: (ctx: TestContext) => Promise): void { + it(desc, done => { + console.debug(`${this.desc} ${desc}`); + body(new TestContext()).then(done).catch(done.fail); + }); + } + + /** + * Setup fake clock for the suite + */ + clock(): FakeClock { + let current = 0; + + beforeEach(function () { + current = 0; + jasmine.clock().install(); + spyOn(Timer, "nowMs").and.callFake(() => current); + }); + + afterEach(function () { + jasmine.clock().uninstall(); + }); + + return { + forward: milliseconds => { + current += milliseconds; + jasmine.clock().tick(milliseconds); + } + }; + } + + /** + * Out-of-context assertion helpers + * + * It is better to use in-context checks, for better information + */ + get check(): TestContext { + return new TestContext(); + } + } + + /** + * A test context, with assertion helpers + */ + export class TestContext { + info: string[]; + + constructor(info: string[] = []) { + this.info = info; + } + + /** + * Create a sub context (adds information for all assertions done with this context) + */ + sub(info: string): TestContext { + return new TestContext(this.info.concat([info])); + } + + /** + * Execute a body in a sub context + */ + in(info: string, body: (ctx: TestContext) => void): void { + body(this.sub(info)); + } + + /** + * Builds a message, with context information added + */ + message(message?: string): string | undefined { + let parts = this.info; + if (message) { + parts = parts.concat([message]); + } + return parts.length ? parts.join(" - ") : undefined; + } + + /** + * Patch an object's method with a mock + * + * Replacement may be: + * - undefined to call through + * - null to not call anything + * - a fake function to call instead + * + * All patches are removed at the end of a case + */ + patch(obj: T, method: K, replacement?: F | null): Mock { + let spy = spyOn(obj, method); + if (replacement === null) { + spy.and.stub(); + } else if (replacement) { + spy.and.callFake(replacement); + } else { + spy.and.callThrough(); + } + + return { + func: spy, + getCalls: () => spy.calls.all().map(info => info.args), + reset: () => spy.calls.reset() + } + } + + /** + * Create a mock function + */ + mockfunc(name = "mock", replacement?: F): Mock { + let spy = jasmine.createSpy(name, replacement); + + if (replacement) { + spy = spy.and.callThrough(); + } + + return { + func: spy, + getCalls: () => spy.calls.all().map(info => info.args), + reset: () => spy.calls.reset() + } + } + + /** + * Check that a mock have been called a given number of times, or with specific args + */ + called(mock: Mock, calls: number | any[][], reset = true): void { + if (typeof calls == "number") { + expect(mock.getCalls().length).toEqual(calls, this.message()); + } else { + expect(mock.getCalls()).toEqual(calls, this.message()); + } + + if (reset) { + mock.reset(); + } + } + + /** + * Check that a function call throws an error + */ + throw(call: Function, error?: string | Error): void { + if (typeof error == "undefined") { + expect(call).toThrow(); + } else if (typeof error == "string") { + expect(call).toThrowError(error); + } else { + expect(call).toThrow(error); + } + } + + /** + * Check that an object is an instance of a given type + */ + instance(obj: any, classref: { new(...args: any[]): T }, message: string): obj is T { + let result = obj instanceof classref; + expect(result).toBe(true, this.message(message)); + return result; + } + + /** + * Check that two references are the same object + */ + same(ref1: T | null | undefined, ref2: T | null | undefined, message?: string): void { + expect(ref1).toBe(ref2, this.message(message)); + } + + /** + * Check that two references are not the same object + */ + notsame(ref1: T | null, ref2: T | null, message?: string): void { + expect(ref1).not.toBe(ref2, this.message(message)); + } + + /** + * Check that two values are equal, in the sense of deep comparison + */ + equals(val1: T, val2: T, message?: string): void { + expect(val1).toEqual(val2, this.message(message)); + } + + /** + * Check that two values differs, in the sense of deep comparison + */ + notequals(val1: T, val2: T, message?: string): void { + expect(val1).not.toEqual(val2, this.message(message)); + } + + /** + * Check that a numerical value is close to another, at a given number of digits precision + */ + nears(val1: number, val2: number, precision = 8, message?: string): void { + if (precision != Math.round(precision)) { + throw new Error(`'nears' precision should be integer, not {precision}`); + } + expect(val1).toBeCloseTo(val2, precision, this.message(message)); + } + + /** + * Check that a numerical value is greater than another + */ + greater(val1: number, val2: number, message?: string): void { + expect(val1).toBeGreaterThan(val2, this.message(message)); + } + + /** + * Check that a numerical value is greater than or equal to another + */ + greaterorequal(val1: number, val2: number, message?: string): void { + expect(val1).toBeGreaterThanOrEqual(val2, this.message(message)); + } + + /** + * Check that a string matches a regex + */ + regex(pattern: RegExp, value: string, message?: string): void { + expect(value).toMatch(pattern, this.message(message)); + } + + /** + * Check that an array contains an item + */ + contains(array: T[], item: T, message?: string): void { + expect(array).toContain(item, this.message(message)); + } + + /** + * Check that an array does not contain an item + */ + notcontains(array: T[], item: T, message?: string): void { + expect(array).not.toContain(item, this.message(message)); + } + + /** + * Check than an object contains a set of properties + */ + containing(val: T, props: Partial, message?: string): void { + expect(val).toEqual(jasmine.objectContaining(props), this.message(message)); + } + + /** + * Fail the whole case + */ + fail(message?: string): void { + fail(this.message(message)); + } + } + + const CUSTOM_MATCHERS = { + toEqual: function (util: any, customEqualityTesters: any) { + customEqualityTesters = customEqualityTesters || []; + + return { + compare: function (actual: any, expected: any, message?: string) { + let result: any = { pass: false }; + let diffBuilder = (jasmine).DiffBuilder(); + + result.pass = util.equals(actual, expected, customEqualityTesters, diffBuilder); + + result.message = diffBuilder.getMessage(); + if (message) { + result.message += " " + message; + } + + return result; + } + }; + } + } +} \ No newline at end of file diff --git a/src/common/Timer.spec.ts b/src/common/Timer.spec.ts new file mode 100644 index 0000000..1896466 --- /dev/null +++ b/src/common/Timer.spec.ts @@ -0,0 +1,117 @@ +module TK.Specs { + testing("Timer", test => { + let clock = test.clock(); + + test.case("schedules and cancels future calls", check => { + let timer = new Timer(); + + let called: any[] = []; + let callback = (item: any) => called.push(item); + + let s1 = timer.schedule(50, () => callback(1)); + let s2 = timer.schedule(150, () => callback(2)); + let s3 = timer.schedule(250, () => callback(3)); + + check.equals(called, []); + clock.forward(100); + check.equals(called, [1]); + timer.cancel(s1); + check.equals(called, [1]); + clock.forward(100); + check.equals(called, [1, 2]); + timer.cancel(s3); + clock.forward(100); + check.equals(called, [1, 2]); + clock.forward(1000); + check.equals(called, [1, 2]); + }); + + test.case("may cancel all scheduled", check => { + let timer = new Timer(); + + let called: any[] = []; + let callback = (item: any) => called.push(item); + + timer.schedule(150, () => callback(1)); + timer.schedule(50, () => callback(2)); + timer.schedule(500, () => callback(3)); + + check.equals(called, []); + + clock.forward(100); + + check.equals(called, [2]); + + clock.forward(100); + + check.equals(called, [2, 1]); + + timer.cancelAll(); + + clock.forward(1000); + + check.equals(called, [2, 1]); + + timer.schedule(50, () => callback(4)); + timer.schedule(150, () => callback(5)); + + clock.forward(100); + + check.equals(called, [2, 1, 4]); + + timer.cancelAll(true); + + clock.forward(100); + + check.equals(called, [2, 1, 4]); + + timer.schedule(50, () => callback(6)); + + clock.forward(100); + + check.equals(called, [2, 1, 4]); + }); + + test.case("may switch to synchronous mode", check => { + let timer = new Timer(true); + let called: any[] = []; + let callback = (item: any) => called.push(item); + + timer.schedule(50, () => callback(1)); + check.equals(called, [1]); + }); + + test.acase("sleeps asynchronously", async check => { + let timer = new Timer(); + let x = 1; + + let promise = timer.sleep(500).then(() => { + x++; + }); + check.equals(x, 1); + + clock.forward(300); + check.equals(x, 1); + + clock.forward(300); + check.equals(x, 1); + + await promise; + check.equals(x, 2); + }); + + test.case("gives current time in milliseconds", check => { + check.equals(Timer.nowMs(), 0); + + clock.forward(5); + + check.equals(Timer.nowMs(), 5); + let t = Timer.nowMs(); + + clock.forward(10); + + check.equals(Timer.nowMs(), 15); + check.equals(Timer.fromMs(t), 10); + }); + }); +} \ No newline at end of file diff --git a/src/common/Timer.ts b/src/common/Timer.ts new file mode 100644 index 0000000..93eaa23 --- /dev/null +++ b/src/common/Timer.ts @@ -0,0 +1,100 @@ +module TK { + /** + * Timing utility. + * + * This extends the standard setTimeout feature. + */ + export class Timer { + // Global timer shared by the whole project + static global = new Timer(); + + // Global synchronous timer for unit tests + static synchronous = new Timer(true); + + private sync = false; + + private locked = false; + + private scheduled: any[] = []; + + constructor(sync = false) { + this.sync = sync; + } + + /** + * Get the current timestamp in milliseconds + */ + static nowMs(): number { + return (new Date()).getTime(); + } + + /** + * Get the elapsed time in milliseconds since a previous timestamp + */ + static fromMs(previous: number): number { + return this.nowMs() - previous; + } + + /** + * Return true if the timer is synchronous + */ + isSynchronous() { + return this.sync; + } + + /** + * Cancel all scheduled calls. + * + * If lock=true, no further scheduling will be allowed. + */ + cancelAll(lock = false) { + this.locked = lock; + + let scheduled = this.scheduled; + this.scheduled = []; + + scheduled.forEach(handle => clearTimeout(handle)); + } + + /** + * Cancel a scheduled callback. + */ + cancel(scheduled: any) { + if (remove(this.scheduled, scheduled)) { + clearTimeout(scheduled); + } + } + + /** + * Schedule a callback to be called later (time is in milliseconds). + */ + schedule(delay: number, callback: Function): any { + if (this.locked) { + return null; + } else if (this.sync || delay <= 0) { + callback(); + return null; + } else { + let handle = setTimeout(() => { + remove(this.scheduled, handle); + callback(); + }, delay); + add(this.scheduled, handle); + return handle; + } + } + + /** + * Asynchronously sleep a given time. + */ + async sleep(ms: number): Promise { + return new Promise(resolve => { + this.schedule(ms, resolve); + }); + } + + postUnserialize() { + this.scheduled = []; + } + } +} diff --git a/src/common/Toggle.spec.ts b/src/common/Toggle.spec.ts new file mode 100644 index 0000000..08b57ae --- /dev/null +++ b/src/common/Toggle.spec.ts @@ -0,0 +1,158 @@ +module TK.Specs { + testing("Toggle", test => { + let on_calls = 0; + let off_calls = 0; + let clock = test.clock(); + + test.setup(function () { + on_calls = 0; + off_calls = 0; + }); + + function newToggle(): Toggle { + return new Toggle(() => on_calls++, () => off_calls++); + } + + function checkstate(on: number, off: number) { + test.check.same(on_calls, on); + test.check.same(off_calls, off); + on_calls = 0; + off_calls = 0; + } + + test.case("toggles on and off", check => { + let toggle = newToggle(); + let client = toggle.manipulate("test"); + checkstate(0, 0); + + let result = client(true); + check.equals(result, true); + checkstate(1, 0); + + result = client(true); + check.equals(result, true); + checkstate(0, 0); + + clock.forward(10000000); + checkstate(0, 0); + + result = client(false); + check.equals(result, false); + checkstate(0, 1); + + result = client(false); + check.equals(result, false); + checkstate(0, 0); + + clock.forward(10000000); + checkstate(0, 0); + + result = client(true); + check.equals(result, true); + checkstate(1, 0); + + let client2 = toggle.manipulate("test2"); + result = client2(true); + check.equals(result, true); + checkstate(0, 0); + + result = client(false); + check.equals(result, true); + checkstate(0, 0); + + result = client2(false); + check.equals(result, false); + checkstate(0, 1); + }) + + test.case("switches between on and off", check => { + let toggle = newToggle(); + let client = toggle.manipulate("test"); + checkstate(0, 0); + + let result = client(); + check.equals(result, true); + checkstate(1, 0); + + result = client(); + check.equals(result, false); + checkstate(0, 1); + + result = client(); + check.equals(result, true); + checkstate(1, 0); + + let client2 = toggle.manipulate("test2"); + checkstate(0, 0); + + result = client2(); + check.equals(result, true); + checkstate(0, 0); + + result = client(); + check.equals(result, true); + checkstate(0, 0); + + result = client2(); + check.equals(result, false); + checkstate(0, 1); + }) + + test.case("toggles on for a given time", check => { + let toggle = newToggle(); + let client = toggle.manipulate("test"); + checkstate(0, 0); + + let result = client(100); + check.equals(result, true); + checkstate(1, 0); + + check.equals(toggle.isOn(), true); + checkstate(0, 0); + clock.forward(60); + check.equals(toggle.isOn(), true); + checkstate(0, 0); + clock.forward(60); + check.equals(toggle.isOn(), false); + checkstate(0, 1); + + result = client(100); + check.equals(result, true); + checkstate(1, 0); + result = client(200); + check.equals(result, true); + checkstate(0, 0); + clock.forward(150); + check.equals(toggle.isOn(), true); + checkstate(0, 0); + clock.forward(150); + check.equals(toggle.isOn(), false); + checkstate(0, 1); + + let client2 = toggle.manipulate("test2"); + result = client(100); + check.equals(result, true); + checkstate(1, 0); + result = client2(200); + check.equals(result, true); + checkstate(0, 0); + clock.forward(150); + check.equals(toggle.isOn(), true); + checkstate(0, 0); + clock.forward(150); + check.equals(toggle.isOn(), false); + checkstate(0, 1); + + result = client(100); + check.equals(result, true); + checkstate(1, 0); + result = client(true); + check.equals(result, true); + checkstate(0, 0); + check.equals(toggle.isOn(), true); + clock.forward(2000); + check.equals(toggle.isOn(), true); + checkstate(0, 0); + }) + }) +} \ No newline at end of file diff --git a/src/common/Toggle.ts b/src/common/Toggle.ts new file mode 100644 index 0000000..c2ef480 --- /dev/null +++ b/src/common/Toggle.ts @@ -0,0 +1,93 @@ +module TK { + /** + * Client for Toggle object, allowing to manipulate it + * + * *state* may be: + * - a boolean to require on or off + * - a number to require on for the duration in milliseconds + * - undefined to switch between on and off (based on the client state, not the toggle state) + * + * The function returns the actual state after applying the requirement + */ + export type ToggleClient = (state?: boolean | number) => boolean + + /** + * A toggle between two states (on and off). + * + * A toggle will be on if at least one ToggleClient requires it to be on. + */ + export class Toggle { + private on: Function + private off: Function + private status = false + private clients: string[] = [] + private scheduled: { [client: string]: any } = {} + private timer = Timer.global + + constructor(on: Function = () => null, off: Function = () => null) { + this.on = on; + this.off = off; + } + + /** + * Check if the current state is on + */ + isOn(): boolean { + return this.status; + } + + /** + * Register a client to manipulate the toggle's state + */ + manipulate(client: string): ToggleClient { + return state => { + if (this.scheduled[client]) { + this.timer.cancel(this.scheduled[client]); + this.scheduled[client] = null; + } + + if (typeof state == "undefined") { + if (contains(this.clients, client)) { + this.stop(client); + } else { + this.start(client); + } + } else if (typeof state == "number") { + if (state > 0) { + this.start(client); + this.scheduled[client] = this.timer.schedule(state, () => this.stop(client)); + } else { + this.stop(client); + } + } else if (!state) { + this.stop(client); + } else { + this.start(client); + } + return this.status; + } + } + + /** + * Start the toggle for a client (set the status *on*) + */ + private start(client: string) { + add(this.clients, client); + if (!this.status) { + this.status = true; + this.on(); + } + } + + /** + * Stop the toggle (set the status *off*) + */ + private stop(client: string) { + remove(this.clients, client); + if (this.status && this.clients.length == 0) { + this.status = false; + this.off(); + } + } + } +} diff --git a/src/common/Tools.spec.ts b/src/common/Tools.spec.ts new file mode 100644 index 0000000..6e6fcb2 --- /dev/null +++ b/src/common/Tools.spec.ts @@ -0,0 +1,517 @@ +module TK.Specs { + testing("Tools", test => { + test.case("returns boolean equivalent", check => { + check.same(bool(null), false, "null"); + check.same(bool(undefined), false, "undefined"); + + check.same(bool(false), false, "false"); + check.same(bool(true), true, "true"); + + check.same(bool(0), false, "0"); + check.same(bool(1), true, "1"); + check.same(bool(-1), true, "-1"); + + check.same(bool(""), false, "\"\""); + check.same(bool(" "), true, "\" \""); + check.same(bool("abc"), true, "\"abc\""); + + check.same(bool([]), false, "[]"); + check.same(bool([1]), true, "[1]"); + check.same(bool([null, "a"]), true, "[null, \"a\"]"); + + check.same(bool({}), false, "{}"); + check.same(bool({ a: 5 }), true, "{a: 5}"); + check.same(bool(new Timer()), true, "new Timer()"); + }); + + test.case("coalesces to a default value", check => { + check.equals(coalesce(0, 2), 0); + check.equals(coalesce(5, 2), 5); + check.equals(coalesce(null, 2), 2); + check.equals(coalesce(undefined, 2), 2); + + check.equals(coalesce("", "a"), ""); + check.equals(coalesce("b", "a"), "b"); + check.equals(coalesce(null, "a"), "a"); + check.equals(coalesce(undefined, "a"), "a"); + }); + + test.case("do basic function composition", check => { + check.equals(fmap((x: number) => x * 2, x => x + 1)(3), 8); + }); + + test.case("function composes a fallback value for null results", check => { + let f = nnf(-1, x => x > 3 ? null : x); + check.equals(f(2), 2); + check.equals(f(3), 3); + check.equals(f(4), -1); + }); + + test.case("checks for null value", check => { + let value: number | null = 5; + check.equals(nn(value), 5); + value = 0; + check.equals(nn(value), 0); + value = null; + check.throw(() => nn(value), "Null value"); + }); + + test.case("removes null values from arrays", check => { + let value: (number | null)[] = []; + check.equals(nna(value), []); + value = [1, 2]; + check.equals(nna(value), [1, 2]); + value = [1, null, 3]; + check.equals(nna(value), [1, 3]); + }); + + test.case("cast-checks objects", check => { + let obj = new RObject(); + check.equals(as(RObject, obj), obj); + check.throw(() => as(Timer, obj), new Error("Bad cast")); + }); + + test.case("compare values", check => { + check.equals(cmp(8, 5), 1); + check.same(cmp(5, 8), -1); + check.equals(cmp(5, 5), 0); + + check.equals(cmp("c", "b"), 1); + check.same(cmp("b", "c"), -1); + check.equals(cmp("b", "b"), 0); + + check.same(cmp(8, 5, true), -1); + check.equals(cmp(5, 8, true), 1); + check.equals(cmp(5, 5, true), 0); + }); + + test.case("clamp values in a range", check => { + check.equals(clamp(5, 3, 8), 5); + check.equals(clamp(1, 3, 8), 3); + check.equals(clamp(10, 3, 8), 8); + }); + + test.case("interpolates values linearly", check => { + check.equals(lerp(0, 0, 4), 0); + check.equals(lerp(0.5, 0, 4), 2); + check.equals(lerp(1, 0, 4), 4); + check.equals(lerp(2, 0, 4), 8); + check.same(lerp(-1, 0, 4), -4); + check.equals(lerp(0.5, 3, 4), 3.5); + check.equals(lerp(0.5, 3, 3), 3); + check.equals(lerp(0.5, 3, 2), 2.5); + }); + + test.case("duplicates objects", check => { + check.equals(duplicate(null), null); + check.equals(duplicate(5), 5); + check.equals(duplicate("test"), "test"); + check.equals(duplicate({ a: 4 }), { a: 4 }); + check.equals(duplicate([1, "test"]), [1, "test"]); + check.equals(duplicate(new TestSerializerObj1(6), TK.Specs), new TestSerializerObj1(6)); + let original = new TestRObject(4); + check.equals(duplicate(original, TK.Specs), original); + check.notsame(duplicate(original, TK.Specs), original); + }); + + test.case("copies arrays", check => { + var array = [1, 2, "test", null, { "a": 5 }]; + var copied = acopy(array); + + check.equals(copied, array); + check.notsame(copied, array); + check.same(copied[4], array[4]); + + check.equals(array[2], "test"); + check.equals(copied[2], "test"); + array[2] = "notest"; + check.equals(array[2], "notest"); + check.equals(copied[2], "test"); + copied[2] = "ok"; + check.equals(array[2], "notest"); + check.equals(copied[2], "ok"); + + check.equals(array.length, 5); + check.equals(copied.length, 5); + remove(copied, 2); + check.equals(array.length, 5); + check.equals(copied.length, 4); + }); + + test.case("iterates through sorted arrays", check => { + var result: number[] = []; + itersorted([1, 2, 3], item => item, item => result.push(item)); + check.equals(result, [1, 2, 3]); + + result = []; + itersorted([1, 2, 3], item => -item, item => result.push(item)); + check.equals(result, [3, 2, 1]); + }); + + test.case("checks if an array contains an item", check => { + check.equals(contains([], 5), false); + + check.equals(contains([3, 5, 8], 5), true); + check.equals(contains([3, 5, 8], 4), false); + + check.equals(contains([5, 5, 5], 5), true); + + check.equals(contains([3, null, 8], null), true); + + check.equals(contains(["a", "b"], "b"), true); + check.equals(contains(["a", "b"], "c"), false); + }); + + test.case("capitalizes strings", check => { + check.equals(capitalize("test"), "Test"); + check.equals(capitalize("test second"), "Test second"); + }); + + test.case("produces range of numbers", check => { + check.equals(range(-1), []); + check.equals(range(0), []); + check.equals(range(1), [0]); + check.equals(range(2), [0, 1]); + check.equals(range(5), [0, 1, 2, 3, 4]); + }); + + test.case("zips arrays", check => { + check.equals(zip([], []), []); + check.equals(zip([], [1]), []); + check.equals(zip([0], [1]), [[0, 1]]); + check.equals(zip([0, 2, 4], [1, 3]), [[0, 1], [2, 3]]); + check.equals(zip([0, 1], ["a", "b"]), [[0, "a"], [1, "b"]]); + }); + + test.case("unzips arrays", check => { + check.equals(unzip([]), [[], []]); + check.equals(unzip([[1, "a"]]), [[1], ["a"]]); + check.equals(unzip([[1, "a"], [2, "b"]]), [[1, 2], ["a", "b"]]); + }); + + test.case("partitions arrays by a predicate", check => { + check.equals(binpartition([], (i: number) => i % 2 == 0), [[], []]); + check.equals(binpartition([1, 2, 3, 4], i => i % 2 == 0), [[2, 4], [1, 3]]); + }); + + test.case("produces neighbor tuples from array", check => { + check.equals(neighbors([]), []); + check.equals(neighbors([1]), []); + check.equals(neighbors([1, 2]), [[1, 2]]); + check.equals(neighbors([1, 2, 3]), [[1, 2], [2, 3]]); + check.equals(neighbors([1, 2, 3, 4]), [[1, 2], [2, 3], [3, 4]]); + + check.equals(neighbors([], true), []); + check.equals(neighbors([1], true), [[1, 1]]); + check.equals(neighbors([1, 2], true), [[1, 2], [2, 1]]); + check.equals(neighbors([1, 2, 3], true), [[1, 2], [2, 3], [3, 1]]); + check.equals(neighbors([1, 2, 3, 4], true), [[1, 2], [2, 3], [3, 4], [4, 1]]); + }); + + test.case("filters list with type guards", check => { + let result = tfilter(<(number | string)[]>[1, "a", 2, "b"], (x): x is number => typeof x == "number"); + check.equals(result, [1, 2]); + + let o1 = new RObject(); + let o2 = new RObject(); + let o3 = new RObjectContainer(); + check.equals(cfilter([1, "a", o1, 2, o2, o3, "b"], RObject), [o1, o2]); + }); + + test.case("flattens lists of lists", check => { + check.equals(flatten([]), []); + check.equals(flatten([[]]), []); + check.equals(flatten([[], []]), []); + check.equals(flatten([[1], []]), [1]); + check.equals(flatten([[], [1]]), [1]); + check.equals(flatten([[1], [2]]), [1, 2]); + check.equals(flatten([[1, 2], [3, 4], [], [5]]), [1, 2, 3, 4, 5]); + }); + + test.case("counts items in array", check => { + check.equals(counter([]), []); + check.equals(counter(["a"]), [["a", 1]]); + check.equals(counter(["a", "b"]), [["a", 1], ["b", 1]]); + check.equals(counter(["a", "b", "a"]), [["a", 2], ["b", 1]]); + }); + + test.case("find the first array item to pass a predicate", check => { + check.equals(first([1, 2, 3], i => i % 2 == 0), 2); + check.equals(first([1, 2, 3], i => i % 4 == 0), null); + + check.equals(any([1, 2, 3], i => i % 2 == 0), true); + check.equals(any([1, 2, 3], i => i % 4 == 0), false); + }); + + test.case("creates a simple iterator over an array", check => { + let i = iterator([1, 2, 3]); + check.equals(i(), 1); + check.equals(i(), 2); + check.equals(i(), 3); + check.equals(i(), null); + check.equals(i(), null); + + i = iterator([]); + check.equals(i(), null); + check.equals(i(), null); + }); + + test.case("iterates an object keys and values", check => { + var obj = { + "a": 1, + "c": [2.5], + "b": null + }; + check.equals(keys(obj), ["a", "c", "b"]); + check.equals(values(obj), [1, [2.5], null]); + var result: { [key: string]: any } = {}; + iteritems(obj, (key, value) => { result[key] = value; }); + check.equals(result, obj); + + check.equals(dict(items(obj)), obj); + }); + + test.case("iterates an enum", check => { + enum Test { + ZERO, + ONE, + TWO + }; + + var result: any[] = []; + iterenum(Test, item => result.push(item)); + check.equals(result, [0, 1, 2]); + }); + + test.case("create a dict from an array of couples", check => { + check.equals(dict([]), {}); + check.equals(dict([["5", 3], ["4", 1], ["5", 8]]), { "5": 8, "4": 1 }); + }); + + test.case("create an index from an array", check => { + check.equals(index([2, 3, 4], i => (i - 1).toString()), { "1": 2, "2": 3, "3": 4 }); + }); + + test.case("add an item in an array", check => { + var result; + var array = [1]; + + result = add(array, 8); + check.equals(array, [1, 8]); + check.equals(result, true); + + result = add(array, 2); + check.equals(array, [1, 8, 2]); + check.equals(result, true); + + result = add(array, 8); + check.equals(array, [1, 8, 2]); + check.equals(result, false); + }); + + test.case("removes an item from an array", check => { + var array = [1, 2, 3]; + var result = remove(array, 1); + check.equals(array, [2, 3]); + check.equals(result, true); + result = remove(array, 1); + check.equals(array, [2, 3]); + check.equals(result, false); + result = remove(array, 2); + check.equals(array, [3]); + check.equals(result, true); + result = remove(array, 3); + check.equals(array, []); + check.equals(result, true); + result = remove(array, 3); + check.equals(array, []); + check.equals(result, false); + }); + + test.case("checks objects equality", check => { + check.equals(equals({}, {}), true); + check.equals(equals({ "a": 1 }, { "a": 1 }), true); + check.equals(equals({ "a": 1 }, { "a": 2 }), false); + check.equals(equals({ "a": 1 }, { "b": 1 }), false); + check.equals(equals({ "a": 1 }, { "a": null }), false); + }); + + test.case("combinate filters", check => { + var filter = andfilter((item: number) => item > 5, (item: number) => item < 12); + check.equals(filter(4), false); + check.equals(filter(5), false); + check.equals(filter(6), true); + check.equals(filter(8), true); + check.equals(filter(11), true); + check.equals(filter(12), false); + check.equals(filter(13), false); + }); + + test.case("get a class name", check => { + class Test { + } + var a = new Test(); + check.equals(classname(a), "Test"); + }); + + test.case("find lowest item of an array", check => { + check.equals(lowest(["aaa", "b", "cc"], s => s.length), "b"); + }); + + test.case("binds callbacks", check => { + class Test { + prop = 5; + meth() { + return this.prop + 1; + } + } + var inst = new Test(); + var double = (getter: () => number): number => getter() * 2; + check.throw(() => double(inst.meth)); + check.equals(double(bound(inst, "meth")), 12); + }); + + test.case("computes progress between two boundaries", check => { + check.equals(progress(-1.0, 0.0, 1.0), 0.0); + check.equals(progress(0.0, 0.0, 1.0), 0.0); + check.equals(progress(0.4, 0.0, 1.0), 0.4); + check.equals(progress(1.8, 0.0, 1.0), 1.0); + check.equals(progress(1.5, 0.5, 2.5), 0.5); + }); + + test.case("copies full javascript objects", check => { + class TestObj { + a: string; + b: any; + constructor() { + this.a = "test"; + this.b = { c: 5.1, d: ["unit", "test", 5] }; + } + get(): string { + return this.a; + } + } + + var ini = new TestObj(); + + var cop = copy(ini); + + check.notsame(cop, ini); + check.equals(cop, ini); + + check.equals(cop.get(), "test"); + }); + + test.case("merges objects", check => { + check.equals(merge({}, {}), {}); + check.equals(merge({ a: 1 }, { b: 2 }), { a: 1, b: 2 }); + check.equals(merge({ a: 1 }, { a: 3, b: 2 }), { a: 3, b: 2 }); + check.equals(merge({ a: 1, b: 2 }, { a: undefined }), { a: undefined, b: 2 }); + }); + + test.case("crawls through objects", check => { + var obj = { + "a": 1, + "b": "test", + "c": { + "a": [2, "thing", { "a": 3, "b": {} }], + "b": null, + "c": undefined, + "d": false + } + }; + /*(obj).jasmineToString = () => "obj1"; + (obj.c).jasmineToString = () => "obj2"; + (obj.c.a[2]).jasmineToString = () => "obj3"; + (obj.c.a[2].b).jasmineToString = () => "obj4"; + (obj.c.a).jasmineToString = () => "array1";*/ + + var crawled: any[] = []; + crawl(obj, val => crawled.push(val)); + check.equals(crawled, [obj, 1, "test", obj.c, obj.c.a, 2, "thing", obj.c.a[2], 3, obj.c.a[2].b, false]); + check.equals(obj.a, 1); + + // replace mode + crawl(obj, val => typeof val == "number" ? 5 : val, true); + check.equals(obj, { a: 5, b: "test", c: { a: [5, "thing", { a: 5, b: {} }], b: null, c: undefined, d: false } }); + }); + + test.case("get minimal item of an array", check => { + check.equals(min([5, 1, 8]), 1); + }); + + test.case("get maximal item of an array", check => { + check.equals(max([5, 12, 8]), 12); + }); + + test.case("get sum of an array", check => { + check.equals(sum([5, 1, 8]), 14); + }); + + test.case("get average of an array", check => { + check.equals(avg([4, 2, 9]), 5); + }); + + test.case("converts to same sign", check => { + check.equals(samesign(2, 1), 2); + check.equals(samesign(2, -1), -2); + check.equals(samesign(-2, 1), 2); + check.equals(samesign(-2, -1), -2); + }); + + test.case("sorts an array", check => { + let base = ["aa", "bbb", "c", "dddd"]; + check.equals(sorted(base, (a, b) => cmp(a.length, b.length)), ["c", "aa", "bbb", "dddd"]); + check.equals(base, ["aa", "bbb", "c", "dddd"]); + }); + + test.case("sorts an array, with function applied to each element", check => { + check.equals(sortedBy([-8, 4, -2, 6], Math.abs), [-2, 4, 6, -8]); + check.equals(sortedBy([-8, 4, -2, 6], Math.abs, true), [-8, 6, 4, -2]); + }); + + test.case("get minimal item of an array, with function applied to each element", check => { + check.equals(minBy([-8, 4, -2, 6], Math.abs), -2); + }); + + test.case("get maximal item of an array, with function applied to each element", check => { + check.equals(maxBy([-8, 4, -2, 6], Math.abs), -8); + }); + + test.case("filter out duplicates in array", check => { + check.equals(unique([]), []); + check.equals(unique([1, 2, 3]), [1, 2, 3]); + check.equals(unique([1, 2, 3, 2, 1]), [1, 2, 3]); + }); + + test.case("get the union between two arrays", check => { + check.equals(union([], []), []); + check.equals(union([], [5]), [5]); + check.equals(union([4], []), [4]); + check.equals(union([4], [5]), [4, 5]); + check.equals(union([1, 2, 4, 8], [3, 2, 8, 7]), [1, 2, 4, 8, 3, 7]); + }); + + test.case("get the difference between two arrays", check => { + check.equals(difference([], []), []); + check.equals(difference([], [5]), []); + check.equals(difference([1, 2, 4, 8], [2, 8, 7]), [1, 4]); + }); + + test.case("get the intersection of two arrays", check => { + check.equals(intersection([], []), []); + check.equals(intersection([], [5]), []); + check.equals(intersection([4], []), []); + check.equals(intersection([6], [7]), []); + check.equals(intersection([1, 8, 2], [2, 8, 4]), [8, 2]); + }); + + test.case("get the disjunct union of two arrays", check => { + check.equals(disjunctunion([], []), []); + check.equals(disjunctunion([], [5]), [5]); + check.equals(disjunctunion([4], []), [4]); + check.equals(disjunctunion([6], [7]), [6, 7]); + check.equals(disjunctunion([1, 8, 2], [2, 8, 4]), [1, 4]); + }); + }); +} diff --git a/src/common/Tools.ts b/src/common/Tools.ts new file mode 100644 index 0000000..a92be91 --- /dev/null +++ b/src/common/Tools.ts @@ -0,0 +1,629 @@ +/** + * Various utility functions. + */ +module TK { + /** + * Functions that does nothing (useful for default callbacks) + */ + export function nop(): void { + } + + /** + * Identity function (returns the sole argument untouched) + */ + export function identity(input: T): T { + return input; + } + + /** + * Check a value for a boolean equivalent + */ + export function bool(value: T | null | undefined): value is T; + export function bool(value: any): boolean { + if (!value) { + return false; + } else if (typeof value == "object") { + return Object.keys(value).length > 0; + } else { + return true; + } + } + + /** + * Return a default value if the given one is undefined + */ + export function coalesce(value: string | null | undefined, fallback: string): string; + export function coalesce(value: number | null | undefined, fallback: number): number; + export function coalesce(value: T | null | undefined, fallback: T): T { + if (typeof value == "undefined" || value === null) { + return fallback; + } else { + return value; + } + } + + /** + * Check for an object being an instance of a type, an returns casted version + * + * Throws an error on failure to cast + */ + export function as(classref: { new(...args: any[]): T }, obj: any): T { + if (obj instanceof classref) { + return obj; + } else { + console.error("Bad cast", obj, classref); + throw new Error("Bad cast"); + } + } + + /** + * Apply a functor on the result of another function + */ + export function fmap(g: (arg: U) => V, f: (...args: any[]) => U): (...args: any[]) => V { + // TODO variadic typing, as soon as supported by typescript + return (...args) => g(f(...args)); + } + + /** + * Apply a default value to nulls or undefineds returned by a function + */ + export function nnf(fallback: T, f: (...args: any[]) => T | null): (...args: any[]) => T { + return fmap(val => val === null ? fallback : val, f); + } + + /** + * Check if a value if null, throwing an exception if its the case + */ + export function nn(value: T | null): T { + if (value === null) { + throw new Error("Null value"); + } else { + return value; + } + } + + /** + * Remove null values from an array + */ + export function nna(array: (T | null)[]): T[] { + return array.filter(item => item !== null); + } + + /** + * Compare operator, that can be used in sort() calls. + */ + export function cmp(a: any, b: any, reverse = false): number { + if (a > b) { + return reverse ? -1 : 1; + } else if (a < b) { + return reverse ? 1 : -1; + } else { + return 0; + } + } + + /** + * Clamp a value in a range. + */ + export function clamp(value: T, min: T, max: T): T { + if (value < min) { + return min; + } else if (value > max) { + return max; + } else { + return value; + } + } + + /** + * Perform a linear interpolation between two values (factor is between 0 and 1). + */ + export function lerp(factor: number, min: number, max: number): number { + return min + (max - min) * factor; + } + + /** + * Make a deep copy of any object. + * + * Serializer is used for this, and needs a namespace to work. + * + * Please be aware that contained RObjects will be duplicated, but keep their ID, thus breaking the uniqueness. + */ + export function duplicate(obj: T, namespace: Object = TK): T { + let serializer = new Serializer(namespace); + let serialized = serializer.serialize({ dat: obj }); + return serializer.unserialize(serialized).dat; + } + + /** + * Make a shallow copy of an array. + */ + export function acopy(input: T[]): T[] { + return input.slice(); + } + + /** + * Call a function for each member of an array, sorted by a key. + */ + export function itersorted(input: T[], keyfunc: (item: T) => any, callback: (item: T) => void): void { + var array = acopy(input); + array.sort((item1, item2) => cmp(keyfunc(item1), keyfunc(item2))); + array.forEach(callback); + } + + /** + * Capitalize the first letter of an input string. + */ + export function capitalize(input: string): string { + return input.charAt(0).toLocaleUpperCase() + input.slice(1); + }; + + /** + * Check if an array contains an item. + */ + export function contains(array: T[], item: T): boolean { + return array.indexOf(item) >= 0; + } + + /** + * Produce an n-sized array, with integers counting from 0 + */ + export function range(n: number): number[] { + var result: number[] = []; + for (var i = 0; i < n; i++) { + result.push(i); + } + return result; + } + + /** + * Produce an array of couples, build from the common length of two arrays + */ + export function zip(array1: T1[], array2: T2[]): [T1, T2][] { + var result: [T1, T2][] = []; + var n = (array1.length > array2.length) ? array2.length : array1.length; + for (var i = 0; i < n; i++) { + result.push([array1[i], array2[i]]); + } + return result; + } + + /** + * Produce two arrays, build from an array of couples + */ + export function unzip(array: [T1, T2][]): [T1[], T2[]] { + return [array.map(x => x[0]), array.map(x => x[1])]; + } + + /** + * Partition a list by a predicate, returning the items that pass the predicate, then the ones that don't pass it + */ + export function binpartition(array: T[], predicate: (item: T) => boolean): [T[], T[]] { + let pass: T[] = []; + let fail: T[] = []; + array.forEach(item => (predicate(item) ? pass : fail).push(item)); + return [pass, fail]; + } + + /** + * Yields the neighbors tuple list + */ + export function neighbors(array: T[], wrap = false): [T, T][] { + var result: [T, T][] = []; + if (array.length > 0) { + var previous = array[0]; + for (var i = 1; i < array.length; i++) { + result.push([previous, array[i]]); + previous = array[i]; + } + if (wrap) { + result.push([previous, array[0]]); + } + return result; + } else { + return []; + } + } + + /** + * Type filter, to return a list of instances of a given type + */ + export function tfilter(array: any[], filter: (item: any) => item is T): T[] { + return array.filter(filter); + } + + /** + * Class filter, to return a list of instances of a given type + */ + export function cfilter(array: any[], classref: { new(...args: any[]): T }): T[] { + return array.filter((item): item is T => item instanceof classref); + } + + /** + * Flatten a list of lists + */ + export function flatten(array: T[][]): T[] { + return array.reduce((a, b) => a.concat(b), []); + } + + /** + * Count each element in an array + */ + export function counter(array: T[], equals: (a: T, b: T) => boolean = (a, b) => a === b): [T, number][] { + var result: [T, number][] = []; + array.forEach(item => { + var found = first(result, iter => equals(iter[0], item)); + if (found) { + found[1]++; + } else { + result.push([item, 1]); + } + }); + return result; + } + + /** + * Return the first element of the array that matches the predicate, null if not found + */ + export function first(array: T[], predicate: (item: T) => boolean): T | null { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i])) { + return array[i]; + } + } + return null; + } + + /** + * Return whether if any element in the array matches the predicate + */ + export function any(array: T[], predicate: (item: T) => boolean): boolean { + return first(array, predicate) != null; + } + + /** + * Return an iterator over an array + * + * An iterator is a function yielding the next value each time, until the end of array where it yields null. + * + * For more powerful iterators, see Iterators + */ + export function iterator(array: T[]): () => T | null { + let i = 0; + return () => (i < array.length) ? array[i++] : null; + } + + /** + * Iterate a list of (key, value) in an object. + */ + export function iteritems(obj: { [key: string]: T }, func: (key: string, value: T) => void) { + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + func(key, obj[key]); + } + } + } + + /** + * Transform an dictionary object to a list of couples (key, value). + */ + export function items(obj: { [key: string]: T }): [string, T][] { + let result: [string, T][] = []; + iteritems(obj, (key, value) => result.push([key, value])); + return result; + } + + /** + * Return the list of keys from an object. + */ + export function keys(obj: T): (Extract)[] { + var result: (Extract)[] = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + result.push(key); + } + } + return result; + } + + /** + * Return the list of values from an object. + */ + export function values(obj: { [key: string]: T }): T[] { + var result: T[] = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + result.push(obj[key]); + } + } + return result; + } + + /** + * Iterate an enum values. + */ + export function iterenum(obj: T, callback: (item: number) => void) { + for (var val in obj) { + var parsed = parseInt(val, 10); + if (!isNaN(parsed)) { + callback(parsed); + } + } + } + + /** + * Create a dictionary from a list of couples + */ + export function dict(array: [string, T][]): { [index: string]: T } { + let result: { [index: string]: T } = {}; + array.forEach(([key, value]) => result[key] = value); + return result; + } + + /** + * Create a dictionnary index from a list of objects + */ + export function index(array: T[], keyfunc: (obj: T) => string): { [key: string]: T } { + var result: { [key: string]: T } = {}; + array.forEach(obj => result[keyfunc(obj)] = obj); + return result; + } + + /** + * Add an item to the end of a list, only if not already there + */ + export function add(array: T[], item: T): boolean { + if (!contains(array, item)) { + array.push(item); + return true; + } else { + return false; + } + } + /** + * Remove an item from a list if found. Return true if changed. + */ + export function remove(array: T[], item: T): boolean { + var idx = array.indexOf(item); + if (idx >= 0) { + array.splice(idx, 1); + return true; + } else { + return false; + } + } + + /** + * Check if two standard objects are equal. + */ + export function equals(obj1: { [key: string]: T }, obj2: { [key: string]: T }): boolean { + return JSON.stringify(obj1) == JSON.stringify(obj2); + } + + /** + * Call a function on any couple formed from combining two arrays. + */ + export function combicall(array1: T[], array2: T[], callback: (item1: T, item2: T) => void): void { + array1.forEach(item1 => array2.forEach(item2 => callback(item1, item2))); + } + + /** + * Combinate two filter functions (predicates), with a boolean and. + */ + export function andfilter(filt1: (item: T) => boolean, filt2: (item: T) => boolean): (item: T) => boolean { + return (item: T) => filt1(item) && filt2(item); + } + + /** + * Get the class name of an object. + */ + export function classname(obj: Object): string { + return (obj.constructor).name; + } + + /** + * Get the lowest item of an array, using a mapping function. + */ + export function lowest(array: T[], rating: (item: T) => number): T { + var rated = array.map((item: T): [T, number] => [item, rating(item)]); + rated.sort((a, b) => cmp(a[1], b[1])); + return rated[0][0]; + } + + /** + * Return a function bound to an object. + * + * This is useful to pass the bound function as callback directly. + */ + export function bound(obj: T, func: K): T[K] { + let attr = obj[func]; + if (attr instanceof Function) { + return attr.bind(obj); + } else { + return (() => attr); + } + } + + /** + * Return a 0.0-1.0 factor of progress between two limits. + */ + export function progress(value: number, min: number, max: number) { + var result = (value - min) / (max - min); + return clamp(result, 0.0, 1.0); + } + + /** + * Copy all fields of an object in another (shallow copy) + */ + export function copyfields(src: Partial, dest: Partial) { + for (let key in src) { + if (src.hasOwnProperty(key)) { + dest[key] = src[key]; + } + } + } + + /** + * Copy an object (only a shallow copy of immediate properties) + */ + export function copy(object: T): T { + let objectCopy = Object.create(object.constructor.prototype); + copyfields(object, objectCopy); + return objectCopy; + } + + /** + * Merge an object into another + */ + export function merge(base: T, incoming: Partial): T { + let result = copy(base); + copyfields(incoming, result); + return result; + } + + export const STOP_CRAWLING = {}; + + /** + * Recursively crawl through an object, yielding any defined value found along the way + * + * If *replace* is set to true, the current object is replaced (in array or object attribute) by the result of the callback + * + * *memo* is used to prevent circular references to be traversed + */ + export function crawl(obj: any, callback: (item: any) => any, replace = false, memo: any[] = []) { + if (obj instanceof Object && !Array.isArray(obj)) { + if (memo.indexOf(obj) >= 0) { + return obj; + } else { + memo.push(obj); + } + } + + if (obj !== undefined && obj !== null && typeof obj != "function") { + let result = callback(obj); + + if (result === STOP_CRAWLING) { + return; + } + + if (Array.isArray(obj)) { + let subresult = obj.map(value => crawl(value, callback, replace, memo)); + if (replace) { + subresult.forEach((value, index) => { + obj[index] = value; + }); + } + } else if (obj instanceof Object) { + let subresult: any = {}; + iteritems(obj, (key, value) => { + subresult[key] = crawl(value, callback, replace, memo); + }); + if (replace) { + copyfields(subresult, obj); + } + } + + return result; + } else { + return obj; + } + } + + /** + * Return the minimal value of an array + */ + export function min(array: T[]): T { + return array.reduce((a, b) => a < b ? a : b); + } + + /** + * Return the maximal value of an array + */ + export function max(array: T[]): T { + return array.reduce((a, b) => a > b ? a : b); + } + + /** + * Return the sum of an array + */ + export function sum(array: number[]): number { + return array.reduce((a, b) => a + b, 0); + } + + /** + * Return the average of an array + */ + export function avg(array: number[]): number { + return sum(array) / array.length; + } + + /** + * Return value, with the same sign as base + */ + export function samesign(value: number, base: number): number { + return Math.abs(value) * (base < 0 ? -1 : 1); + } + + /** + * Return a copy of the array, sorted by a cmp function (equivalent of javascript sort) + */ + export function sorted(array: T[], cmpfunc: (v1: T, v2: T) => number): T[] { + return acopy(array).sort(cmpfunc); + } + + /** + * Return a copy of the array, sorted by the result of a function applied to each item + */ + export function sortedBy(array: T1[], func: (val: T1) => T2, reverse = false): T1[] { + return sorted(array, (a, b) => cmp(func(a), func(b), reverse)); + } + + /** + * Return the minimum of an array transformed by a function + */ + export function minBy(array: T1[], func: (val: T1) => T2): T1 { + return array.reduce((a, b) => func(a) < func(b) ? a : b); + } + + /** + * Return the maximum of an array transformed by a function + */ + export function maxBy(array: T1[], func: (val: T1) => T2): T1 { + return array.reduce((a, b) => func(a) > func(b) ? a : b); + } + + /** + * Return a copy of an array, containing each value only once + */ + export function unique(array: T[]): T[] { + return array.filter((value, index, self) => self.indexOf(value) === index); + } + + /** + * Return the union of two arrays (items in either array) + */ + export function union(array1: T[], array2: T[]): T[] { + return array1.concat(difference(array2, array1)); + } + + /** + * Return the difference between two arrays (items in the first, but not in the second) + */ + export function difference(array1: T[], array2: T[]): T[] { + return array1.filter(value => !contains(array2, value)); + } + + /** + * Return the intersection of two arrays (items in both arrays) + */ + export function intersection(array1: T[], array2: T[]): T[] { + return array1.filter(value => contains(array2, value)); + } + + /** + * Return the disjunctive union of two arrays (items not in both arrays) + */ + export function disjunctunion(array1: T[], array2: T[]): T[] { + return difference(union(array1, array2), intersection(array1, array2)); + } +} diff --git a/src/lib/phaser.d.ts b/src/lib/phaser.d.ts index 1f4163e..181d640 100644 --- a/src/lib/phaser.d.ts +++ b/src/lib/phaser.d.ts @@ -33,481 +33,6 @@ declare type GridAlignConfig = { y?: number; }; -declare type JSONAnimation = { - /** - * The key that the animation will be associated with. i.e. sprite.animations.play(key) - */ - key: string; - /** - * A frame based animation (as opposed to a bone based animation) - */ - type: string; - /** - * [description] - */ - frames: JSONAnimationFrame[]; - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - */ - frameRate: integer; - /** - * How long the animation should play for in milliseconds. If not given its derived from frameRate. - */ - duration: integer; - /** - * Skip frames if the time lags, or always advanced anyway? - */ - skipMissedFrames: boolean; - /** - * Delay before starting playback. Value given in milliseconds. - */ - delay: integer; - /** - * Number of times to repeat the animation (-1 for infinity) - */ - repeat: integer; - /** - * Delay before the animation repeats. Value given in milliseconds. - */ - repeatDelay: integer; - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - */ - yoyo: boolean; - /** - * Should sprite.visible = true when the animation starts to play? - */ - showOnStart: boolean; - /** - * Should sprite.visible = false when the animation finishes? - */ - hideOnComplete: boolean; -}; - -declare type AnimationFrameConfig = { - /** - * The key that the animation will be associated with. i.e. sprite.animations.play(key) - */ - key: string; - /** - * [description] - */ - frame: string | number; - /** - * [description] - */ - duration?: number; - /** - * [description] - */ - visible?: boolean; -}; - -declare type AnimationConfig = { - /** - * The key that the animation will be associated with. i.e. sprite.animations.play(key) - */ - key?: string; - /** - * An object containing data used to generate the frames for the animation - */ - frames?: AnimationFrameConfig[]; - /** - * The key of the texture all frames of the animation will use. Can be overridden on a per frame basis. - */ - defaultTextureKey?: string; - /** - * The frame rate of playback in frames per second (default 24 if duration is null) - */ - frameRate?: integer; - /** - * How long the animation should play for in milliseconds. If not given its derived from frameRate. - */ - duration?: integer; - /** - * Skip frames if the time lags, or always advanced anyway? - */ - skipMissedFrames?: boolean; - /** - * Delay before starting playback. Value given in milliseconds. - */ - delay?: integer; - /** - * Number of times to repeat the animation (-1 for infinity) - */ - repeat?: integer; - /** - * Delay before the animation repeats. Value given in milliseconds. - */ - repeatDelay?: integer; - /** - * Should the animation yoyo? (reverse back down to the start) before repeating? - */ - yoyo?: boolean; - /** - * Should sprite.visible = true when the animation starts to play? - */ - showOnStart?: boolean; - /** - * Should sprite.visible = false when the animation finishes? - */ - hideOnComplete?: boolean; -}; - -declare type JSONAnimationFrame = { - /** - * The key of the Texture this AnimationFrame uses. - */ - key: string; - /** - * The key of the Frame within the Texture that this AnimationFrame uses. - */ - frame: string | integer; - /** - * Additional time (in ms) that this frame should appear for during playback. - */ - duration: number; -}; - -declare type JSONAnimationManager = { - /** - * [description] - */ - anims: JSONAnimation[]; - /** - * [description] - */ - globalTimeScale: number; -}; - -declare type GenerateFrameNamesConfig = { - /** - * [description] - */ - prefix?: string; - /** - * [description] - */ - start?: integer; - /** - * [description] - */ - end?: integer; - /** - * [description] - */ - suffix?: string; - /** - * [description] - */ - zeroPad?: integer; - /** - * [description] - */ - outputArray?: AnimationFrameConfig[]; - /** - * [description] - */ - frames?: boolean; -}; - -declare type GenerateFrameNumbersConfig = { - /** - * [description] - */ - start?: integer; - /** - * [description] - */ - end?: integer; - /** - * [description] - */ - first?: boolean; - /** - * [description] - */ - outputArray?: AnimationFrameConfig[]; - /** - * [description] - */ - frames?: boolean; -}; - -/** - * This callback type is completely empty, a no-operation. - */ -declare type NOOP = ()=>void; - -declare type BootCallback = (game: Phaser.Game)=>void; - -declare type FPSConfig = { - /** - * [description] - */ - min?: integer; - /** - * [description] - */ - target?: integer; - /** - * [description] - */ - forceSetTimeOut?: boolean; - /** - * [description] - */ - deltaHistory?: integer; - /** - * [description] - */ - panicMax?: integer; -}; - -declare type LoaderConfig = { - /** - * [description] - */ - baseURL?: string; - /** - * [description] - */ - path?: string; - /** - * [description] - */ - maxParallelDownloads?: integer; - /** - * [description] - */ - crossOrigin?: string | undefined; - /** - * [description] - */ - responseType?: string; - /** - * [description] - */ - async?: boolean; - /** - * [description] - */ - user?: string; - /** - * [description] - */ - password?: string; - /** - * [description] - */ - timeout?: integer; -}; - -declare type GameConfig = { - /** - * [description] - */ - width?: integer | string; - /** - * [description] - */ - height?: integer | string; - /** - * [description] - */ - zoom?: number; - /** - * [description] - */ - resolution?: number; - /** - * [description] - */ - type?: number; - /** - * [description] - */ - parent?: any; - /** - * Provide your own Canvas element for Phaser to use instead of creating one. - */ - canvas?: HTMLCanvasElement; - /** - * [description] - */ - canvasStyle?: string; - /** - * Provide your own Canvas Context for Phaser to use, instead of creating one. - */ - context?: CanvasRenderingContext2D; - /** - * [description] - */ - scene?: object; - /** - * [description] - */ - seed?: string[]; - /** - * [description] - */ - title?: string; - /** - * [description] - */ - url?: string; - /** - * [description] - */ - version?: string; - /** - * Automatically call window.focus() when the game boots. - */ - autoFocus?: boolean; - /** - * [description] - */ - input?: boolean | object; - /** - * [description] - */ - "input.keyboard"?: boolean; - /** - * [description] - */ - "input.keyboard.target"?: any; - /** - * [description] - */ - "input.mouse"?: boolean | object; - /** - * [description] - */ - "input.mouse.target"?: any; - /** - * [description] - */ - "input.touch"?: boolean; - /** - * [description] - */ - "input.activePointers"?: integer; - /** - * [description] - */ - "input.touch.target"?: any; - /** - * [description] - */ - "input.touch.capture"?: boolean; - /** - * [description] - */ - "input.gamepad"?: boolean | object; - /** - * [description] - */ - disableContextMenu?: boolean; - /** - * [description] - */ - banner?: boolean | object; - /** - * [description] - */ - "banner.hidePhaser"?: boolean; - /** - * [description] - */ - "banner.text"?: string; - /** - * [description] - */ - "banner.background"?: string[]; - /** - * [description] - */ - fps?: FPSConfig; - /** - * [description] - */ - "render.antialias"?: boolean; - /** - * [description] - */ - "render.pixelArt"?: boolean; - /** - * [description] - */ - "render.autoResize"?: boolean; - /** - * [description] - */ - "render.roundPixels"?: boolean; - /** - * [description] - */ - "render.transparent"?: boolean; - /** - * [description] - */ - "render.clearBeforeRender"?: boolean; - /** - * [description] - */ - "render.premultipliedAlpha"?: boolean; - /** - * [description] - */ - "render.preserveDrawingBuffer"?: boolean; - /** - * [description] - */ - "render.failIfMajorPerformanceCaveat"?: boolean; - /** - * "high-performance", "low-power" or "default" - */ - "render.powerPreference"?: string; - /** - * [description] - */ - backgroundColor?: string | number; - /** - * [description] - */ - callbacks?: object; - /** - * [description] - */ - "callbacks.preBoot"?: BootCallback; - /** - * [description] - */ - "callbacks.postBoot"?: BootCallback; - /** - * [description] - */ - loader?: LoaderConfig; - /** - * [description] - */ - images?: object; - /** - * [description] - */ - "images.default"?: string; - /** - * [description] - */ - "images.missing"?: string; - /** - * [description] - */ - physics?: object; -}; - -declare type TimeStepCallback = (time: number, average: number, interpolation: number)=>void; - declare type JSONCameraBounds = { /** * The horizontal position of camera @@ -580,67 +105,67 @@ declare type JSONCamera = { declare type InputJSONCameraObject = { /** - * [description] + * The name of the Camera. */ name?: string; /** - * [description] + * The horizontal position of the Camera viewport. */ x?: integer; /** - * [description] + * The vertical position of the Camera viewport. */ y?: integer; /** - * [description] + * The width of the Camera viewport. */ width?: integer; /** - * [description] + * The height of the Camera viewport. */ height?: integer; /** - * [description] + * The default zoom level of the Camera. */ zoom?: number; /** - * [description] + * The rotation of the Camera, in radians. */ rotation?: number; /** - * [description] + * Should the Camera round pixels before rendering? */ roundPixels?: boolean; /** - * [description] + * The horizontal scroll position of the Camera. */ scrollX?: number; /** - * [description] + * The vertical scroll position of the Camera. */ scrollY?: number; /** - * [description] + * A CSS color string controlling the Camera background color. */ backgroundColor?: false | string; /** - * [description] + * Defines the Camera bounds. */ bounds?: object; /** - * [description] + * The top-left extent of the Camera bounds. */ "bounds.x"?: number; /** - * [description] + * The top-left extent of the Camera bounds. */ "bounds.y"?: number; /** - * [description] + * The width of the Camera bounds. */ "bounds.width"?: number; /** - * [description] + * The height of the Camera bounds. */ "bounds.height"?: number; }; @@ -649,8 +174,12 @@ declare type CameraFadeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progre declare type CameraFlashCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; +declare type CameraPanCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, x: number, y: number)=>void; + declare type CameraShakeCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number)=>void; +declare type CameraZoomCallback = (camera: Phaser.Cameras.Scene2D.Camera, progress: number, zoom: number)=>void; + declare type FixedKeyControlConfig = { /** * The Camera that this Control will update. @@ -668,6 +197,10 @@ declare type FixedKeyControlConfig = { * The Key to be pressed that will move the Camera up. */ up?: Phaser.Input.Keyboard.Key; + /** + * The Key to be pressed that will move the Camera down. + */ + down?: Phaser.Input.Keyboard.Key; /** * The Key to be pressed that will zoom the Camera in. */ @@ -729,17 +262,507 @@ declare type SmoothedKeyControlConfig = { maxSpeed?: number | Object; }; -declare type RayDef = { +/** + * This callback type is completely empty, a no-operation. + */ +declare type NOOP = ()=>void; + +declare type BootCallback = (game: Phaser.Game)=>void; + +/** + * Config object containing various sound settings. + */ +declare type AudioConfig = { /** - * [description] + * Use HTML5 Audio instead of Web Audio. */ - origin: Phaser.Math.Vector3; + disableWebAudio?: boolean; /** - * [description] + * An existing Web Audio context. */ - direction: Phaser.Math.Vector3; + context?: AudioContext; + /** + * Disable all audio output. + */ + noAudio?: boolean; }; +declare type InputConfig = { + /** + * Keyboard input configuration. `true` uses the default configuration and `false` disables keyboard input. + */ + keyboard?: boolean | KeyboardInputConfig; + /** + * Mouse input configuration. `true` uses the default configuration and `false` disables mouse input. + */ + mouse?: boolean | MouseInputConfig; + /** + * Touch input configuration. `true` uses the default configuration and `false` disables touch input. + */ + touch?: boolean | TouchInputConfig; + /** + * Gamepad input configuration. `true` enables gamepad input. + */ + gamepad?: boolean | GamepadInputConfig; + /** + * The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}. + */ + activePointers?: integer; + /** + * The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. + */ + smoothFactor?: number; + /** + * Should Phaser use a queued input system for native DOM Events or not? + */ + inputQueue?: boolean; +}; + +declare type MouseInputConfig = { + /** + * Where the Mouse Manager listens for mouse input events. The default is the game canvas. + */ + target?: any; + /** + * Whether mouse input events have `preventDefault` called on them. + */ + capture?: boolean; +}; + +declare type KeyboardInputConfig = { + /** + * Where the Keyboard Manager listens for keyboard input events. + */ + target?: any; + /** + * `preventDefault` will be called on every non-modified key which has a key code in this array. By default it is empty. + */ + capture?: integer; +}; + +declare type TouchInputConfig = { + /** + * Where the Touch Manager listens for touch input events. The default is the game canvas. + */ + target?: any; + /** + * Whether touch input events have preventDefault() called on them. + */ + capture?: boolean; +}; + +declare type GamepadInputConfig = { + /** + * Where the Gamepad Manager listens for gamepad input events. + */ + target?: any; +}; + +declare type BannerConfig = { + /** + * Omit Phaser's name and version from the banner. + */ + hidePhaser?: boolean; + /** + * The color of the banner text. + */ + text?: string; + /** + * The background colors of the banner. + */ + background?: string[]; +}; + +declare type FPSConfig = { + /** + * The minimum acceptable rendering rate, in frames per second. + */ + min?: integer; + /** + * The optimum rendering rate, in frames per second. + */ + target?: integer; + /** + * Use setTimeout instead of requestAnimationFrame to run the game loop. + */ + forceSetTimeOut?: boolean; + /** + * Calculate the average frame delta from this many consecutive frame intervals. + */ + deltaHistory?: integer; + /** + * The amount of frames the time step counts before we trust the delta values again. + */ + panicMax?: integer; +}; + +declare type RenderConfig = { + /** + * When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. + */ + antialias?: boolean; + /** + * Sets `antialias` and `roundPixels` to true. This is the best setting for pixel-art games. + */ + pixelArt?: boolean; + /** + * Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. + */ + roundPixels?: boolean; + /** + * Whether the game canvas will be transparent. + */ + transparent?: boolean; + /** + * Whether the game canvas will be cleared between each rendering frame. + */ + clearBeforeRender?: boolean; + /** + * In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha. + */ + premultipliedAlpha?: boolean; + /** + * Let the browser abort creating a WebGL context if it judges performance would be unacceptable. + */ + failIfMajorPerformanceCaveat?: boolean; + /** + * "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. + */ + powerPreference?: string; + /** + * The default WebGL batch size. + */ + batchSize?: integer; + /** + * The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + maxLights?: integer; +}; + +declare type WidthHeight = { + /** + * The width. + */ + width?: integer; + /** + * The height. + */ + height?: integer; +}; + +declare type ScaleConfig = { + /** + * The base width of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size. + */ + width?: integer | string; + /** + * The base height of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size. + */ + height?: integer | string; + /** + * The zoom value of the game canvas. + */ + zoom?: Phaser.Scale.ZoomType | integer; + /** + * The rendering resolution of the canvas. This is reserved for future use and is currently ignored. + */ + resolution?: number; + /** + * The DOM element that will contain the game canvas, or its `id`. If undefined, or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment. + */ + parent?: HTMLElement | string; + /** + * Is the Scale Manager allowed to adjust the CSS height property of the parent and/or document body to be 100%? + */ + expandParent?: boolean; + /** + * The scale mode. + */ + mode?: Phaser.Scale.ScaleModeType; + /** + * The minimum width and height the canvas can be scaled down to. + */ + min?: WidthHeight; + /** + * The maximum width the canvas can be scaled up to. + */ + max?: WidthHeight; + /** + * Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. + */ + autoRound?: boolean; + /** + * Automatically center the canvas within the parent? + */ + autoCenter?: Phaser.Scale.CenterType; + /** + * How many ms should elapse before checking if the browser size has changed? + */ + resizeInterval?: integer; + /** + * The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. + */ + fullscreenTarget?: HTMLElement | string; +}; + +declare type CallbacksConfig = { + /** + * A function to run at the start of the boot sequence. + */ + preBoot?: BootCallback; + /** + * A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. + */ + postBoot?: BootCallback; +}; + +declare type LoaderConfig = { + /** + * A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. + */ + baseURL?: string; + /** + * A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. + */ + path?: string; + /** + * The maximum number of resources the loader will start loading at once. + */ + maxParallelDownloads?: integer; + /** + * 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. + */ + crossOrigin?: string | undefined; + /** + * The response type of the XHR request, e.g. `blob`, `text`, etc. + */ + responseType?: string; + /** + * Should the XHR request use async or not? + */ + async?: boolean; + /** + * Optional username for all XHR requests. + */ + user?: string; + /** + * Optional password for all XHR requests. + */ + password?: string; + /** + * Optional XHR timeout value, in ms. + */ + timeout?: integer; +}; + +declare type DOMContainerConfig = { + /** + * Create a div element in which DOM Elements will be contained. You must also provide a parent. + */ + createContainer?: boolean; + /** + * Place the DOM Container behind the Phaser Canvas. The default is to place it over the Canvas. + */ + behindCanvas?: boolean; +}; + +declare type ImagesConfig = { + /** + * URL to use for the 'default' texture. + */ + default?: string; + /** + * URL to use for the 'missing' texture. + */ + missing?: string; +}; + +declare type PhysicsConfig = { + /** + * The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'. + */ + default?: string; + /** + * Arcade Physics configuration. + */ + arcade?: ArcadeWorldConfig; + /** + * Impact Physics configuration. + */ + impact?: Phaser.Physics.Impact.WorldConfig; + /** + * Matter Physics configuration. + */ + matter?: object; +}; + +declare type PluginObjectItem = { + /** + * A key to identify the plugin in the Plugin Manager. + */ + key?: string; + /** + * The plugin itself. Usually a class/constructor. + */ + plugin?: any; + /** + * Whether the plugin should be started automatically. + */ + start?: boolean; + /** + * For a scene plugin, add the plugin to the scene's systems object under this key (`this.sys.KEY`, from the scene). + */ + systemKey?: string; + /** + * For a scene plugin, add the plugin to the scene object under this key (`this.KEY`, from the scene). + */ + sceneKey?: string; + /** + * If this plugin is to be injected into the Scene Systems, this is the property key map used. + */ + mapping?: string; + /** + * Arbitrary data passed to the plugin's init() method. + */ + data?: any; +}; + +declare type PluginObject = { + /** + * Global plugins to install. + */ + global?: PluginObjectItem[]; + /** + * Scene plugins to install. + */ + scene?: PluginObjectItem[]; + /** + * The default set of scene plugins (names). + */ + default?: string[]; + /** + * Plugins to *add* to the default set of scene plugins. + */ + defaultMerge?: string[]; +}; + +declare type GameConfig = { + /** + * The width of the game, in game pixels. + */ + width?: integer | string; + /** + * The height of the game, in game pixels. + */ + height?: integer | string; + /** + * Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc. + */ + zoom?: number; + /** + * The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution. + */ + resolution?: number; + /** + * Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS. + */ + type?: number; + /** + * The DOM element that will contain the game canvas, or its `id`. If undefined or if the named element doesn't exist, the game canvas is inserted directly into the document body. If `null` no parent will be used and you are responsible for adding the canvas to your environment. + */ + parent?: HTMLElement | string; + /** + * Provide your own Canvas element for Phaser to use instead of creating one. + */ + canvas?: HTMLCanvasElement; + /** + * CSS styles to apply to the game canvas instead of Phaser's default styles. + */ + canvasStyle?: string; + /** + * Provide your own Canvas Context for Phaser to use, instead of creating one. + */ + context?: CanvasRenderingContext2D; + /** + * A scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }. + */ + scene?: object; + /** + * Seed for the random number generator. + */ + seed?: string[]; + /** + * The title of the game. Shown in the browser console. + */ + title?: string; + /** + * The URL of the game. Shown in the browser console. + */ + url?: string; + /** + * The version of the game. Shown in the browser console. + */ + version?: string; + /** + * Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame. + */ + autoFocus?: boolean; + /** + * Input configuration, or `false` to disable all game input. + */ + input?: boolean | InputConfig; + /** + * Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click). + */ + disableContextMenu?: boolean; + /** + * Configuration for the banner printed in the browser console when the game starts. + */ + banner?: boolean | BannerConfig; + /** + * The DOM Container configuration object. + */ + dom?: DOMContainerConfig; + /** + * Game loop configuration. + */ + fps?: FPSConfig; + /** + * Game renderer configuration. + */ + render?: RenderConfig; + /** + * The background color of the game canvas. The default is black. + */ + backgroundColor?: string | number; + /** + * Optional callbacks to run before or after game boot. + */ + callbacks?: CallbacksConfig; + /** + * Loader configuration. + */ + loader?: LoaderConfig; + /** + * Images configuration. + */ + images?: ImagesConfig; + /** + * Physics configuration. + */ + physics?: object; + /** + * Plugins to install. + */ + plugins?: PluginObject | PluginObjectItem[]; + /** + * The Scale Manager configuration. + */ + scale?: ScaleConfig; +}; + +declare type TimeStepCallback = (time: number, average: number, interpolation: number)=>void; + declare type GenerateTextureRendererCallback = (canvas: HTMLCanvasElement, context: CanvasRenderingContext2D)=>void; declare type GenerateTextureConfig = { @@ -756,11 +779,11 @@ declare type GenerateTextureConfig = { */ palette?: Palette; /** - * [description] + * The width of each 'pixel' in the generated texture. */ pixelWidth?: number; /** - * [description] + * The height of each 'pixel' in the generated texture. */ pixelHeight?: number; /** @@ -854,11 +877,11 @@ declare type JSONEllipseCurve = { */ type: string; /** - * [description] + * The x coordinate of the ellipse. */ x: number; /** - * [description] + * The y coordinate of the ellipse. */ y: number; /** @@ -870,54 +893,54 @@ declare type JSONEllipseCurve = { */ yRadius: number; /** - * The start angle of ellipse. + * The start angle of the ellipse, in degrees. */ startAngle: integer; /** - * The end angle of ellipse. + * The end angle of the ellipse, in degrees. */ endAngle: integer; /** - * The clockwise of ellipse. + * Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) */ clockwise: boolean; /** - * The rotation of ellipse. + * The rotation of ellipse, in degrees. */ rotation: integer; }; declare type EllipseCurveConfig = { /** - * [description] + * The x coordinate of the ellipse. */ x?: number; /** - * [description] + * The y coordinate of the ellipse. */ y?: number; /** - * [description] + * The horizontal radius of the ellipse. */ xRadius?: number; /** - * [description] + * The vertical radius of the ellipse. */ yRadius?: number; /** - * [description] + * The start angle of the ellipse, in degrees. */ startAngle?: integer; /** - * [description] + * The end angle of the ellipse, in degrees. */ endAngle?: integer; /** - * [description] + * Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) */ clockwise?: boolean; /** - * [description] + * The rotation of the ellipse, in degrees. */ rotation?: integer; }; @@ -939,11 +962,11 @@ declare type JSONPath = { */ type: string; /** - * [description] + * The X coordinate of the curve's starting point. */ x: number; /** - * [description] + * The Y coordinate of the path's starting point. */ y: number; /** @@ -982,51 +1005,26 @@ declare type InputColorObject = { a?: number; }; -declare type ColorObject = ()=>void; - -declare namespace Phaser.Display.Color { +declare type ColorObject = { /** - * Interpolates color values + * The red color value in the range 0 to 255. */ - namespace Interpolate { - /** - * Interpolates between the two given color ranges over the length supplied. - * @param r1 Red value. - * @param g1 Blue value. - * @param b1 Green value. - * @param r2 Red value. - * @param g2 Blue value. - * @param b2 Green value. - * @param length Distance to interpolate over. Default 100. - * @param index Index to start from. Default 0. - */ - function RGBWithRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, length?: number, index?: number): ColorObject; + r: number; + /** + * The green color value in the range 0 to 255. + */ + g: number; + /** + * The blue color value in the range 0 to 255. + */ + b: number; + /** + * The alpha color value in the range 0 to 255. + */ + a: number; +}; - /** - * Interpolates between the two given color objects over the length supplied. - * @param color1 The first Color object. - * @param color2 The second Color object. - * @param length Distance to interpolate over. Default 100. - * @param index Index to start from. Default 0. - */ - function ColorWithColor(color1: Phaser.Display.Color, color2: Phaser.Display.Color, length?: number, index?: number): ColorObject; - - /** - * Interpolates between the Color object and color values over the length supplied. - * @param color1 The first Color object. - * @param r Red value. - * @param g Blue value. - * @param b Green value. - * @param length Distance to interpolate over. Default 100. - * @param index Index to start from. Default 0. - */ - function ColorWithRGB(color1: Phaser.Display.Color, r: number, g: number, b: number, length?: number, index?: number): ColorObject; - - } - -} - -declare type HSLColorObject = { +declare type HSVColorObject = { /** * The hue color value. A number between 0 and 1 */ @@ -1038,14 +1036,18 @@ declare type HSLColorObject = { /** * The lightness color value. A number between 0 and 1 */ - l: number; + v: number; }; declare type ContentLoadedCallback = ()=>void; declare type DisplayCallbackConfig = { /** - * The tint of the character being rendered. + * The Dynamic Bitmap Text object that owns this character being rendered. + */ + parent: Phaser.GameObjects.DynamicBitmapText; + /** + * The tint of the character being rendered. Always zero in Canvas. */ tint: Object; /** @@ -1238,164 +1240,16 @@ declare type JSONBitmapText = JSONGameObject & { */ fontSize: number; /** - * Adds/Removes spacing between characters + * Adds / Removes spacing between characters. */ letterSpacing: number; + /** + * The alignment of the text in a multi-line BitmapText object. + */ + align: integer; }; -declare namespace Phaser.GameObjects.Blitter { - type CreateCallback = (bob: Phaser.GameObjects.Blitter.Bob, index: integer)=>void; - - /** - * A Bob Game Object. - * - * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. - * - * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle - * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it - * must be a Frame within the Texture used by the parent Blitter. - * - * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will - * have their positions impacted by this change as well. - * - * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be - * handled via the Blitter parent. - */ - class Bob { - /** - * - * @param blitter The parent Blitter object is responsible for updating this Bob. - * @param x The horizontal position of this Game Object in the world, relative to the parent Blitter position. - * @param y The vertical position of this Game Object in the world, relative to the parent Blitter position. - * @param frame The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. - * @param visible Should the Bob render visible or not to start with? - */ - constructor(blitter: Phaser.GameObjects.Blitter, x: number, y: number, frame: string | integer, visible: boolean); - - /** - * The Blitter object that this Bob belongs to. - */ - parent: Phaser.GameObjects.Blitter; - - /** - * The x position of this Bob, relative to the x position of the Blitter. - */ - x: number; - - /** - * The y position of this Bob, relative to the y position of the Blitter. - */ - y: number; - - /** - * The frame that the Bob uses to render with. - * To change the frame use the `Bob.setFrame` method. - */ - protected frame: Phaser.Textures.Frame; - - /** - * A blank object which can be used to store data related to this Bob in. - */ - data: object; - - /** - * The horizontally flipped state of the Bob. - * A Bob that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Bob. - * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture. - */ - flipY: boolean; - - /** - * Changes the Texture Frame being used by this Bob. - * The frame must be part of the Texture the parent Blitter is using. - * If no value is given it will use the default frame of the Blitter parent. - * @param frame The frame to be used during rendering. - */ - setFrame(frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Blitter.Bob; - - /** - * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. - */ - resetFlip(): Phaser.GameObjects.Blitter.Bob; - - /** - * Resets this Bob. - * - * Changes the position to the values given, and optionally changes the frame. - * - * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. - * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. - * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. - */ - reset(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Blitter.Bob; - - /** - * Sets the horizontal flipped state of this Bob. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): Phaser.GameObjects.Blitter.Bob; - - /** - * Sets the vertical flipped state of this Bob. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): Phaser.GameObjects.Blitter.Bob; - - /** - * Sets the horizontal and vertical flipped state of this Bob. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): Phaser.GameObjects.Blitter.Bob; - - /** - * Sets the visibility of this Bob. - * - * An invisible Bob will skip rendering. - * @param value The visible state of the Game Object. - */ - setVisible(value: boolean): Phaser.GameObjects.Blitter.Bob; - - /** - * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * A Bob with alpha 0 will skip rendering. - * @param value The alpha value used for this Bob. Between 0 and 1. - */ - setAlpha(value: number): Phaser.GameObjects.Blitter.Bob; - - /** - * Destroys this Bob instance. - * Removes itself from the Blitter and clears the parent, frame and data properties. - */ - destroy(): void; - - /** - * The visible state of the Bob. - * - * An invisible Bob will skip rendering. - */ - visible: boolean; - - /** - * The alpha value of the Bob, between 0 and 1. - * - * A Bob with alpha 0 will skip rendering. - */ - alpha: number; - - } - -} +declare type CreateCallback = (bob: Phaser.GameObjects.Bob, index: integer)=>void; declare type GameObjectConfig = { /** @@ -1545,12 +1399,6 @@ declare type JSONGameObject = { declare type EachContainerCallback = (item: any, ...args: any[])=>void; -declare namespace Phaser.GameObjects.Graphics { - namespace Commands { - } - -} - /** * Graphics line style (or stroke style) settings. */ @@ -1558,15 +1406,15 @@ declare type GraphicsLineStyle = { /** * The stroke width. */ - width: number; + width?: number; /** * The stroke color. */ - color: number; + color?: number; /** * The stroke alpha. */ - alpha: number; + alpha?: number; }; /** @@ -1576,11 +1424,11 @@ declare type GraphicsFillStyle = { /** * The fill color. */ - color: number; + color?: number; /** * The fill alpha. */ - alpha: number; + alpha?: number; }; /** @@ -1590,11 +1438,11 @@ declare type GraphicsStyles = { /** * The style applied to shape outlines. */ - lineStyle: GraphicsLineStyle; + lineStyle?: GraphicsLineStyle; /** * The style applied to shape areas. */ - fillStyle: GraphicsFillStyle; + fillStyle?: GraphicsFillStyle; }; /** @@ -1604,11 +1452,30 @@ declare type GraphicsOptions = GraphicsStyles & { /** * The x coordinate of the Graphics. */ - x: number; + x?: number; /** * The y coordinate of the Graphics. */ - y: number; + y?: number; +}; + +declare type RoundedRectRadius = { + /** + * Top left + */ + tl?: number; + /** + * Top right + */ + tr?: number; + /** + * Bottom right + */ + br?: number; + /** + * Bottom left + */ + bl?: number; }; declare type GroupCallback = (item: Phaser.GameObjects.GameObject)=>void; @@ -1619,7 +1486,7 @@ declare type GroupConfig = { /** * Sets {@link Phaser.GameObjects.Group#classType}. */ - classType?: object; + classType?: GroupClassTypeConstructor; /** * Sets {@link Phaser.GameObjects.Group#active}. */ @@ -1669,7 +1536,7 @@ declare type GroupCreateConfig = { /** * The class of each new Game Object. */ - classType?: object; + classType?: GroupClassTypeConstructor; /** * The texture key of each new Game Object. */ @@ -1776,6 +1643,11 @@ declare type GroupCreateConfig = { gridAlign?: false | GridAlignConfig; }; +/** + * A constructor function (class) that can be assigned to `classType`. + */ +declare type GroupClassTypeConstructor = (scene: Phaser.Scene, x: number, y: number, texture: string, frame?: string | integer)=>void; + declare type LightForEach = (light: Phaser.GameObjects.Light)=>void; /** @@ -1868,18 +1740,18 @@ declare type EmitterOpSteppedConfig = { declare type EmitterOpCustomEmitConfig = { /** - * [description] + * A callback that is invoked each time the emitter emits a particle. */ onEmit: EmitterOpOnEmitCallback; }; declare type EmitterOpCustomUpdateConfig = { /** - * [description] + * A callback that is invoked each time the emitter emits a particle. */ onEmit?: EmitterOpOnEmitCallback; /** - * [description] + * A callback that is invoked each time the emitter updates. */ onUpdate: EmitterOpOnUpdateCallback; }; @@ -1894,11 +1766,11 @@ declare type GravityWellConfig = { */ y?: number; /** - * The power of the Gravity Well. + * The strength of the gravity force - larger numbers produce a stronger force. */ power?: number; /** - * [description] + * The minimum distance for which the gravity force is calculated. */ epsilon?: number; /** @@ -2006,7 +1878,7 @@ declare type ParticleEmitterConfig = { /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#blendMode}. */ - blendMode?: integer; + blendMode?: Phaser.BlendModes | string; /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#deathCallbackScope} and {@link Phaser.GameObjects.Particles.ParticleEmitter#emitCallbackScope}. */ @@ -2078,7 +1950,7 @@ declare type ParticleEmitterConfig = { /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#particleClass}. */ - particleClass?: Phaser.GameObjects.Particles.Particle; + particleClass?: typeof Phaser.GameObjects.Particles.Particle; /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#radial}. */ @@ -2206,7 +2078,7 @@ declare type ParticleEmitterConfig = { /** * Sets {@link Phaser.GameObjects.Particles.ParticleEmitter#frames}. */ - frames?: number | number[] | string | string[] | Phaser.Textures.Frame | Phaser.Textures.Frame[] | ParticleEmitterFrameConfig; + frame?: number | number[] | string | string[] | Phaser.Textures.Frame | Phaser.Textures.Frame[] | ParticleEmitterFrameConfig; }; declare type ParticleEmitterFrameConfig = { @@ -2230,7 +2102,7 @@ declare type DeathZoneSource = { contains: DeathZoneSourceCallback; }; -declare type EdgeZoneSourceCallback = (quantity: integer, stepRate?: integer)=>void; +declare type EdgeZoneSourceCallback = (quantity: integer, stepRate?: number)=>void; declare type EdgeZoneSource = { /** @@ -2248,35 +2120,38 @@ declare type RandomZoneSource = { getRandomPoint: RandomZoneSourceCallback; }; +/** + * Settings for a PathFollower. + */ declare type PathConfig = { /** - * [description] + * The duration of the path follow. */ duration: number; /** - * [description] + * The start position of the path follow, between 0 and 1. */ from: number; /** - * [description] + * The end position of the path follow, between 0 and 1. */ to: number; /** - * [description] + * Whether to position the PathFollower on the Path using its path offset. */ positionOnPath?: boolean; /** - * [description] + * Should the PathFollower automatically rotate to point in the direction of the Path? */ rotateToPath?: boolean; /** - * [description] + * If the PathFollower is rotating to match the Path, this value is added to the rotation value. This allows you to rotate objects to a path but control the angle of the rotation as well. */ rotationOffset?: number; /** - * [description] + * Current start position of the path follow, between 0 and 1. */ - verticalAdjust?: boolean; + startAt?: number; }; declare type RenderTextureConfig = { @@ -2298,320 +2173,39 @@ declare type RenderTextureConfig = { height?: number; }; +declare type SpriteConfig = GameObjectConfig & { + /** + * The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + */ + key?: string; + /** + * An optional frame from the Texture this Game Object is rendering with. + */ + frame?: number | string; +}; + /** * A custom function that will be responsible for wrapping the text. */ declare type TextStyleWordWrapCallback = (text: string, textObject: Phaser.GameObjects.Text)=>void; -declare namespace Phaser.GameObjects.Text { +/** + * Font metrics for a Text Style object. + */ +declare type BitmapTextMetrics = { /** - * [description] + * The ascent of the font. */ - class TextStyle { - /** - * - * @param text The Text object that this TextStyle is styling. - * @param style [description] - */ - constructor(text: Phaser.GameObjects.Text, style: object); - - /** - * The Text object that this TextStyle is styling. - */ - parent: Phaser.GameObjects.Text; - - /** - * [description] - */ - fontFamily: string; - - /** - * [description] - */ - fontSize: string; - - /** - * [description] - */ - fontStyle: string; - - /** - * [description] - */ - backgroundColor: string; - - /** - * [description] - */ - color: string; - - /** - * [description] - */ - stroke: string; - - /** - * [description] - */ - strokeThickness: number; - - /** - * [description] - */ - shadowOffsetX: number; - - /** - * [description] - */ - shadowOffsetY: number; - - /** - * [description] - */ - shadowColor: string; - - /** - * [description] - */ - shadowBlur: number; - - /** - * [description] - */ - shadowStroke: boolean; - - /** - * [description] - */ - shadowFill: boolean; - - /** - * [description] - */ - align: string; - - /** - * [description] - */ - maxLines: integer; - - /** - * [description] - */ - fixedWidth: number; - - /** - * [description] - */ - fixedHeight: number; - - /** - * [description] - */ - rtl: boolean; - - /** - * [description] - */ - testString: string; - - /** - * The amount of horizontal padding adding to the width of the text when calculating the font metrics. - */ - baselineX: number; - - /** - * The amount of vertical padding adding to the width of the text when calculating the font metrics. - */ - baselineY: number; - - /** - * [description] - * @param style [description] - * @param updateText [description] Default true. - */ - setStyle(style: CSSStyleRule, updateText?: boolean): Phaser.GameObjects.Text; - - /** - * [description] - * @param canvas [description] - * @param context [description] - */ - syncFont(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; - - /** - * [description] - * @param canvas [description] - * @param context [description] - */ - syncStyle(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; - - /** - * [description] - * @param context [description] - * @param enabled [description] - */ - syncShadow(context: CanvasRenderingContext2D, enabled: boolean): void; - - /** - * [description] - * @param recalculateMetrics [description] - */ - update(recalculateMetrics: boolean): Phaser.GameObjects.Text; - - /** - * [description] - * @param font [description] - */ - setFont(font: string | object): Phaser.GameObjects.Text; - - /** - * [description] - * @param family [description] - */ - setFontFamily(family: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param style [description] - */ - setFontStyle(style: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param size [description] - */ - setFontSize(size: number | string): Phaser.GameObjects.Text; - - /** - * [description] - * @param string [description] - */ - setTestString(string: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param width [description] - * @param height [description] - */ - setFixedSize(width: number, height: number): Phaser.GameObjects.Text; - - /** - * [description] - * @param color [description] - */ - setBackgroundColor(color: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param color [description] - */ - setFill(color: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param color [description] - */ - setColor(color: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param color [description] - * @param thickness [description] - */ - setStroke(color: string, thickness: number): Phaser.GameObjects.Text; - - /** - * [description] - * @param x [description] Default 0. - * @param y [description] Default 0. - * @param color [description] Default '#000'. - * @param blur [description] Default 0. - * @param shadowStroke [description] Default false. - * @param shadowFill [description] Default true. - */ - setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; - - /** - * [description] - * @param x [description] Default 0. - * @param y [description] Default 0. - */ - setShadowOffset(x?: number, y?: number): Phaser.GameObjects.Text; - - /** - * [description] - * @param color [description] Default '#000'. - */ - setShadowColor(color?: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param blur [description] Default 0. - */ - setShadowBlur(blur?: number): Phaser.GameObjects.Text; - - /** - * [description] - * @param enabled [description] - */ - setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; - - /** - * [description] - * @param enabled [description] - */ - setShadowFill(enabled: boolean): Phaser.GameObjects.Text; - - /** - * Set the width (in pixels) to use for wrapping lines. Pass in null to remove wrapping by width. - * @param width The maximum width of a line in pixels. Set to null to remove wrapping. - * @param useAdvancedWrap Whether or not to use the advanced wrapping - * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, - * spaces and whitespace are left as is. Default false. - */ - setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; - - /** - * Set a custom callback for wrapping lines. Pass in null to remove wrapping by callback. - * @param callback A custom function that will be responsible for wrapping the - * text. It will receive two arguments: text (the string to wrap), textObject (this Text - * instance). It should return the wrapped lines either as an array of lines or as a string with - * newline characters in place to indicate where breaks should happen. - * @param scope The scope that will be applied when the callback is invoked. Default null. - */ - setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; - - /** - * [description] - * @param align [description] - */ - setAlign(align: string): Phaser.GameObjects.Text; - - /** - * [description] - * @param max [description] Default 0. - */ - setMaxLines(max?: integer): Phaser.GameObjects.Text; - - /** - * [description] - */ - getTextMetrics(): object; - - /** - * [description] - */ - toJSON(): object; - - /** - * [description] - */ - destroy(): void; - - } - -} + ascent: number; + /** + * The descent of the font. + */ + descent: number; + /** + * The size of the font. + */ + fontSize: number; +}; declare type TileSprite = GameObjectConfig & { /** @@ -2623,13 +2217,13 @@ declare type TileSprite = GameObjectConfig & { */ y?: number; /** - * The width of the Tile Sprite. + * The width of the Tile Sprite. If zero it will use the size of the texture frame. */ - width?: number; + width?: integer; /** - * The height of the Tile Sprite. + * The height of the Tile Sprite. If zero it will use the size of the texture frame. */ - height?: number; + height?: integer; /** * The key of the Texture this Tile Sprite will use to render with, as stored in the Texture Manager. */ @@ -2670,40 +2264,6 @@ declare type InputPluginContainer = { mapping?: string; }; -declare namespace Phaser.Input.InputPluginCache { - /** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * @param key A reference used to get this plugin from the plugin cache. - * @param plugin The plugin to be stored. Should be the core object, not instantiated. - * @param mapping If this plugin is to be injected into the Input Plugin, this is the property key used. - * @param settingsKey The key in the Scene Settings to check to see if this plugin should install or not. - * @param configKey The key in the Game Config to check to see if this plugin should install or not. - */ - function register(key: string, plugin: Function, mapping: string, settingsKey: string, configKey: string): void; - - /** - * Returns the input plugin object from the cache based on the given key. - * @param key The key of the input plugin to get. - */ - function getCore(key: string): InputPluginContainer; - - /** - * Installs all of the registered Input Plugins into the given target. - * @param target The target InputPlugin to install the plugins into. - */ - function install(target: Phaser.Input.InputPlugin): void; - - /** - * Removes an input plugin based on the given key. - * @param key The key of the input plugin to remove. - */ - function remove(key: string): void; - -} - declare type KeyboardKeydownCallback = (event: KeyboardEvent)=>void; declare type KeyComboConfig = { @@ -2725,33 +2285,6 @@ declare type KeyComboConfig = { deleteOnMatch?: boolean; }; -declare type CursorKeys = { - /** - * A Key object mapping to the UP arrow key. - */ - up?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the DOWN arrow key. - */ - down?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the LEFT arrow key. - */ - left?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the RIGHT arrow key. - */ - right?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the SPACE BAR key. - */ - space?: Phaser.Input.Keyboard.Key; - /** - * A Key object mapping to the SHIFT key. - */ - shift?: Phaser.Input.Keyboard.Key; -}; - declare type FileConfig = { /** * The file type string (image, json, etc) for sorting within the Loader. @@ -2787,37 +2320,6 @@ declare type FileConfig = { config?: any; }; -declare namespace Phaser.Loader.AudioSpriteFile { - /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. - */ - function onFileComplete(file: Phaser.Loader.File): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - function addToCache(): void; - -} - -declare namespace Phaser.Loader.FileTypesManager { - /** - * Static method called when a LoaderPlugin is created. - * - * Loops through the local types object and injects all of them as - * properties into the LoaderPlugin instance. - * @param loader The LoaderPlugin to install the types into. - */ - function register(loader: Phaser.Loader.LoaderPlugin): void; - - /** - * Removed all associated file types. - */ - function destroy(): void; - -} - declare type XHRSettingsObject = { /** * The response type of the XHR request, i.e. `blob`, `text`, etc. @@ -3003,43 +2505,52 @@ declare namespace Phaser { function IncY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param circle [description] - * @param startAngle [description] Default 0. - * @param endAngle [description] Default 6.28. + * @param circle The Circle to position the Game Objects on. + * @param startAngle Optional angle to start position from, in radians. Default 0. + * @param endAngle Optional angle to stop position at, in radians. Default 6.28. */ function PlaceOnCircle(items: G, circle: Phaser.Geom.Circle, startAngle?: number, endAngle?: number): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param ellipse [description] - * @param startAngle [description] Default 0. - * @param endAngle [description] Default 6.28. + * @param ellipse The Ellipse to position the Game Objects on. + * @param startAngle Optional angle to start position from, in radians. Default 0. + * @param endAngle Optional angle to stop position at, in radians. Default 6.28. */ function PlaceOnEllipse(items: G, ellipse: Phaser.Geom.Ellipse, startAngle?: number, endAngle?: number): G; /** - * [description] + * Positions an array of Game Objects on evenly spaced points of a Line. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param line [description] + * @param line The Line to position the Game Objects on. */ function PlaceOnLine(items: G, line: Phaser.Geom.Line): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param rect [description] - * @param shift [description] Default 1. + * @param rect The Rectangle to position the Game Objects on. + * @param shift An optional positional offset. Default 1. */ function PlaceOnRectangle(items: G, rect: Phaser.Geom.Rectangle, shift?: integer): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param triangle [description] - * @param stepRate [description] Default 1. + * @param triangle The Triangle to position the Game Objects on. + * @param stepRate An optional step rate, to increase or decrease the packing of the Game Objects on the lines. Default 1. */ function PlaceOnTriangle(items: G, triangle: Phaser.Geom.Triangle, stepRate?: number): G; @@ -3084,37 +2595,45 @@ declare namespace Phaser { function PropertyValueSet(items: G, key: string, value: number, step?: number, index?: integer, direction?: integer): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param circle [description] + * @param circle The Circle to position the Game Objects within. */ function RandomCircle(items: G, circle: Phaser.Geom.Circle): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param ellipse [description] + * @param ellipse The Ellipse to position the Game Objects within. */ function RandomEllipse(items: G, ellipse: Phaser.Geom.Ellipse): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param line [description] + * @param line The Line to position the Game Objects randomly on. */ function RandomLine(items: G, line: Phaser.Geom.Line): G; /** - * [description] + * Takes an array of Game Objects and positions them at random locations within the Ellipse. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param rect [description] + * @param rect The Rectangle to position the Game Objects within. */ function RandomRectangle(items: G, rect: Phaser.Geom.Rectangle): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param triangle [description] + * @param triangle The Triangle to position the Game Objects within. */ function RandomTriangle(items: G, triangle: Phaser.Geom.Triangle): G; @@ -3142,7 +2661,7 @@ declare namespace Phaser { function RotateAround(items: G, point: object, angle: number): G; /** - * [description] + * Rotates an array of Game Objects around a point by the given angle and distance. * @param items An array of Game Objects. The contents of this array are updated by this Action. * @param point Any object with public `x` and `y` properties. * @param angle The angle to rotate by, in radians. @@ -3242,10 +2761,10 @@ declare namespace Phaser { function SetDepth(items: G, value: number, step?: number, index?: integer, direction?: integer): G; /** - * [description] + * Passes all provided Game Objects to the Input Manager to enable them for input with identical areas and callbacks. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param hitArea [description] - * @param hitAreaCallback [description] + * @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 hitAreaCallback A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. */ function SetHitArea(items: G, hitArea: any, hitAreaCallback: HitAreaCallback): G; @@ -3329,12 +2848,12 @@ declare namespace Phaser { function SetScaleY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; /** - * [description] + * 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. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param topLeft [description] - * @param topRight [description] - * @param bottomLeft [description] - * @param bottomRight [description] + * @param 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 topRight The tint to be applied to top-right corner of item. + * @param bottomLeft The tint to be applied to the bottom-left corner of item. + * @param bottomRight The tint to be applied to the bottom-right corner of item. */ function SetTint(items: G, topLeft: number, topRight?: number, bottomLeft?: number, bottomRight?: number): G; @@ -3398,15 +2917,17 @@ declare namespace Phaser { function SetY(items: G, value: number, step?: number, index?: integer, direction?: integer): G; /** - * Iterate through items changing the position of each element to - * be that of the element that came before it in the array (or after it if direction = 1) + * Iterate through the items array changing the position of each element to be that of the element that came before + * it in the array (or after it if direction = 1) + * * The first items position is set to x/y. + * * The final x/y coords are returned * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param x [description] - * @param y [description] - * @param direction [description] Default 0. - * @param output [description] + * @param x The x coordinate to place the first item in the array at. + * @param y The y coordinate to place the first item in the array at. + * @param direction The iteration direction. 0 = first to last and 1 = last to first. Default 0. + * @param output An optional objec to store the final objects position in. */ function ShiftPosition(items: G, x: number, y: number, direction?: integer, output?: O): O; @@ -3417,37 +2938,51 @@ declare namespace Phaser { function Shuffle(items: G): G; /** - * [description] + * Smootherstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param property [description] - * @param min [description] - * @param max [description] - * @param inc [description] + * @param property The property of the Game Object to interpolate. + * @param min The minimum interpolation value. + * @param max The maximum interpolation value. + * @param inc Should the values be incremented? `true` or set (`false`) Default false. */ - function SmootherStep(items: G, property: string, min: number, max: number, inc: number): G; + function SmootherStep(items: G, property: string, min: number, max: number, inc?: boolean): G; /** - * [description] + * Smoothstep is a sigmoid-like interpolation and clamping function. + * + * The function depends on three parameters, the input x, the "left edge" and the "right edge", with the left edge being assumed smaller than the right edge. The function receives a real number x as an argument and returns 0 if x is less than or equal to the left edge, 1 if x is greater than or equal to the right edge, and smoothly interpolates, using a Hermite polynomial, between 0 and 1 otherwise. The slope of the smoothstep function is zero at both edges. This is convenient for creating a sequence of transitions using smoothstep to interpolate each segment as an alternative to using more sophisticated or expensive interpolation techniques. * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param property [description] - * @param min [description] - * @param max [description] - * @param inc [description] + * @param property The property of the Game Object to interpolate. + * @param min The minimum interpolation value. + * @param max The maximum interpolation value. + * @param inc Should the values be incremented? `true` or set (`false`) Default false. */ - function SmoothStep(items: G, property: string, min: number, max: number, inc: number): G; + function SmoothStep(items: G, property: string, min: number, max: number, inc?: boolean): G; /** - * [description] + * Takes an array of Game Objects and then modifies their `property` so the value equals, or is incremented, the + * calculated spread value. + * + * The spread value is derived from the given `min` and `max` values and the total number of items in the array.//#endregion + * + * For example, to cause an array of Sprites to change in alpha from 0 to 1 you could call: + * + * ```javascript + * Phaser.Actions.Spread(itemsArray, 'alpha', 0, 1); + * ``` * @param items An array of Game Objects. The contents of this array are updated by this Action. - * @param property [description] - * @param min [description] - * @param max [description] - * @param inc [description] Default false. + * @param property The property of the Game Object to spread. + * @param min The minimum value. + * @param max The maximum value. + * @param inc Should the values be incremented? `true` or set (`false`) Default false. */ - function Spread(items: G, property: string, min: number, max: number, inc?: number): G; + function Spread(items: G, property: string, min: number, max: number, inc?: boolean): G; /** - * [description] + * Takes an array of Game Objects and toggles the visibility of each one. + * Those previously `visible = false` will become `visible = true`, and vice versa. * @param items An array of Game Objects. The contents of this array are updated by this Action. */ function ToggleVisible(items: G): G; @@ -3472,22 +3007,22 @@ declare namespace Phaser { * Game Objects have the Animation Component, which are like playheads to global Animations (these objects) * So multiple Game Objects can have playheads all pointing to this one Animation instance. */ - class Animation { + class Animation extends Phaser.Events.EventEmitter { /** * - * @param manager [description] - * @param key [description] - * @param config [description] + * @param manager A reference to the global Animation Manager + * @param key The unique identifying string for this animation. + * @param config The Animation configuration. */ - constructor(manager: Phaser.Animations.AnimationManager, key: string, config: AnimationConfig); + constructor(manager: Phaser.Animations.AnimationManager, key: string, config: Phaser.Animations.Types.Animation); /** - * A reference to the global Animation Manager + * A reference to the global Animation Manager. */ manager: Phaser.Animations.AnimationManager; /** - * The unique identifying string for this animation + * The unique identifying string for this animation. */ key: string; @@ -3497,7 +3032,7 @@ declare namespace Phaser { type: string; /** - * Extract all the frame data into the frames array + * Extract all the frame data into the frames array. */ frames: Phaser.Animations.AnimationFrame[]; @@ -3534,22 +3069,22 @@ declare namespace Phaser { repeat: integer; /** - * The delay in ms before the a repeat playthrough starts. + * The delay in ms before the a repeat play starts. */ repeatDelay: integer; /** - * Should the animation yoyo? (reverse back down to the start) before repeating? + * Should the animation yoyo (reverse back down to the start) before repeating? */ yoyo: boolean; /** - * Should sprite.visible = true when the animation starts to play? + * Should the GameObject's `visible` property be set to `true` when the animation starts to play? */ showOnStart: boolean; /** - * Should sprite.visible = false when the animation finishes? + * Should the GameObject's `visible` property be set to `false` when the animation finishes? */ hideOnComplete: boolean; @@ -3562,14 +3097,14 @@ declare namespace Phaser { * Add frames to the end of the animation. * @param config [description] */ - addFrame(config: string | AnimationFrameConfig[]): Phaser.Animations.Animation; + addFrame(config: string | Phaser.Animations.Types.AnimationFrame[]): Phaser.Animations.Animation; /** * Add frame/s into the animation. - * @param index [description] + * @param index The index to insert the frame at within the animation. * @param config [description] */ - addFrameAt(index: integer, config: string | AnimationFrameConfig[]): Phaser.Animations.Animation; + addFrameAt(index: integer, config: string | Phaser.Animations.Types.AnimationFrame[]): Phaser.Animations.Animation; /** * Check if the given frame index is valid. @@ -3602,7 +3137,7 @@ declare namespace Phaser { * @param frames [description] * @param defaultTextureKey [description] */ - getFrames(textureManager: Phaser.Textures.TextureManager, frames: string | AnimationFrameConfig[], defaultTextureKey?: string): Phaser.Animations.AnimationFrame[]; + getFrames(textureManager: Phaser.Textures.TextureManager, frames: string | Phaser.Animations.Types.AnimationFrame[], defaultTextureKey?: string): Phaser.Animations.AnimationFrame[]; /** * [description] @@ -3622,6 +3157,11 @@ declare namespace Phaser { */ nextFrame(component: Phaser.GameObjects.Components.Animation): void; + /** + * Returns the animation last frame. + */ + getLastFrame(): Phaser.Animations.AnimationFrame; + /** * [description] * @param component [description] @@ -3648,15 +3188,15 @@ declare namespace Phaser { repeatAnimation(component: Phaser.GameObjects.Components.Animation): void; /** - * [description] + * Sets the texture frame the animation uses for rendering. * @param component [description] */ setFrame(component: Phaser.GameObjects.Components.Animation): void; /** - * [description] + * Converts the animation data to JSON. */ - toJSON(): JSONAnimation; + toJSON(): Phaser.Animations.Types.JSONAnimation; /** * [description] @@ -3684,8 +3224,7 @@ declare namespace Phaser { * A single frame in an Animation sequence. * * An AnimationFrame consists of a reference to the Texture it uses for rendering, references to other - * frames in the animation, and index data. It also has the ability to fire its own `onUpdate` callback - * and modify the animation timing. + * frames in the animation, and index data. It also has the ability to modify the animation timing. * * AnimationFrames are generated automatically by the Animation class. */ @@ -3754,7 +3293,7 @@ declare namespace Phaser { /** * Generates a JavaScript object suitable for converting to JSON. */ - toJSON(): JSONAnimationFrame; + toJSON(): Phaser.Animations.Types.JSONAnimationFrame; /** * Destroys this object by removing references to external resources and callbacks. @@ -3775,141 +3314,3022 @@ declare namespace Phaser { class AnimationManager extends Phaser.Events.EventEmitter { /** * - * @param game [description] + * @param game A reference to the Phaser.Game instance. */ constructor(game: Phaser.Game); /** - * [description] + * A reference to the Phaser.Game instance. */ protected game: Phaser.Game; /** - * [description] + * A reference to the Texture Manager. */ protected textureManager: Phaser.Textures.TextureManager; /** - * [description] + * The global time scale of the Animation Manager. + * + * This scales the time delta between two frames, thus influencing the speed of time for the Animation Manager. */ globalTimeScale: number; /** - * [description] + * The Animations registered in the Animation Manager. + * + * This map should be modified with the {@link #add} and {@link #create} methods of the Animation Manager. */ protected anims: Phaser.Structs.Map; /** - * [description] + * Whether the Animation Manager is paused along with all of its Animations. */ paused: boolean; /** - * [description] + * The name of this Animation Manager. */ name: string; /** - * [description] + * Registers event listeners after the Game boots. */ boot(): void; /** - * [description] - * @param key [description] - * @param animation [description] + * Adds an existing Animation to the Animation Manager. + * @param key The key under which the Animation should be added. The Animation will be updated with it. Must be unique. + * @param animation The Animation which should be added to the Animation Manager. */ add(key: string, animation: Phaser.Animations.Animation): Phaser.Animations.AnimationManager; /** - * [description] - * @param config [description] + * Checks to see if the given key is already in use within the Animation Manager or not. + * + * Animations are global. Keys created in one scene can be used from any other Scene in your game. They are not Scene specific. + * @param key The key of the Animation to check. */ - create(config: AnimationConfig): Phaser.Animations.Animation; + exists(key: string): boolean; + + /** + * Creates a new Animation and adds it to the Animation Manager. + * + * Animations are global. Once created, you can use them in any Scene in your game. They are not Scene specific. + * + * If an invalid key is given this method will return `false`. + * + * If you pass the key of an animation that already exists in the Animation Manager, that animation will be returned. + * + * A brand new animation is only created if the key is valid and not already in use. + * + * If you wish to re-use an existing key, call `AnimationManager.remove` first, then this method. + * @param config The configuration settings for the Animation. + */ + create(config: Phaser.Animations.Types.Animation): Phaser.Animations.Animation | false; + + /** + * Loads this Animation Manager's Animations and settings from a JSON object. + * @param data The JSON object to parse. + * @param clearCurrentAnimations If set to `true`, the current animations will be removed (`anims.clear()`). If set to `false` (default), the animations in `data` will be added. Default false. + */ + fromJSON(data: string | Phaser.Animations.Types.JSONAnimations | Phaser.Animations.Types.JSONAnimation, clearCurrentAnimations?: boolean): Phaser.Animations.Animation[]; /** * [description] - * @param data [description] - * @param clearCurrentAnimations [description] Default false. + * @param key The key for the texture containing the animation frames. + * @param config The configuration object for the animation frame names. */ - fromJSON(data: string | JSONAnimationManager | JSONAnimation, clearCurrentAnimations?: boolean): Phaser.Animations.Animation[]; + generateFrameNames(key: string, config?: Phaser.Animations.Types.GenerateFrameNames): Phaser.Animations.Types.AnimationFrame[]; /** - * [description] - * @param key [description] - * @param config [description] + * Generate an array of {@link Phaser.Animations.Types.AnimationFrame} objects from a texture key and configuration object. + * + * Generates objects with numbered frame names, as configured by the given {@link Phaser.Animations.Types.GenerateFrameNumbers}. + * @param key The key for the texture containing the animation frames. + * @param config The configuration object for the animation frames. */ - generateFrameNames(key: string, config?: GenerateFrameNamesConfig): AnimationFrameConfig[]; + generateFrameNumbers(key: string, config: Phaser.Animations.Types.GenerateFrameNumbers): Phaser.Animations.Types.AnimationFrame[]; /** - * [description] - * @param key [description] - * @param config [description] - */ - generateFrameNumbers(key: string, config: GenerateFrameNumbersConfig): AnimationFrameConfig[]; - - /** - * [description] - * @param key [description] + * Get an Animation. + * @param key The key of the Animation to retrieve. */ get(key: string): Phaser.Animations.Animation; /** - * Load an Animation into a Game Objects Animation Component. - * @param child [description] - * @param key [description] - * @param startFrame [description] + * Load an Animation into a Game Object's Animation Component. + * @param child The Game Object to load the animation into. + * @param key The key of the animation to load. + * @param startFrame The name of a start frame to set on the loaded animation. */ load(child: Phaser.GameObjects.GameObject, key: string, startFrame?: string | integer): Phaser.GameObjects.GameObject; /** - * [description] + * Pause all animations. */ pauseAll(): Phaser.Animations.AnimationManager; /** - * [description] - * @param key [description] - * @param child [description] + * Play an animation on the given Game Objects that have an Animation Component. + * @param key The key of the animation to play on the Game Object. + * @param child The Game Objects to play the animation on. */ - play(key: string, child: Phaser.GameObjects.GameObject): Phaser.Animations.AnimationManager; + play(key: string, child: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.Animations.AnimationManager; /** - * [description] - * @param key [description] + * Remove an animation. + * @param key The key of the animation to remove. */ remove(key: string): Phaser.Animations.Animation; /** - * [description] + * Resume all paused animations. */ resumeAll(): Phaser.Animations.AnimationManager; /** - * Takes an array of Game Objects that have the Animation Component and then + * Takes an array of Game Objects that have an Animation Component and then * starts the given animation playing on them, each one offset by the * `stagger` amount given to this method. * @param key The key of the animation to play on the Game Objects. - * @param children An array of Game Objects to play the animation on. They must have the Animation Component. + * @param children An array of Game Objects to play the animation on. They must have an Animation Component. * @param stagger The amount of time, in milliseconds, to offset each play time by. Default 0. */ - staggerPlay(key: string, children: Phaser.GameObjects.GameObject[], stagger?: number): G; + staggerPlay(key: string, children: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[], stagger?: number): G; /** - * [description] + * Get the animation data as javascript object by giving key, or get the data of all animations as array of objects, if key wasn't provided. * @param key [description] */ - toJSON(key: string): JSONAnimationManager; + toJSON(key: string): Phaser.Animations.Types.JSONAnimations; /** - * [description] + * Destroy this Animation Manager and clean up animation definitions and references to other objects. + * This method should not be called directly. It will be called automatically as a response to a `destroy` event from the Phaser.Game instance. */ destroy(): void; } + namespace Events { + /** + * The Add Animation Event. + * + * This event is dispatched when a new animation is added to the global Animation Manager. + * + * This can happen either as a result of an animation instance being added to the Animation Manager, + * or the Animation Manager creating a new animation directly. + */ + const ADD_ANIMATION: any; + + /** + * The Animation Complete Event. + * + * This event is dispatched by an Animation instance when it completes, i.e. finishes playing or is manually stopped. + * + * Be careful with the volume of events this could generate. If a group of Sprites all complete the same + * animation at the same time, this event will invoke its handler for each one of them. + */ + const ANIMATION_COMPLETE: any; + + /** + * The Animation Repeat Event. + * + * This event is dispatched when a currently playing animation repeats. + * + * The event is dispatched directly from the Animation object itself. Which means that listeners + * bound to this event will be invoked every time the Animation repeats, for every Game Object that may have it. + */ + const ANIMATION_REPEAT: any; + + /** + * The Animation Restart Event. + * + * This event is dispatched by an Animation instance when it restarts. + * + * Be careful with the volume of events this could generate. If a group of Sprites all restart the same + * animation at the same time, this event will invoke its handler for each one of them. + */ + const ANIMATION_RESTART: any; + + /** + * The Animation Start Event. + * + * This event is dispatched by an Animation instance when it starts playing. + * + * Be careful with the volume of events this could generate. If a group of Sprites all play the same + * animation at the same time, this event will invoke its handler for each one of them. + */ + const ANIMATION_START: any; + + /** + * The Pause All Animations Event. + * + * This event is dispatched when the global Animation Manager is told to pause. + * + * When this happens all current animations will stop updating, although it doesn't necessarily mean + * that the game has paused as well. + */ + const PAUSE_ALL: any; + + /** + * The Remove Animation Event. + * + * This event is dispatched when an animation is removed from the global Animation Manager. + */ + const REMOVE_ANIMATION: any; + + /** + * The Resume All Animations Event. + * + * This event is dispatched when the global Animation Manager resumes, having been previously paused. + * + * When this happens all current animations will continue updating again. + */ + const RESUME_ALL: any; + + /** + * The Sprite Animation Complete Event. + * + * This event is dispatched by a Sprite when an animation finishes playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationcomplete', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_COMPLETE` event. + */ + const SPRITE_ANIMATION_COMPLETE: any; + + /** + * The Sprite Animation Key Complete Event. + * + * This event is dispatched by a Sprite when a specific animation finishes playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationcomplete-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationcomplete-explode`. + */ + const SPRITE_ANIMATION_KEY_COMPLETE: any; + + /** + * The Sprite Animation Key Repeat Event. + * + * This event is dispatched by a Sprite when a specific animation repeats playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrepeat-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationrepeat-explode`. + */ + const SPRITE_ANIMATION_KEY_REPEAT: any; + + /** + * The Sprite Animation Key Restart Event. + * + * This event is dispatched by a Sprite when a specific animation restarts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrestart-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationrestart-explode`. + */ + const SPRITE_ANIMATION_KEY_RESTART: any; + + /** + * The Sprite Animation Key Start Event. + * + * This event is dispatched by a Sprite when a specific animation starts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationstart-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationstart-explode`. + */ + const SPRITE_ANIMATION_KEY_START: any; + + /** + * The Sprite Animation Key Update Event. + * + * This event is dispatched by a Sprite when a specific animation playing on it updates. This happens when the animation changes frame, + * based on the animation frame rate and other factors like `timeScale` and `delay`. + * + * Listen for it on the Sprite using `sprite.on('animationupdate-key', listener)` where `key` is the key of + * the animation. For example, if you had an animation with the key 'explode' you should listen for `animationupdate-explode`. + */ + const SPRITE_ANIMATION_KEY_UPDATE: any; + + /** + * The Sprite Animation Repeat Event. + * + * This event is dispatched by a Sprite when an animation repeats playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrepeat', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_REPEAT` event. + */ + const SPRITE_ANIMATION_REPEAT: any; + + /** + * The Sprite Animation Restart Event. + * + * This event is dispatched by a Sprite when an animation restarts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationrestart', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_RESTART` event. + */ + const SPRITE_ANIMATION_RESTART: any; + + /** + * The Sprite Animation Start Event. + * + * This event is dispatched by a Sprite when an animation starts playing on it. + * + * Listen for it on the Sprite using `sprite.on('animationstart', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_START` event. + */ + const SPRITE_ANIMATION_START: any; + + /** + * The Sprite Animation Update Event. + * + * This event is dispatched by a Sprite when an animation playing on it updates. This happens when the animation changes frame, + * based on the animation frame rate and other factors like `timeScale` and `delay`. + * + * Listen for it on the Sprite using `sprite.on('animationupdate', listener)` + * + * This same event is dispatched for all animations. To listen for a specific animation, use the `SPRITE_ANIMATION_KEY_UPDATE` event. + */ + const SPRITE_ANIMATION_UPDATE: any; + + } + + namespace Types { + type Animation = { + /** + * The key that the animation will be associated with. i.e. sprite.animations.play(key) + */ + key?: string; + /** + * An object containing data used to generate the frames for the animation + */ + frames?: Phaser.Animations.Types.AnimationFrame[]; + /** + * The key of the texture all frames of the animation will use. Can be overridden on a per frame basis. + */ + defaultTextureKey?: string; + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + */ + frameRate?: integer; + /** + * How long the animation should play for in milliseconds. If not given its derived from frameRate. + */ + duration?: integer; + /** + * Skip frames if the time lags, or always advanced anyway? + */ + skipMissedFrames?: boolean; + /** + * Delay before starting playback. Value given in milliseconds. + */ + delay?: integer; + /** + * Number of times to repeat the animation (-1 for infinity) + */ + repeat?: integer; + /** + * Delay before the animation repeats. Value given in milliseconds. + */ + repeatDelay?: integer; + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + */ + yoyo?: boolean; + /** + * Should sprite.visible = true when the animation starts to play? + */ + showOnStart?: boolean; + /** + * Should sprite.visible = false when the animation finishes? + */ + hideOnComplete?: boolean; + }; + + type AnimationFrame = { + /** + * The key that the animation will be associated with. i.e. sprite.animations.play(key) + */ + key: string; + /** + * [description] + */ + frame: string | number; + /** + * [description] + */ + duration?: number; + /** + * [description] + */ + visible?: boolean; + }; + + type GenerateFrameNames = { + /** + * The string to append to every resulting frame name if using a range or an array of `frames`. + */ + prefix?: string; + /** + * If `frames` is not provided, the number of the first frame to return. + */ + start?: integer; + /** + * If `frames` is not provided, the number of the last frame to return. + */ + end?: integer; + /** + * The string to append to every resulting frame name if using a range or an array of `frames`. + */ + suffix?: string; + /** + * The minimum expected lengths of each resulting frame's number. Numbers will be left-padded with zeroes until they are this long, then prepended and appended to create the resulting frame name. + */ + zeroPad?: integer; + /** + * The array to append the created configuration objects to. + */ + outputArray?: Phaser.Animations.Types.AnimationFrame[]; + /** + * If provided as an array, the range defined by `start` and `end` will be ignored and these frame numbers will be used. + */ + frames?: boolean; + }; + + type GenerateFrameNumbers = { + /** + * The starting frame of the animation. + */ + start?: integer; + /** + * The ending frame of the animation. + */ + end?: integer; + /** + * A frame to put at the beginning of the animation, before `start` or `outputArray` or `frames`. + */ + first?: boolean | integer; + /** + * An array to concatenate the output onto. + */ + outputArray?: Phaser.Animations.Types.AnimationFrame[]; + /** + * A custom sequence of frames. + */ + frames?: boolean | integer[]; + }; + + type JSONAnimation = { + /** + * The key that the animation will be associated with. i.e. sprite.animations.play(key) + */ + key: string; + /** + * A frame based animation (as opposed to a bone based animation) + */ + type: string; + /** + * [description] + */ + frames: Phaser.Animations.Types.JSONAnimationFrame[]; + /** + * The frame rate of playback in frames per second (default 24 if duration is null) + */ + frameRate: integer; + /** + * How long the animation should play for in milliseconds. If not given its derived from frameRate. + */ + duration: integer; + /** + * Skip frames if the time lags, or always advanced anyway? + */ + skipMissedFrames: boolean; + /** + * Delay before starting playback. Value given in milliseconds. + */ + delay: integer; + /** + * Number of times to repeat the animation (-1 for infinity) + */ + repeat: integer; + /** + * Delay before the animation repeats. Value given in milliseconds. + */ + repeatDelay: integer; + /** + * Should the animation yoyo? (reverse back down to the start) before repeating? + */ + yoyo: boolean; + /** + * Should sprite.visible = true when the animation starts to play? + */ + showOnStart: boolean; + /** + * Should sprite.visible = false when the animation finishes? + */ + hideOnComplete: boolean; + }; + + type JSONAnimationFrame = { + /** + * The key of the Texture this AnimationFrame uses. + */ + key: string; + /** + * The key of the Frame within the Texture that this AnimationFrame uses. + */ + frame: string | integer; + /** + * Additional time (in ms) that this frame should appear for during playback. + */ + duration: number; + }; + + type JSONAnimations = { + /** + * An array of all Animations added to the Animation Manager. + */ + anims: Phaser.Animations.Types.JSONAnimation[]; + /** + * The global time scale of the Animation Manager. + */ + globalTimeScale: number; + }; + + } + } + namespace Cache { + /** + * The BaseCache is a base Cache class that can be used for storing references to any kind of data. + * + * Data can be added, retrieved and removed based on the given keys. + * + * Keys are string-based. + */ + class BaseCache { + /** + * The Map in which the cache objects are stored. + * + * You can query the Map directly or use the BaseCache methods. + */ + entries: Phaser.Structs.Map; + + /** + * An instance of EventEmitter used by the cache to emit related events. + */ + events: Phaser.Events.EventEmitter; + + /** + * Adds an item to this cache. The item is referenced by a unique string, which you are responsible + * for setting and keeping track of. The item can only be retrieved by using this string. + * @param key The unique key by which the data added to the cache will be referenced. + * @param data The data to be stored in the cache. + */ + add(key: string, data: any): Phaser.Cache.BaseCache; + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.exists`. + * @param key The unique key of the item to be checked in this cache. + */ + has(key: string): boolean; + + /** + * Checks if this cache contains an item matching the given key. + * This performs the same action as `BaseCache.has` and is called directly by the Loader. + * @param key The unique key of the item to be checked in this cache. + */ + exists(key: string): boolean; + + /** + * Gets an item from this cache based on the given key. + * @param key The unique key of the item to be retrieved from this cache. + */ + get(key: string): any; + + /** + * Removes and item from this cache based on the given key. + * + * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. + * No additional checks are done on the item removed. If other systems or parts of your game code + * are relying on this item, it is up to you to sever those relationships prior to removing the item. + * @param key The unique key of the item to remove from the cache. + */ + remove(key: string): Phaser.Cache.BaseCache; + + /** + * Destroys this cache and all items within it. + */ + destroy(): void; + + } + + /** + * The Cache Manager is the global cache owned and maintained by the Game instance. + * + * Various systems, such as the file Loader, rely on this cache in order to store the files + * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache + * instances, one per type of file. You can also add your own custom caches. + */ + class CacheManager { + /** + * + * @param game A reference to the Phaser.Game instance that owns this CacheManager. + */ + constructor(game: Phaser.Game); + + /** + * A reference to the Phaser.Game instance that owns this CacheManager. + */ + protected game: Phaser.Game; + + /** + * A Cache storing all binary files, typically added via the Loader. + */ + binary: Phaser.Cache.BaseCache; + + /** + * A Cache storing all bitmap font data files, typically added via the Loader. + * Only the font data is stored in this cache, the textures are part of the Texture Manager. + */ + bitmapFont: Phaser.Cache.BaseCache; + + /** + * A Cache storing all JSON data files, typically added via the Loader. + */ + json: Phaser.Cache.BaseCache; + + /** + * A Cache storing all physics data files, typically added via the Loader. + */ + physics: Phaser.Cache.BaseCache; + + /** + * A Cache storing all shader source files, typically added via the Loader. + */ + shader: Phaser.Cache.BaseCache; + + /** + * A Cache storing all non-streaming audio files, typically added via the Loader. + */ + audio: Phaser.Cache.BaseCache; + + /** + * A Cache storing all text files, typically added via the Loader. + */ + text: Phaser.Cache.BaseCache; + + /** + * A Cache storing all html files, typically added via the Loader. + */ + html: Phaser.Cache.BaseCache; + + /** + * A Cache storing all WaveFront OBJ files, typically added via the Loader. + */ + obj: Phaser.Cache.BaseCache; + + /** + * A Cache storing all tilemap data files, typically added via the Loader. + * Only the data is stored in this cache, the textures are part of the Texture Manager. + */ + tilemap: Phaser.Cache.BaseCache; + + /** + * A Cache storing all xml data files, typically added via the Loader. + */ + xml: Phaser.Cache.BaseCache; + + /** + * An object that contains your own custom BaseCache entries. + * Add to this via the `addCustom` method. + */ + custom: {[key: string]: Phaser.Cache.BaseCache}; + + /** + * Add your own custom Cache for storing your own files. + * The cache will be available under `Cache.custom.key`. + * The cache will only be created if the key is not already in use. + * @param key The unique key of your custom cache. + */ + addCustom(key: string): Phaser.Cache.BaseCache; + + /** + * Removes all entries from all BaseCaches and destroys all custom caches. + */ + destroy(): void; + + } + + namespace Events { + /** + * The Cache Add Event. + * + * This event is dispatched by any Cache that extends the BaseCache each time a new object is added to it. + */ + const ADD: any; + + /** + * The Cache Remove Event. + * + * This event is dispatched by any Cache that extends the BaseCache each time an object is removed from it. + */ + const REMOVE: any; + + } + + } + + namespace Cameras { + namespace Scene2D { + /** + * A Base Camera class. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * The Base Camera is extended by the Camera class, which adds in special effects including Fade, + * Flash and Camera Shake, as well as the ability to follow Game Objects. + * + * The Base Camera was introduced in Phaser 3.12. It was split off from the Camera class, to allow + * you to isolate special effects as needed. Therefore the 'since' values for properties of this class relate + * to when they were added to the Camera class. + */ + class BaseCamera extends Phaser.Events.EventEmitter implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.Visible { + /** + * + * @param x The x position of the Camera, relative to the top-left of the game canvas. + * @param y The y position of the Camera, relative to the top-left of the game canvas. + * @param width The width of the Camera, in pixels. + * @param height The height of the Camera, in pixels. + */ + constructor(x: number, y: number, width: number, height: number); + + /** + * A reference to the Scene this camera belongs to. + */ + scene: Phaser.Scene; + + /** + * A reference to the Game Scene Manager. + */ + sceneManager: Phaser.Scenes.SceneManager; + + /** + * A reference to the Game Scale Manager. + */ + scaleManager: Phaser.Scale.ScaleManager; + + /** + * The Camera ID. Assigned by the Camera Manager and used to handle camera exclusion. + * This value is a bitmask. + */ + readonly id: integer; + + /** + * The name of the Camera. This is left empty for your own use. + */ + name: string; + + /** + * This property is un-used in v3.16. + * + * The resolution of the Game, used in most Camera calculations. + */ + readonly resolution: number; + + /** + * Should this camera round its pixel values to integers? + */ + roundPixels: boolean; + + /** + * Is this Camera visible or not? + * + * A visible camera will render and perform input tests. + * An invisible camera will not render anything and will skip input tests. + */ + visible: boolean; + + /** + * Is this Camera using a bounds to restrict scrolling movement? + * + * Set this property along with the bounds via `Camera.setBounds`. + */ + useBounds: boolean; + + /** + * The World View is a Rectangle that defines the area of the 'world' the Camera is currently looking at. + * This factors in the Camera viewport size, zoom and scroll position and is updated in the Camera preRender step. + * If you have enabled Camera bounds the worldview will be clamped to those bounds accordingly. + * You can use it for culling or intersection checks. + */ + readonly worldView: Phaser.Geom.Rectangle; + + /** + * Is this Camera dirty? + * + * A dirty Camera has had either its viewport size, bounds, scroll, rotation or zoom levels changed since the last frame. + * + * This flag is cleared during the `postRenderCamera` method of the renderer. + */ + dirty: boolean; + + /** + * Does this Camera have a transparent background? + */ + transparent: boolean; + + /** + * The background color of this Camera. Only used if `transparent` is `false`. + */ + backgroundColor: Phaser.Display.Color; + + /** + * The Camera alpha value. Setting this property impacts every single object that this Camera + * renders. You can either set the property directly, i.e. via a Tween, to fade a Camera in or out, + * or via the chainable `setAlpha` method instead. + */ + alpha: number; + + /** + * Should the camera cull Game Objects before checking them for input hit tests? + * In some special cases it may be beneficial to disable this. + */ + disableCull: boolean; + + /** + * The mid-point of the Camera in 'world' coordinates. + * + * Use it to obtain exactly where in the world the center of the camera is currently looking. + * + * This value is updated in the preRender method, after the scroll values and follower + * have been processed. + */ + readonly midPoint: Phaser.Math.Vector2; + + /** + * The horizontal origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + */ + originX: number; + + /** + * The vertical origin of rotation for this Camera. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * + * See `setOrigin` to set both origins in a single, chainable call. + */ + originY: number; + + /** + * Set the Alpha level of this Camera. The alpha controls the opacity of the Camera as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * @param value The Camera alpha value. Default 1. + */ + setAlpha(value?: number): this; + + /** + * Sets the rotation origin of this Camera. + * + * The values are given in the range 0 to 1 and are only used when calculating Camera rotation. + * + * By default the camera rotates around the center of the viewport. + * + * Changing the origin allows you to adjust the point in the viewport from which rotation happens. + * A value of 0 would rotate from the top-left of the viewport. A value of 1 from the bottom right. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Calculates what the Camera.scrollX and scrollY values would need to be in order to move + * the Camera so it is centered on the given x and y coordinates, without actually moving + * the Camera there. The results are clamped based on the Camera bounds, if set. + * @param x The horizontal coordinate to center on. + * @param y The vertical coordinate to center on. + * @param out A Vec2 to store the values in. If not given a new Vec2 is created. + */ + getScroll(x: number, y: number, out?: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Moves the Camera horizontally so that it is centered on the given x coordinate, bounds allowing. + * Calling this does not change the scrollY value. + * @param x The horizontal coordinate to center on. + */ + centerOnX(x: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera vertically so that it is centered on the given y coordinate, bounds allowing. + * Calling this does not change the scrollX value. + * @param y The vertical coordinate to center on. + */ + centerOnY(y: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera so that it is centered on the given coordinates, bounds allowing. + * @param x The horizontal coordinate to center on. + * @param y The vertical coordinate to center on. + */ + centerOn(x: number, y: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera so that it is looking at the center of the Camera Bounds, if enabled. + */ + centerToBounds(): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Moves the Camera so that it is re-centered based on its viewport size. + */ + centerToSize(): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Takes an array of Game Objects and returns a new array featuring only those objects + * visible by this camera. + * @param renderableObjects An array of Game Objects to cull. + */ + cull(renderableObjects: G): G; + + /** + * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. + * You can optionally provide a Vector2, or similar object, to store the results in. + * @param x The x position to convert to world space. + * @param y The y position to convert to world space. + * @param output An optional object to store the results in. If not provided a new Vector2 will be created. + */ + getWorldPoint(x: number, y: number, output?: O): O; + + /** + * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings + * so that they are ignored by this Camera. This means they will not be rendered by this Camera. + * @param entries The Game Object, or array of Game Objects, to be ignored by this Camera. + */ + ignore(entries: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Internal preRender step. + * @param resolution The game resolution, as set in the Scale Manager. + */ + protected preRender(resolution: number): void; + + /** + * Takes an x value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * @param x The value to horizontally scroll clamp. + */ + clampX(x: number): number; + + /** + * Takes a y value and checks it's within the range of the Camera bounds, adjusting if required. + * Do not call this method if you are not using camera bounds. + * @param y The value to vertically scroll clamp. + */ + clampY(y: number): number; + + /** + * If this Camera has previously had movement bounds set on it, this will remove them. + */ + removeBounds(): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * @param value The cameras angle of rotation, given in degrees. Default 0. + */ + setAngle(value?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Sets the background color for this Camera. + * + * By default a Camera has a transparent background but it can be given a solid color, with any level + * of transparency, via this method. + * + * The color value can be specified using CSS color notation, hex or numbers. + * @param color The color value. In CSS, hex or numeric color notation. Default 'rgba(0,0,0,0)'. + */ + setBackgroundColor(color?: string | number | InputColorObject): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the bounds of the Camera. The bounds are an axis-aligned rectangle. + * + * The Camera bounds controls where the Camera can scroll to, stopping it from scrolling off the + * edges and into blank space. It does not limit the placement of Game Objects, or where + * the Camera viewport can be positioned. + * + * Temporarily disable the bounds by changing the boolean `Camera.useBounds`. + * + * Clear the bounds entirely by calling `Camera.removeBounds`. + * + * If you set bounds that are smaller than the viewport it will stop the Camera from being + * able to scroll. The bounds can be positioned where-ever you wish. By default they are from + * 0x0 to the canvas width x height. This means that the coordinate 0x0 is the top left of + * the Camera bounds. However, you can position them anywhere. So if you wanted a game world + * that was 2048x2048 in size, with 0x0 being the center of it, you can set the bounds x/y + * to be -1024, -1024, with a width and height of 2048. Depending on your game you may find + * it easier for 0x0 to be the top-left of the bounds, or you may wish 0x0 to be the middle. + * @param x The top-left x coordinate of the bounds. + * @param y The top-left y coordinate of the bounds. + * @param width The width of the bounds, in pixels. + * @param height The height of the bounds, in pixels. + * @param centerOn If `true` the Camera will automatically be centered on the new bounds. Default false. + */ + setBounds(x: integer, y: integer, width: integer, height: integer, centerOn?: boolean): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Returns a rectangle containing the bounds of the Camera. + * + * If the Camera does not have any bounds the rectangle will be empty. + * + * The rectangle is a copy of the bounds, so is safe to modify. + * @param out An optional Rectangle to store the bounds in. If not given, a new Rectangle will be created. + */ + getBounds(out?: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; + + /** + * Sets the name of this Camera. + * This value is for your own use and isn't used internally. + * @param value The name of the Camera. Default ''. + */ + setName(value?: string): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the position of the Camera viewport within the game. + * + * This does not change where the camera is 'looking'. See `setScroll` to control that. + * @param x The top-left x coordinate of the Camera viewport. + * @param y The top-left y coordinate of the Camera viewport. Default x. + */ + setPosition(x: number, y?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the rotation of this Camera. This causes everything it renders to appear rotated. + * + * Rotating a camera does not rotate the viewport itself, it is applied during rendering. + * @param value The rotation of the Camera, in radians. Default 0. + */ + setRotation(value?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Should the Camera round pixel values to whole integers when rendering Game Objects? + * + * In some types of game, especially with pixel art, this is required to prevent sub-pixel aliasing. + * @param value `true` to round Camera pixels, `false` to not. + */ + setRoundPixels(value: boolean): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Sets the Scene the Camera is bound to. + * + * Also populates the `resolution` property and updates the internal size values. + * @param scene The Scene the camera is bound to. + */ + setScene(scene: Phaser.Scene): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the position of where the Camera is looking within the game. + * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. + * Use this method, or the scroll properties, to move your camera around the game world. + * + * This does not change where the camera viewport is placed. See `setPosition` to control that. + * @param x The x coordinate of the Camera in the game world. + * @param y The y coordinate of the Camera in the game world. Default x. + */ + setScroll(x: number, y?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the size of the Camera viewport. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * @param width The width of the Camera viewport. + * @param height The height of the Camera viewport. Default width. + */ + setSize(width: integer, height?: integer): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * This method sets the position and size of the Camera viewport in a single call. + * + * If you're trying to change where the Camera is looking at in your game, then see + * the method `Camera.setScroll` instead. This method is for changing the viewport + * itself, not what the camera can see. + * + * By default a Camera is the same size as the game, but can be made smaller via this method, + * allowing you to create mini-cam style effects by creating and positioning a smaller Camera + * viewport within your game. + * @param x The top-left x coordinate of the Camera viewport. + * @param y The top-left y coordinate of the Camera viewport. + * @param width The width of the Camera viewport. + * @param height The height of the Camera viewport. Default width. + */ + setViewport(x: number, y: number, width: integer, height?: integer): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Set the zoom value of the Camera. + * + * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. + * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. + * + * A value of 1 means 'no zoom' and is the default. + * + * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. + * @param value The zoom value of the Camera. The minimum it can be is 0.001. Default 1. + */ + setZoom(value?: number): Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Sets the visibility of this Camera. + * + * An invisible Camera will skip rendering and input tests of everything it can see. + * @param value The visible state of the Camera. + */ + setVisible(value: boolean): this; + + /** + * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. + */ + toJSON(): JSONCamera; + + /** + * Internal method called automatically by the Camera Manager. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected update(time: integer, delta: number): void; + + /** + * Destroys this Camera instance and its internal properties and references. + * Once destroyed you cannot use this Camera again, even if re-added to a Camera Manager. + * + * This method is called automatically by `CameraManager.remove` if that methods `runDestroy` argument is `true`, which is the default. + * + * Unless you have a specific reason otherwise, always use `CameraManager.remove` and allow it to handle the camera destruction, + * rather than calling this method directly. + */ + destroy(): void; + + /** + * The x position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollX` value. + */ + x: number; + + /** + * The y position of the Camera viewport, relative to the top-left of the game canvas. + * The viewport is the area into which the camera renders. + * To adjust the position the camera is looking at in the game world, see the `scrollY` value. + */ + y: number; + + /** + * The width of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + */ + width: number; + + /** + * The height of the Camera viewport, in pixels. + * + * The viewport is the area into which the Camera renders. Setting the viewport does + * not restrict where the Camera can scroll to. + */ + height: number; + + /** + * The horizontal scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + */ + scrollX: number; + + /** + * The vertical scroll position of this Camera. + * + * Change this value to cause the Camera to scroll around your Scene. + * + * Alternatively, setting the Camera to follow a Game Object, via the `startFollow` method, + * will automatically adjust the Camera scroll values accordingly. + * + * You can set the bounds within which the Camera can scroll via the `setBounds` method. + */ + scrollY: number; + + /** + * The Camera zoom value. Change this value to zoom in, or out of, a Scene. + * + * A value of 0.5 would zoom the Camera out, so you can now see twice as much + * of the Scene as before. A value of 2 would zoom the Camera in, so every pixel + * now takes up 2 pixels when rendered. + * + * Set to 1 to return to the default zoom level. + * + * Be careful to never set this value to zero. + */ + zoom: number; + + /** + * The horizontal position of the center of the Camera's viewport, relative to the left of the game canvas. + */ + readonly centerX: number; + + /** + * The vertical position of the center of the Camera's viewport, relative to the top of the game canvas. + */ + readonly centerY: number; + + /** + * The displayed width of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport width of 800 and a zoom of 0.5 then its display width + * would be 1600, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a width of 800 and zoom of 2 would have a display width + * of 400 pixels. + */ + readonly displayWidth: number; + + /** + * The displayed height of the camera viewport, factoring in the camera zoom level. + * + * If a camera has a viewport height of 600 and a zoom of 0.5 then its display height + * would be 1200, as it's displaying twice as many pixels as zoom level 1. + * + * Equally, a camera with a height of 600 and zoom of 2 would have a display height + * of 300 pixels. + */ + readonly displayHeight: number; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + } + + /** + * A Camera. + * + * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, + * and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. + * + * A Camera also has built-in special effects including Fade, Flash and Camera Shake. + */ + class Camera extends Phaser.Cameras.Scene2D.BaseCamera implements Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Tint { + /** + * + * @param x The x position of the Camera, relative to the top-left of the game canvas. + * @param y The y position of the Camera, relative to the top-left of the game canvas. + * @param width The width of the Camera, in pixels. + * @param height The height of the Camera, in pixels. + */ + constructor(x: number, y: number, width: number, height: number); + + /** + * Does this Camera allow the Game Objects it renders to receive input events? + */ + inputEnabled: boolean; + + /** + * The Camera Fade effect handler. + * To fade this camera see the `Camera.fade` methods. + */ + fadeEffect: Phaser.Cameras.Scene2D.Effects.Fade; + + /** + * The Camera Flash effect handler. + * To flash this camera see the `Camera.flash` method. + */ + flashEffect: Phaser.Cameras.Scene2D.Effects.Flash; + + /** + * The Camera Shake effect handler. + * To shake this camera see the `Camera.shake` method. + */ + shakeEffect: Phaser.Cameras.Scene2D.Effects.Shake; + + /** + * The Camera Pan effect handler. + * To pan this camera see the `Camera.pan` method. + */ + panEffect: Phaser.Cameras.Scene2D.Effects.Pan; + + /** + * The Camera Zoom effect handler. + * To zoom this camera see the `Camera.zoom` method. + */ + zoomEffect: Phaser.Cameras.Scene2D.Effects.Zoom; + + /** + * The linear interpolation value to use when following a target. + * + * Can also be set via `setLerp` or as part of the `startFollow` call. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + */ + lerp: Phaser.Math.Vector2; + + /** + * The values stored in this property are subtracted from the Camera targets position, allowing you to + * offset the camera from the actual target x/y coordinates by this amount. + * Can also be set via `setFollowOffset` or as part of the `startFollow` call. + */ + followOffset: Phaser.Math.Vector2; + + /** + * The Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * You can directly set this property to be an instance of a Rectangle. Or, you can use the + * `setDeadzone` method for a chainable approach. + * + * The rectangle you provide can have its dimensions adjusted dynamically, however, please + * note that its position is updated every frame, as it is constantly re-centered on the cameras mid point. + * + * Calling `setDeadzone` with no arguments will reset an active deadzone, as will setting this property + * to `null`. + */ + deadzone: Phaser.Geom.Rectangle; + + /** + * Is this Camera rendering directly to the canvas or to a texture? + * + * Enable rendering to texture with the method `setRenderToTexture` (just enabling this boolean won't be enough) + * + * Once enabled you can toggle it by switching this property. + * + * To properly remove a render texture you should call the `clearRenderToTexture()` method. + */ + renderToTexture: boolean; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the HTML Canvas Element that the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + */ + canvas: HTMLCanvasElement; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the Rendering Context belonging to the Canvas element the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only populated if Phaser is running with the Canvas Renderer. + */ + context: CanvasRenderingContext2D; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Texture belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + */ + glTexture: WebGLTexture; + + /** + * If this Camera has been set to render to a texture then this holds a reference + * to the GL Frame Buffer belonging the Camera is drawing to. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + */ + framebuffer: WebGLFramebuffer; + + /** + * If this Camera has been set to render to a texture and to use a custom pipeline, + * then this holds a reference to the pipeline the Camera is drawing with. + * + * Enable texture rendering using the method `setRenderToTexture`. + * + * This is only set if Phaser is running with the WebGL Renderer. + */ + pipeline: any; + + /** + * Sets the Camera to render to a texture instead of to the main canvas. + * + * The Camera will redirect all Game Objects it's asked to render to this texture. + * + * During the render sequence, the texture itself will then be rendered to the main canvas. + * + * Doing this gives you the ability to modify the texture before this happens, + * allowing for special effects such as Camera specific shaders, or post-processing + * on the texture. + * + * If running under Canvas the Camera will render to its `canvas` property. + * + * If running under WebGL the Camera will create a frame buffer, which is stored in its `framebuffer` and `glTexture` properties. + * + * If you set a camera to render to a texture then it will emit 2 events during the render loop: + * + * First, it will emit the event `prerender`. This happens right before any Game Object's are drawn to the Camera texture. + * + * Then, it will emit the event `postrender`. This happens after all Game Object's have been drawn, but right before the + * Camera texture is rendered to the main game canvas. It's the final point at which you can manipulate the texture before + * it appears in-game. + * + * You should not enable this unless you plan on actually using the texture it creates + * somehow, otherwise you're just doubling the work required to render your game. + * + * To temporarily disable rendering to a texture, toggle the `renderToTexture` boolean. + * + * If you no longer require the Camera to render to a texture, call the `clearRenderToTexture` method, + * which will delete the respective textures and free-up resources. + * @param pipeline An optional WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. + */ + setRenderToTexture(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Cameras.Scene2D.Camera; + + /** + * Sets the WebGL pipeline this Camera is using when rendering to a texture. + * + * You can pass either the string-based name of the pipeline, or a reference to the pipeline itself. + * + * Call this method with no arguments to clear any previously set pipeline. + * @param pipeline The WebGL Pipeline to render with, can be either a string which is the name of the pipeline, or a pipeline reference. Or if left empty it will clear the pipeline. + */ + setPipeline(pipeline?: string | Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Cameras.Scene2D.Camera; + + /** + * If this Camera was set to render to a texture, this will clear the resources it was using and + * redirect it to render back to the primary Canvas again. + * + * If you only wish to temporarily disable rendering to a texture then you can toggle the + * property `renderToTexture` instead. + */ + clearRenderToTexture(): Phaser.Cameras.Scene2D.Camera; + + /** + * Sets the Camera dead zone. + * + * The deadzone is only used when the camera is following a target. + * + * It defines a rectangular region within which if the target is present, the camera will not scroll. + * If the target moves outside of this area, the camera will begin scrolling in order to follow it. + * + * The deadzone rectangle is re-positioned every frame so that it is centered on the mid-point + * of the camera. This allows you to use the object for additional game related checks, such as + * testing if an object is within it or not via a Rectangle.contains call. + * + * The `lerp` values that you can set for a follower target also apply when using a deadzone. + * + * Calling this method with no arguments will reset an active deadzone. + * @param width The width of the deadzone rectangle in pixels. If not specified the deadzone is removed. + * @param height The height of the deadzone rectangle in pixels. + */ + setDeadzone(width?: number, height?: number): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera in from the given color over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fadeIn(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera out to the given color over the duration specified. + * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fadeOut(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera from the given color to transparent over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fadeFrom(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Fades the Camera from transparent to the given color over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + fade(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 250. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + flash(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Shakes the Camera by the given intensity over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 100. + * @param intensity The intensity of the shake. Default 0.05. + * @param force Force the shake effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + shake(duration?: integer, intensity?: number, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * @param x The destination x coordinate to scroll the center of the Camera viewport to. + * @param y The destination y coordinate to scroll the center of the Camera viewport to. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the pan effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + pan(x: number, y: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * @param zoom The target Camera zoom value. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the pan effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + zoomTo(zoom: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * Internal preRender step. + * @param resolution The game resolution, as set in the Scale Manager. + */ + protected preRender(resolution: number): void; + + /** + * Sets the linear interpolation value to use when following a target. + * + * The default values of 1 means the camera will instantly snap to the target coordinates. + * A lower value, such as 0.1 means the camera will more slowly track the target, giving + * a smooth transition. You can set the horizontal and vertical values independently, and also + * adjust this value in real-time during your game. + * + * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. + * @param x The amount added to the horizontal linear interpolation of the follow target. Default 1. + * @param y The amount added to the vertical linear interpolation of the follow target. Default 1. + */ + setLerp(x?: number, y?: number): this; + + /** + * Sets the horizontal and vertical offset of the camera from its follow target. + * The values are subtracted from the targets position during the Cameras update step. + * @param x The horizontal offset from the camera follow target.x position. Default 0. + * @param y The vertical offset from the camera follow target.y position. Default 0. + */ + setFollowOffset(x?: number, y?: number): this; + + /** + * Sets the Camera to follow a Game Object. + * + * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object + * in its center. + * + * You can set the linear interpolation value used in the follow code. + * Use low lerp values (such as 0.1) to automatically smooth the camera motion. + * + * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel + * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to + * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom + * value on the camera. So be sure to keep the camera zoom to integers. + * @param target The target for the Camera to follow. + * @param roundPixels Round the camera position to whole integers to avoid sub-pixel rendering? Default false. + * @param lerpX A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. Default 1. + * @param lerpY A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. Default 1. + * @param offsetX The horizontal offset from the camera follow target.x position. Default 0. + * @param offsetY The vertical offset from the camera follow target.y position. Default 0. + */ + startFollow(target: Phaser.GameObjects.GameObject | object, roundPixels?: boolean, lerpX?: number, lerpY?: number, offsetX?: number, offsetY?: number): this; + + /** + * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. + */ + stopFollow(): Phaser.Cameras.Scene2D.Camera; + + /** + * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to + * remove the fade. + */ + resetFX(): Phaser.Cameras.Scene2D.Camera; + + /** + * Internal method called automatically by the Camera Manager. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected update(time: integer, delta: number): void; + + /** + * Destroys this Camera instance. You rarely need to call this directly. + * + * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as + * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. + */ + destroy(): void; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): this; + + /** + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): this; + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlip(x: boolean, y: boolean): this; + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + */ + resetFlip(): this; + + /** + * Fill or additive? + */ + tintFill: boolean; + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + */ + clearTint(): this; + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + + } + + /** + * The Camera Manager is a plugin that belongs to a Scene and is responsible for managing all of the Scene Cameras. + * + * By default you can access the Camera Manager from within a Scene using `this.cameras`, although this can be changed + * in your game config. + * + * Create new Cameras using the `add` method. Or extend the Camera class with your own addition code and then add + * the new Camera in using the `addExisting` method. + * + * Cameras provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. + * + * A Camera consists of two elements: The viewport and the scroll values. + * + * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are + * created the same size as your game, but their position and size can be set to anything. This means if you + * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, + * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). + * + * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this + * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the + * viewport, and changing the viewport has no impact on the scrolling. + * + * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, + * allowing you to filter Game Objects out on a per-Camera basis. The Camera Manager can manage up to 31 unique + * 'Game Object ignore capable' Cameras. Any Cameras beyond 31 that you create will all be given a Camera ID of + * zero, meaning that they cannot be used for Game Object exclusion. This means if you need your Camera to ignore + * Game Objects, make sure it's one of the first 31 created. + * + * A Camera also has built-in special effects including Fade, Flash, Camera Shake, Pan and Zoom. + */ + class CameraManager { + /** + * + * @param scene The Scene that owns the Camera Manager plugin. + */ + constructor(scene: Phaser.Scene); + + /** + * The Scene that owns the Camera Manager plugin. + */ + scene: Phaser.Scene; + + /** + * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. + */ + systems: Phaser.Scenes.Systems; + + /** + * All Cameras created by, or added to, this Camera Manager, will have their `roundPixels` + * property set to match this value. By default it is set to match the value set in the + * game configuration, but can be changed at any point. Equally, individual cameras can + * also be changed as needed. + */ + roundPixels: boolean; + + /** + * An Array of the Camera objects being managed by this Camera Manager. + * The Cameras are updated and rendered in the same order in which they appear in this array. + * Do not directly add or remove entries to this array. However, you can move the contents + * around the array should you wish to adjust the display order. + */ + cameras: Phaser.Cameras.Scene2D.Camera[]; + + /** + * A handy reference to the 'main' camera. By default this is the first Camera the + * Camera Manager creates. You can also set it directly, or use the `makeMain` argument + * in the `add` and `addExisting` methods. It allows you to access it from your game: + * + * ```javascript + * var cam = this.cameras.main; + * ``` + * + * Also see the properties `camera1`, `camera2` and so on. + */ + main: Phaser.Cameras.Scene2D.Camera; + + /** + * Adds a new Camera into the Camera Manager. The Camera Manager can support up to 31 different Cameras. + * + * Each Camera has its own viewport, which controls the size of the Camera and its position within the canvas. + * + * Use the `Camera.scrollX` and `Camera.scrollY` properties to change where the Camera is looking, or the + * Camera methods such as `centerOn`. Cameras also have built in special effects, such as fade, flash, shake, + * pan and zoom. + * + * By default Cameras are transparent and will render anything that they can see based on their `scrollX` + * and `scrollY` values. Game Objects can be set to be ignored by a Camera by using the `Camera.ignore` method. + * + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change + * it after creation if required. + * + * See the Camera class documentation for more details. + * @param x The horizontal position of the Camera viewport. Default 0. + * @param y The vertical position of the Camera viewport. Default 0. + * @param width The width of the Camera viewport. If not given it'll be the game config size. + * @param height The height of the Camera viewport. If not given it'll be the game config size. + * @param makeMain Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. Default false. + * @param name The name of the Camera. Default ''. + */ + add(x?: integer, y?: integer, width?: integer, height?: integer, makeMain?: boolean, name?: string): Phaser.Cameras.Scene2D.Camera; + + /** + * Adds an existing Camera into the Camera Manager. + * + * The Camera should either be a `Phaser.Cameras.Scene2D.Camera` instance, or a class that extends from it. + * + * The Camera will have its `roundPixels` property set to whatever `CameraManager.roundPixels` is. You can change + * it after addition if required. + * + * The Camera will be assigned an ID, which is used for Game Object exclusion and then added to the + * manager. As long as it doesn't already exist in the manager it will be added then returned. + * + * If this method returns `null` then the Camera already exists in this Camera Manager. + * @param camera The Camera to be added to the Camera Manager. + * @param makeMain Set this Camera as being the 'main' camera. This just makes the property `main` a reference to it. Default false. + */ + addExisting(camera: Phaser.Cameras.Scene2D.Camera, makeMain?: boolean): Phaser.Cameras.Scene2D.Camera; + + /** + * Gets the total number of Cameras in this Camera Manager. + * + * If the optional `isVisible` argument is set it will only count Cameras that are currently visible. + * @param isVisible Set the `true` to only include visible Cameras in the total. Default false. + */ + getTotal(isVisible?: boolean): integer; + + /** + * Populates this Camera Manager based on the given configuration object, or an array of config objects. + * + * See the `InputJSONCameraObject` documentation for details of the object structure. + * @param config A Camera configuration object, or an array of them, to be added to this Camera Manager. + */ + fromJSON(config: InputJSONCameraObject | InputJSONCameraObject[]): Phaser.Cameras.Scene2D.CameraManager; + + /** + * Gets a Camera based on its name. + * + * Camera names are optional and don't have to be set, so this method is only of any use if you + * have given your Cameras unique names. + * @param name The name of the Camera. + */ + getCamera(name: string): Phaser.Cameras.Scene2D.Camera; + + /** + * Returns an array of all cameras below the given Pointer. + * + * The first camera in the array is the top-most camera in the camera list. + * @param pointer The Pointer to check against. + */ + getCamerasBelowPointer(pointer: Phaser.Input.Pointer): Phaser.Cameras.Scene2D.Camera[]; + + /** + * Removes the given Camera, or an array of Cameras, from this Camera Manager. + * + * If found in the Camera Manager it will be immediately removed from the local cameras array. + * If also currently the 'main' camera, 'main' will be reset to be camera 0. + * + * The removed Cameras are automatically destroyed if the `runDestroy` argument is `true`, which is the default. + * If you wish to re-use the cameras then set this to `false`, but know that they will retain their references + * and internal data until destroyed or re-added to a Camera Manager. + * @param camera The Camera, or an array of Cameras, to be removed from this Camera Manager. + * @param runDestroy Automatically call `Camera.destroy` on each Camera removed from this Camera Manager. Default true. + */ + remove(camera: Phaser.Cameras.Scene2D.Camera | Phaser.Cameras.Scene2D.Camera[], runDestroy?: boolean): integer; + + /** + * The internal render method. This is called automatically by the Scene and should not be invoked directly. + * + * It will iterate through all local cameras and render them in turn, as long as they're visible and have + * an alpha level > 0. + * @param renderer The Renderer that will render the children to this camera. + * @param children An array of renderable Game Objects. + * @param interpolation Interpolation value. Reserved for future use. + */ + protected render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, children: Phaser.GameObjects.GameObject[], interpolation: number): void; + + /** + * Resets this Camera Manager. + * + * This will iterate through all current Cameras, destroying them all, then it will reset the + * cameras array, reset the ID counter and create 1 new single camera using the default values. + */ + resetAll(): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop. Called automatically when the Scene steps. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + protected update(time: integer, delta: number): void; + + /** + * Resizes all cameras to the given dimensions. + * @param width The new width of the camera. + * @param height The new height of the camera. + */ + resize(width: number, height: number): void; + + } + + namespace Effects { + /** + * A Camera Fade effect. + * + * This effect will fade the camera viewport to the given color, over the duration specified. + * + * Only the camera viewport is faded. None of the objects it is displaying are impacted, i.e. their colors do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect, if required. + */ + class Fade { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * Has this effect finished running? + * + * This is different from `isRunning` because it remains set to `true` when the effect is over, + * until the effect is either reset or started again. + */ + readonly isComplete: boolean; + + /** + * The direction of the fade. + * `true` = fade out (transparent to color), `false` = fade in (color to transparent) + */ + readonly direction: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * Fades the Camera to or from the given color over the duration specified. + * @param direction The direction of the fade. `true` = fade out (transparent to color), `false` = fade in (color to transparent) Default true. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(direction?: boolean, duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFadeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally by the Canvas Renderer. + * @param ctx The Canvas context to render to. + */ + postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; + + /** + * Called internally by the WebGL Renderer. + * @param pipeline The WebGL Pipeline to render to. + * @param getTintFunction A function that will return the gl safe tint colors. + */ + postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline, getTintFunction: Function): boolean; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Flash effect. + * + * This effect will flash the camera viewport to the given color, over the duration specified. + * + * Only the camera viewport is flashed. None of the objects it is displaying are impacted, i.e. their colors do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect, if required. + */ + class Flash { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * Flashes the Camera to or from the given color over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 250. + * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. + * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. + * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. + * @param force Force the effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFlashCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally by the Canvas Renderer. + * @param ctx The Canvas context to render to. + */ + postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; + + /** + * Called internally by the WebGL Renderer. + * @param pipeline The WebGL Pipeline to render to. + * @param getTintFunction A function that will return the gl safe tint colors. + */ + postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline, getTintFunction: Function): boolean; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Pan effect. + * + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * + * Only the camera scroll is moved. None of the objects it is displaying are impacted, i.e. their positions do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + */ + class Pan { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * The starting scroll coordinates to pan the camera from. + */ + source: Phaser.Math.Vector2; + + /** + * The constantly updated value based on zoom. + */ + current: Phaser.Math.Vector2; + + /** + * The destination scroll coordinates to pan the camera to. + */ + destination: Phaser.Math.Vector2; + + /** + * The ease function to use during the pan. + */ + ease: Function; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * This effect will scroll the Camera so that the center of its viewport finishes at the given destination, + * over the duration and with the ease specified. + * @param x The destination x coordinate to scroll the center of the Camera viewport to. + * @param y The destination y coordinate to scroll the center of the Camera viewport to. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the pan. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the pan effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent four arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * the current camera scroll x coordinate and the current camera scroll y coordinate. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(x: number, y: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraPanCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Shake effect. + * + * This effect will shake the camera viewport by a random amount, bounded by the specified intensity, each frame. + * + * Only the camera viewport is moved. None of the objects it is displaying are impacted, i.e. their positions do + * not change. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + */ + class Shake { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * The intensity of the effect. Use small float values. The default when the effect starts is 0.05. + * This is a Vector2 object, allowing you to control the shake intensity independently across x and y. + * You can modify this value while the effect is active to create more varied shake effects. + */ + intensity: Phaser.Math.Vector2; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * Shakes the Camera by the given intensity over the duration specified. + * @param duration The duration of the effect in milliseconds. Default 100. + * @param intensity The intensity of the shake. Default 0.05. + * @param force Force the shake effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(duration?: integer, intensity?: number, force?: boolean, callback?: CameraShakeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The pre-render step for this effect. Called automatically by the Camera. + */ + preRender(): void; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + /** + * A Camera Zoom effect. + * + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * + * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, + * which is invoked each frame for the duration of the effect if required. + */ + class Zoom { + /** + * + * @param camera The camera this effect is acting upon. + */ + constructor(camera: Phaser.Cameras.Scene2D.Camera); + + /** + * The Camera this effect belongs to. + */ + readonly camera: Phaser.Cameras.Scene2D.Camera; + + /** + * Is this effect actively running? + */ + readonly isRunning: boolean; + + /** + * The duration of the effect, in milliseconds. + */ + readonly duration: integer; + + /** + * The starting zoom value; + */ + source: number; + + /** + * The destination zoom value. + */ + destination: number; + + /** + * The ease function to use during the zoom. + */ + ease: Function; + + /** + * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. + */ + progress: number; + + /** + * This effect will zoom the Camera to the given scale, over the duration and with the ease specified. + * @param zoom The target Camera zoom value. + * @param duration The duration of the effect in milliseconds. Default 1000. + * @param ease The ease to use for the Zoom. Can be any of the Phaser Easing constants or a custom function. Default 'Linear'. + * @param force Force the zoom effect to start immediately, even if already running. Default false. + * @param callback This callback will be invoked every frame for the duration of the effect. + * It is sent three arguments: A reference to the camera, a progress amount between 0 and 1 indicating how complete the effect is, + * and the current camera zoom value. + * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. + */ + start(zoom: number, duration?: integer, ease?: string | Function, force?: boolean, callback?: CameraZoomCallback, context?: any): Phaser.Cameras.Scene2D.Camera; + + /** + * The main update loop for this effect. Called automatically by the Camera. + * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. + * @param delta The delta time, in ms, elapsed since the last frame. + */ + update(time: integer, delta: number): void; + + /** + * Called internally when the effect completes. + */ + effectComplete(): void; + + /** + * Resets this camera effect. + * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. + */ + reset(): void; + + /** + * Destroys this effect, releasing it from the Camera. + */ + destroy(): void; + + } + + } + + namespace Events { + /** + * The Destroy Camera Event. + * + * This event is dispatched by a Camera instance when it is destroyed by the Camera Manager. + */ + const DESTROY: any; + + /** + * The Camera Fade In Complete Event. + * + * This event is dispatched by a Camera instance when the Fade In Effect completes. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeincomplete', listener)`. + */ + const FADE_IN_COMPLETE: any; + + /** + * The Camera Fade In Start Event. + * + * This event is dispatched by a Camera instance when the Fade In Effect starts. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeinstart', listener)`. + */ + const FADE_IN_START: any; + + /** + * The Camera Fade Out Complete Event. + * + * This event is dispatched by a Camera instance when the Fade Out Effect completes. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeoutcomplete', listener)`. + */ + const FADE_OUT_COMPLETE: any; + + /** + * The Camera Fade Out Start Event. + * + * This event is dispatched by a Camera instance when the Fade Out Effect starts. + * + * Listen to it from a Camera instance using `Camera.on('camerafadeoutstart', listener)`. + */ + const FADE_OUT_START: any; + + /** + * The Camera Flash Complete Event. + * + * This event is dispatched by a Camera instance when the Flash Effect completes. + */ + const FLASH_COMPLETE: any; + + /** + * The Camera Flash Start Event. + * + * This event is dispatched by a Camera instance when the Flash Effect starts. + */ + const FLASH_START: any; + + /** + * The Camera Pan Complete Event. + * + * This event is dispatched by a Camera instance when the Pan Effect completes. + */ + const PAN_COMPLETE: any; + + /** + * The Camera Pan Start Event. + * + * This event is dispatched by a Camera instance when the Pan Effect starts. + */ + const PAN_START: any; + + /** + * The Camera Post-Render Event. + * + * This event is dispatched by a Camera instance after is has finished rendering. + * It is only dispatched if the Camera is rendering to a texture. + * + * Listen to it from a Camera instance using: `camera.on('postrender', listener)`. + */ + const POST_RENDER: any; + + /** + * The Camera Pre-Render Event. + * + * This event is dispatched by a Camera instance when it is about to render. + * It is only dispatched if the Camera is rendering to a texture. + * + * Listen to it from a Camera instance using: `camera.on('prerender', listener)`. + */ + const PRE_RENDER: any; + + /** + * The Camera Shake Complete Event. + * + * This event is dispatched by a Camera instance when the Shake Effect completes. + */ + const SHAKE_COMPLETE: any; + + /** + * The Camera Shake Start Event. + * + * This event is dispatched by a Camera instance when the Shake Effect starts. + */ + const SHAKE_START: any; + + /** + * The Camera Zoom Complete Event. + * + * This event is dispatched by a Camera instance when the Zoom Effect completes. + */ + const ZOOM_COMPLETE: any; + + /** + * The Camera Zoom Start Event. + * + * This event is dispatched by a Camera instance when the Zoom Effect starts. + */ + const ZOOM_START: any; + + } + + } + + namespace Controls { + /** + * A Fixed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using the defined keys. + * + * ```javascript + * var camControl = new FixedKeyControl({ + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * speed: float OR { x: 0, y: 0 } + * }); + * ``` + * + * Movement is precise and has no 'smoothing' applied to it. + * + * You must call the `update` method of this controller every frame. + */ + class FixedKeyControl { + /** + * + * @param config The Fixed Key Control configuration object. + */ + constructor(config: FixedKeyControlConfig); + + /** + * The Camera that this Control will update. + */ + camera: Phaser.Cameras.Scene2D.Camera; + + /** + * The Key to be pressed that will move the Camera left. + */ + left: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera right. + */ + right: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera up. + */ + up: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera down. + */ + down: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera in. + */ + zoomIn: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera out. + */ + zoomOut: Phaser.Input.Keyboard.Key; + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + */ + zoomSpeed: number; + + /** + * The horizontal speed the camera will move. + */ + speedX: number; + + /** + * The vertical speed the camera will move. + */ + speedY: number; + + /** + * A flag controlling if the Controls will update the Camera or not. + */ + active: boolean; + + /** + * Starts the Key Control running, providing it has been linked to a camera. + */ + start(): Phaser.Cameras.Controls.FixedKeyControl; + + /** + * Stops this Key Control from running. Call `start` to start it again. + */ + stop(): Phaser.Cameras.Controls.FixedKeyControl; + + /** + * Binds this Key Control to a camera. + * @param camera The camera to bind this Key Control to. + */ + setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.FixedKeyControl; + + /** + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(delta: number): void; + + /** + * Destroys this Key Control. + */ + destroy(): void; + + } + + /** + * A Smoothed Key Camera Control. + * + * This allows you to control the movement and zoom of a camera using the defined keys. + * Unlike the Fixed Camera Control you can also provide physics values for acceleration, drag and maxSpeed for smoothing effects. + * + * ```javascript + * + * var controlConfig = { + * camera: this.cameras.main, + * left: cursors.left, + * right: cursors.right, + * up: cursors.up, + * down: cursors.down, + * zoomIn: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.Q), + * zoomOut: this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.E), + * zoomSpeed: 0.02, + * acceleration: 0.06, + * drag: 0.0005, + * maxSpeed: 1.0 + * }; + * ``` + * + * You must call the `update` method of this controller every frame. + */ + class SmoothedKeyControl { + /** + * + * @param config The Smoothed Key Control configuration object. + */ + constructor(config: SmoothedKeyControlConfig); + + /** + * The Camera that this Control will update. + */ + camera: Phaser.Cameras.Scene2D.Camera; + + /** + * The Key to be pressed that will move the Camera left. + */ + left: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera right. + */ + right: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera up. + */ + up: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will move the Camera down. + */ + down: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera in. + */ + zoomIn: Phaser.Input.Keyboard.Key; + + /** + * The Key to be pressed that will zoom the Camera out. + */ + zoomOut: Phaser.Input.Keyboard.Key; + + /** + * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. + */ + zoomSpeed: number; + + /** + * The horizontal acceleration the camera will move. + */ + accelX: number; + + /** + * The vertical acceleration the camera will move. + */ + accelY: number; + + /** + * The horizontal drag applied to the camera when it is moving. + */ + dragX: number; + + /** + * The vertical drag applied to the camera when it is moving. + */ + dragY: number; + + /** + * The maximum horizontal speed the camera will move. + */ + maxSpeedX: number; + + /** + * The maximum vertical speed the camera will move. + */ + maxSpeedY: number; + + /** + * A flag controlling if the Controls will update the Camera or not. + */ + active: boolean; + + /** + * Starts the Key Control running, providing it has been linked to a camera. + */ + start(): Phaser.Cameras.Controls.SmoothedKeyControl; + + /** + * Stops this Key Control from running. Call `start` to start it again. + */ + stop(): Phaser.Cameras.Controls.SmoothedKeyControl; + + /** + * Binds this Key Control to a camera. + * @param camera The camera to bind this Key Control to. + */ + setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.SmoothedKeyControl; + + /** + * Applies the results of pressing the control keys to the Camera. + * + * You must call this every step, it is not called automatically. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. + */ + update(delta: number): void; + + /** + * Destroys this Key Control. + */ + destroy(): void; + + } + + } + + } + + /** + * Phaser Release Version + */ + var VERSION: string; + + /** + * AUTO Detect Renderer. + */ + var AUTO: integer; + + /** + * Canvas Renderer. + */ + var CANVAS: integer; + + /** + * WebGL Renderer. + */ + var WEBGL: integer; + + /** + * Headless Renderer. + */ + var HEADLESS: integer; + + /** + * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead + * to help you remember what the value is doing in your code. + */ + var FOREVER: integer; + + /** + * Direction constant. + */ + var NONE: integer; + + /** + * Direction constant. + */ + var UP: integer; + + /** + * Direction constant. + */ + var DOWN: integer; + + /** + * Direction constant. + */ + var LEFT: integer; + + /** + * Direction constant. + */ + var RIGHT: integer; + /** * The Phaser.Game instance is the main controller for the entire Phaser game. It is responsible * for handling the boot process, parsing the configuration values, creating the renderer, @@ -3931,13 +6351,23 @@ declare namespace Phaser { * * The values stored within this object are read-only and should not be changed at run-time. */ - readonly config: Phaser.Boot.Config; + readonly config: Phaser.Core.Config; /** * A reference to either the Canvas or WebGL Renderer that this Game is using. */ renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + /** + * A reference to an HTML Div Element used as a DOM Element Container. + * + * Only set if `createDOMContainer` is `true` in the game config (by default it is `false`) and + * if you provide a parent element to insert the Phaser Game inside. + * + * See the DOM Element Game Object for more details. + */ + domContainer: HTMLDivElement; + /** * A reference to the HTML Canvas Element that Phaser uses to render the game. * This is created automatically by Phaser unless you provide a `canvas` property @@ -4017,6 +6447,13 @@ declare namespace Phaser { */ device: Phaser.DeviceConf; + /** + * An instance of the Scale Manager. + * + * The Scale Manager is a global system responsible for handling scaling of the game canvas. + */ + scale: Phaser.Scale.ScaleManager; + /** * An instance of the base Sound Manager. * @@ -4030,7 +6467,7 @@ declare namespace Phaser { * The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing * them and calculating delta values. It then automatically calls the game step. */ - loop: Phaser.Boot.TimeStep; + loop: Phaser.Core.TimeStep; /** * An instance of the Plugin Manager. @@ -4040,18 +6477,20 @@ declare namespace Phaser { */ plugins: Phaser.Plugins.PluginManager; + /** + * An instance of the Facebook Instant Games Plugin. + * + * This will only be available if the plugin has been built into Phaser, + * or you're using the special Facebook Instant Games custom build. + */ + facebook: Phaser.FacebookInstantGamesPlugin; + /** * Does the window the game is running in currently have focus or not? * This is modified by the VisibilityHandler. */ readonly hasFocus: boolean; - /** - * Is the mouse pointer currently over the game canvas or not? - * This is modified by the VisibilityHandler. - */ - readonly isOver: boolean; - /** * This method is called automatically when the DOM is ready. It is responsible for creating the renderer, * displaying the Debug Header, adding the game canvas to the DOM and emitting the 'boot' event. @@ -4073,10 +6512,10 @@ declare namespace Phaser { * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. * * It will then render each Scene in turn, via the Renderer. This process emits `prerender` and `postrender` events. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ - step(time: integer, delta: number): void; + step(time: number, delta: number): void; /** * A special version of the Game Step for the HEADLESS renderer only. @@ -4087,10 +6526,10 @@ declare namespace Phaser { * The step will update the global managers first, then proceed to update each Scene in turn, via the Scene Manager. * * This process emits `prerender` and `postrender` events, even though nothing actually displays. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time elapsed since the last frame. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ - headlessStep(time: integer, delta: number): void; + headlessStep(time: number, delta: number): void; /** * Called automatically by the Visibility Handler. @@ -4117,25 +6556,33 @@ declare namespace Phaser { protected onFocus(): void; /** - * Updates the Game Config with the new width and height values given. - * Then resizes the Renderer and Input Manager scale. - * @param width The new width of the game. - * @param height The new height of the game. + * Returns the current game frame. + * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. */ - resize(width: number, height: number): void; + getFrame(): number; + + /** + * Returns the current game timestamp. + * When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires. + */ + getTime(): number; /** * Flags this Game instance as needing to be destroyed on the next frame. * It will wait until the current frame has completed and then call `runDestroy` internally. + * + * If you **do not** need to run Phaser again on the same web page you can set the `noReturn` argument to `true` and it will free-up + * memory being held by the core Phaser plugins. If you do need to create another game instance on the same page, leave this as `false`. * @param removeCanvas Set to `true` if you would like the parent canvas element removed from the DOM, or `false` to leave it in place. + * @param noReturn If `true` all the core Phaser plugins are destroyed. You cannot create another instance of Phaser on the same web page if you do this. Default false. */ - destroy(removeCanvas: boolean): void; + destroy(removeCanvas: boolean, noReturn?: boolean): void; } - namespace Boot { + namespace Core { /** - * [description] + * The active game configuration settings, parsed from a {@link GameConfig} object. */ class Config { /** @@ -4145,35 +6592,85 @@ declare namespace Phaser { constructor(GameConfig?: GameConfig); /** - * [description] + * The width of the underlying canvas, in pixels. */ readonly width: integer | string; /** - * [description] + * The height of the underlying canvas, in pixels. */ readonly height: integer | string; /** - * [description] + * The zoom factor, as used by the Scale Manager. */ - readonly zoom: number; + readonly zoom: Phaser.Scale.ZoomType | integer; /** - * [description] + * The canvas device pixel resolution. Currently un-used. */ readonly resolution: number; /** - * [description] - */ - readonly renderType: number; - - /** - * [description] + * A parent DOM element into which the canvas created by the renderer will be injected. */ readonly parent: any; + /** + * The scale mode as used by the Scale Manager. The default is zero, which is no scaling. + */ + readonly scaleMode: Phaser.Scale.ScaleModeType; + + /** + * Is the Scale Manager allowed to adjust the CSS height property of the parent to be 100%? + */ + readonly expandParent: boolean; + + /** + * Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices. + */ + readonly autoRound: integer; + + /** + * Automatically center the canvas within the parent? + */ + readonly autoCenter: Phaser.Scale.CenterType; + + /** + * How many ms should elapse before checking if the browser size has changed? + */ + readonly resizeInterval: integer; + + /** + * The DOM element that will be sent into full screen mode, or its `id`. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode. + */ + readonly fullscreenTarget: HTMLElement | string; + + /** + * The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + readonly minWidth: integer; + + /** + * The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + readonly maxWidth: integer; + + /** + * The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum. + */ + readonly minHeight: integer; + + /** + * The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum. + */ + readonly maxHeight: integer; + + /** + * Force Phaser to use a specific renderer. Can be `CONST.CANVAS`, `CONST.WEBGL`, `CONST.HEADLESS` or `CONST.AUTO` (default) + */ + readonly renderType: number; + /** * Force Phaser to use your own Canvas element instead of creating one. */ @@ -4185,257 +6682,287 @@ declare namespace Phaser { readonly context: CanvasRenderingContext2D | WebGLRenderingContext; /** - * [description] + * Optional CSS attributes to be set on the canvas object created by the renderer. */ readonly canvasStyle: string; /** - * [description] + * Is Phaser running under a custom (non-native web) environment? If so, set this to `true` to skip internal Feature detection. If `true` the `renderType` cannot be left as `AUTO`. + */ + readonly customEnvironment: boolean; + + /** + * The default Scene configuration object. */ readonly sceneConfig: object; /** - * [description] + * A seed which the Random Data Generator will use. If not given, a dynamic seed based on the time is used. */ readonly seed: string[]; /** - * [description] + * The title of the game. */ readonly gameTitle: string; /** - * [description] + * The URL of the game. */ readonly gameURL: string; /** - * [description] + * The version of the game. */ readonly gameVersion: string; /** - * [description] + * If `true` the window will automatically be given focus immediately and on any future mousedown event. */ readonly autoFocus: boolean; /** - * [description] + * EXPERIMENTAL: Do not currently use. + */ + readonly domCreateContainer: boolean; + + /** + * EXPERIMENTAL: Do not currently use. + */ + readonly domBehindCanvas: boolean; + + /** + * Enable the Keyboard Plugin. This can be disabled in games that don't need keyboard input. */ readonly inputKeyboard: boolean; /** - * [description] + * The DOM Target to listen for keyboard events on. Defaults to `window` if not specified. */ readonly inputKeyboardEventTarget: any; /** - * [description] + * `preventDefault` will be called on every non-modified key which has a key code in this array. By default, it is empty. + */ + readonly inputKeyboardCapture: integer[]; + + /** + * Enable the Mouse Plugin. This can be disabled in games that don't need mouse input. */ readonly inputMouse: boolean | object; /** - * [description] + * The DOM Target to listen for mouse events on. Defaults to the game canvas if not specified. */ readonly inputMouseEventTarget: any; /** - * [description] + * Should mouse events be captured? I.e. have prevent default called on them. */ readonly inputMouseCapture: boolean; /** - * [description] + * Enable the Touch Plugin. This can be disabled in games that don't need touch input. */ readonly inputTouch: boolean; /** - * [description] + * The DOM Target to listen for touch events on. Defaults to the game canvas if not specified. */ readonly inputTouchEventTarget: any; /** - * [description] + * Should touch events be captured? I.e. have prevent default called on them. */ readonly inputTouchCapture: boolean; /** - * [description] + * The number of Pointer objects created by default. In a mouse-only, or non-multi touch game, you can leave this as 1. */ readonly inputActivePointers: integer; /** - * [description] + * The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}. + */ + readonly inputSmoothFactor: integer; + + /** + * Should Phaser use a queued input system for native DOM Events or not? + */ + readonly inputQueue: boolean; + + /** + * Enable the Gamepad Plugin. This can be disabled in games that don't need gamepad input. */ readonly inputGamepad: boolean; /** - * [description] + * The DOM Target to listen for gamepad events on. Defaults to `window` if not specified. */ readonly inputGamepadEventTarget: any; /** - * [description] + * Set to `true` to disable the right-click context menu. */ readonly disableContextMenu: boolean; /** - * [description] + * The Audio Configuration object. */ - readonly audio: any; + readonly audio: AudioConfig; /** - * [description] + * Don't write the banner line to the console.log. */ readonly hideBanner: boolean; /** - * [description] + * Omit Phaser's name and version from the banner. */ readonly hidePhaser: boolean; /** - * [description] + * The color of the banner text. */ readonly bannerTextColor: string; /** - * [description] + * The background colors of the banner. */ readonly bannerBackgroundColor: string[]; /** - * [description] + * The Frame Rate Configuration object, as parsed by the Timestep class. */ readonly fps: FPSConfig; /** - * [description] + * When set to `true`, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to `false`, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. `false` also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled. */ readonly antialias: boolean; /** - * [description] - */ - readonly pixelArt: boolean; - - /** - * [description] - */ - readonly autoResize: boolean; - - /** - * [description] + * Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property. */ readonly roundPixels: boolean; /** - * [description] + * Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode). + */ + readonly pixelArt: boolean; + + /** + * Whether the game canvas will have a transparent background. */ readonly transparent: boolean; /** - * [description] + * Whether the game canvas will be cleared between each rendering frame. You can disable this if you have a full-screen background image or game object. */ - readonly zoclearBeforeRenderom: boolean; + readonly clearBeforeRender: boolean; /** - * [description] + * In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha. */ readonly premultipliedAlpha: boolean; /** - * [description] - */ - readonly preserveDrawingBuffer: boolean; - - /** - * [description] + * Let the browser abort creating a WebGL context if it judges performance would be unacceptable. */ readonly failIfMajorPerformanceCaveat: boolean; /** - * [description] + * "high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use. */ readonly powerPreference: string; /** - * [description] + * The default WebGL Batch size. + */ + readonly batchSize: integer; + + /** + * The maximum number of lights allowed to be visible within range of a single Camera in the LightManager. + */ + readonly maxLights: integer; + + /** + * The background color of the game canvas. The default is black. This value is ignored if `transparent` is set to `true`. */ readonly backgroundColor: Phaser.Display.Color; /** - * [description] + * Called before Phaser boots. Useful for initializing anything not related to Phaser that Phaser may require while booting. */ readonly preBoot: BootCallback; /** - * [description] + * A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded. */ readonly postBoot: BootCallback; /** - * [description] + * The Physics Configuration object. */ - readonly physics: object; + readonly physics: PhysicsConfig; /** - * [description] + * The default physics system. It will be started for each scene. Either 'arcade', 'impact' or 'matter'. */ - readonly defaultPhysicsSystem: boolean; + readonly defaultPhysicsSystem: boolean | string; /** - * [description] + * A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'. */ readonly loaderBaseURL: string; /** - * [description] + * A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'. */ readonly loaderPath: string; /** - * [description] + * Maximum parallel downloads allowed for resources (Default to 32). */ readonly loaderMaxParallelDownloads: integer; /** - * [description] + * 'anonymous', 'use-credentials', or `undefined`. If you're not making cross-origin requests, leave this as `undefined`. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}. */ readonly loaderCrossOrigin: string | undefined; /** - * [description] + * The response type of the XHR request, e.g. `blob`, `text`, etc. */ readonly loaderResponseType: string; /** - * [description] + * Should the XHR request use async or not? */ readonly loaderAsync: boolean; /** - * [description] + * Optional username for all XHR requests. */ readonly loaderUser: string; /** - * [description] + * Optional password for all XHR requests. */ readonly loaderPassword: string; /** - * [description] + * Optional XHR timeout value, in ms. */ readonly loaderTimeout: integer; /** - * [description] + * An array of global plugins to be installed. */ readonly installGlobalPlugins: any; /** - * [description] + * An array of Scene level plugins to be installed. */ readonly installScenePlugins: any; @@ -4445,12 +6972,12 @@ declare namespace Phaser { readonly defaultPlugins: any; /** - * [description] + * A base64 encoded PNG that will be used as the default blank texture. */ readonly defaultImage: string; /** - * [description] + * A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded. */ readonly missingImage: string; @@ -4472,6 +6999,130 @@ declare namespace Phaser { */ function DebugHeader(game: Phaser.Game): void; + namespace Events { + /** + * The Game Blur Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a blurred state. The blur event is raised when the window loses focus. This can happen if a user swaps + * tab, or if they simply remove focus from the browser to another app. + */ + const BLUR: any; + + /** + * The Game Boot Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, but before it is ready to start running. + * The global systems use this event to know when to set themselves up, dispatching their own `ready` events as required. + */ + const BOOT: any; + + /** + * The Game Destroy Event. + * + * This event is dispatched when the game instance has been told to destroy itself. + * Lots of internal systems listen to this event in order to clear themselves out. + * Custom plugins and game code should also do the same. + */ + const DESTROY: any; + + /** + * The Game Focus Event. + * + * This event is dispatched by the Game Visibility Handler when the window in which the Game instance is embedded + * enters a focused state. The focus event is raised when the window re-gains focus, having previously lost it. + */ + const FOCUS: any; + + /** + * The Game Hidden Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a hidden state. Only browsers that support the Visibility API will cause this event to be emitted. + * + * In most modern browsers, when the document enters a hidden state, the Request Animation Frame and setTimeout, which + * control the main game loop, will automatically pause. There is no way to stop this from happening. It is something + * your game should account for in its own code, should the pause be an issue (i.e. for multiplayer games) + */ + const HIDDEN: any; + + /** + * The Game Pause Event. + * + * This event is dispatched when the Game loop enters a paused state, usually as a result of the Visibility Handler. + */ + const PAUSE: any; + + /** + * The Game Post-Render Event. + * + * This event is dispatched right at the end of the render process. + * + * Every Scene will have rendered and been drawn to the canvas by the time this event is fired. + * Use it for any last minute post-processing before the next game step begins. + */ + const POST_RENDER: any; + + /** + * The Game Post-Step Event. + * + * This event is dispatched after the Scene Manager has updated. + * Hook into it from plugins or systems that need to do things before the render starts. + */ + const POST_STEP: any; + + /** + * The Game Pre-Render Event. + * + * This event is dispatched immediately before any of the Scenes have started to render. + * + * The renderer will already have been initialized this frame, clearing itself and preparing to receive the Scenes for rendering, but it won't have actually drawn anything yet. + */ + const PRE_RENDER: any; + + /** + * The Game Pre-Step Event. + * + * This event is dispatched before the main Game Step starts. By this point in the game cycle none of the Scene updates have yet happened. + * Hook into it from plugins or systems that need to update before the Scene Manager does. + */ + const PRE_STEP: any; + + /** + * The Game Ready Event. + * + * This event is dispatched when the Phaser Game instance has finished booting, the Texture Manager is fully ready, + * and all local systems are now able to start. + */ + const READY: any; + + /** + * The Game Resume Event. + * + * This event is dispatched when the game loop leaves a paused state and resumes running. + */ + const RESUME: any; + + /** + * The Game Step Event. + * + * This event is dispatched after the Game Pre-Step and before the Scene Manager steps. + * Hook into it from plugins or systems that need to update before the Scene Manager does, but after the core Systems have. + */ + const STEP: any; + + /** + * The Game Visible Event. + * + * This event is dispatched by the Game Visibility Handler when the document in which the Game instance is embedded + * enters a visible state, previously having been hidden. + * + * Only browsers that support the Visibility API will cause this event to be emitted. + */ + const VISIBLE: any; + + } + /** * [description] */ @@ -4662,7 +7313,7 @@ declare namespace Phaser { /** * Stops the TimeStep running. */ - stop(): Phaser.Boot.TimeStep; + stop(): Phaser.Core.TimeStep; /** * Destroys the TimeStep. This will stop Request Animation Frame, stop the step, clear the callbacks and null @@ -4682,1850 +7333,6 @@ declare namespace Phaser { } - namespace Cache { - /** - * The BaseCache is a base Cache class that can be used for storing references to any kind of data. - * - * Data can be added, retrieved and removed based on the given keys. - * - * Keys are string-based. - */ - class BaseCache { - /** - * The Map in which the cache objects are stored. - * - * You can query the Map directly or use the BaseCache methods. - */ - entries: Phaser.Structs.Map; - - /** - * An instance of EventEmitter used by the cache to emit related events. - */ - events: Phaser.Events.EventEmitter; - - /** - * Adds an item to this cache. The item is referenced by a unique string, which you are responsible - * for setting and keeping track of. The item can only be retrieved by using this string. - * @param key The unique key by which the data added to the cache will be referenced. - * @param data The data to be stored in the cache. - */ - add(key: string, data: any): Phaser.Cache.BaseCache; - - /** - * Checks if this cache contains an item matching the given key. - * This performs the same action as `BaseCache.exists`. - * @param key The unique key of the item to be checked in this cache. - */ - has(key: string): boolean; - - /** - * Checks if this cache contains an item matching the given key. - * This performs the same action as `BaseCache.has` and is called directly by the Loader. - * @param key The unique key of the item to be checked in this cache. - */ - exists(key: string): boolean; - - /** - * Gets an item from this cache based on the given key. - * @param key The unique key of the item to be retrieved from this cache. - */ - get(key: string): any; - - /** - * Removes and item from this cache based on the given key. - * - * If an entry matching the key is found it is removed from the cache and a `remove` event emitted. - * No additional checks are done on the item removed. If other systems or parts of your game code - * are relying on this item, it is up to you to sever those relationships prior to removing the item. - * @param key The unique key of the item to remove from the cache. - */ - remove(key: string): Phaser.Cache.BaseCache; - - /** - * Destroys this cache and all items within it. - */ - destroy(): void; - - } - - /** - * The Cache Manager is the global cache owned and maintained by the Game instance. - * - * Various systems, such as the file Loader, rely on this cache in order to store the files - * it has loaded. The manager itself doesn't store any files, but instead owns multiple BaseCache - * instances, one per type of file. You can also add your own custom caches. - */ - class CacheManager { - /** - * - * @param game A reference to the Phaser.Game instance that owns this CacheManager. - */ - constructor(game: Phaser.Game); - - /** - * A reference to the Phaser.Game instance that owns this CacheManager. - */ - protected game: Phaser.Game; - - /** - * A Cache storing all binary files, typically added via the Loader. - */ - binary: Phaser.Cache.BaseCache; - - /** - * A Cache storing all bitmap font data files, typically added via the Loader. - * Only the font data is stored in this cache, the textures are part of the Texture Manager. - */ - bitmapFont: Phaser.Cache.BaseCache; - - /** - * A Cache storing all JSON data files, typically added via the Loader. - */ - json: Phaser.Cache.BaseCache; - - /** - * A Cache storing all physics data files, typically added via the Loader. - */ - physics: Phaser.Cache.BaseCache; - - /** - * A Cache storing all shader source files, typically added via the Loader. - */ - shader: Phaser.Cache.BaseCache; - - /** - * A Cache storing all non-streaming audio files, typically added via the Loader. - */ - audio: Phaser.Cache.BaseCache; - - /** - * A Cache storing all text files, typically added via the Loader. - */ - text: Phaser.Cache.BaseCache; - - /** - * A Cache storing all WaveFront OBJ files, typically added via the Loader. - */ - obj: Phaser.Cache.BaseCache; - - /** - * A Cache storing all tilemap data files, typically added via the Loader. - * Only the data is stored in this cache, the textures are part of the Texture Manager. - */ - tilemap: Phaser.Cache.BaseCache; - - /** - * A Cache storing all xml data files, typically added via the Loader. - */ - xml: Phaser.Cache.BaseCache; - - /** - * An object that contains your own custom BaseCache entries. - * Add to this via the `addCustom` method. - */ - custom: {[key: string]: Phaser.Cache.BaseCache}; - - /** - * Add your own custom Cache for storing your own files. - * The cache will be available under `Cache.custom.key`. - * The cache will only be created if the key is not already in use. - * @param key The unique key of your custom cache. - */ - addCustom(key: string): Phaser.Cache.BaseCache; - - /** - * Removes all entries from all BaseCaches and destroys all custom caches. - */ - destroy(): void; - - } - - } - - namespace Cameras { - namespace Scene2D { - /** - * A Camera. - * - * The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, - * and can be positioned, rotated, zoomed and scrolled accordingly. - * - * A Camera consists of two elements: The viewport and the scroll values. - * - * The viewport is the physical position and size of the Camera within your game. Cameras, by default, are - * created the same size as your game, but their position and size can be set to anything. This means if you - * wanted to create a camera that was 320x200 in size, positioned in the bottom-right corner of your game, - * you'd adjust the viewport to do that (using methods like `setViewport` and `setSize`). - * - * If you wish to change where the Camera is looking in your game, then you scroll it. You can do this - * via the properties `scrollX` and `scrollY` or the method `setScroll`. Scrolling has no impact on the - * viewport, and changing the viewport has no impact on the scrolling. - * - * By default a Camera will render all Game Objects it can see. You can change this using the `ignore` method, - * allowing you to filter Game Objects out on a per-Camera basis. - * - * A Camera also has built-in special effects including Fade, Flash and Camera Shake. - */ - class Camera extends Phaser.Events.EventEmitter { - /** - * - * @param x The x position of the Camera, relative to the top-left of the game canvas. - * @param y The y position of the Camera, relative to the top-left of the game canvas. - * @param width The width of the Camera, in pixels. - * @param height The height of the Camera, in pixels. - */ - constructor(x: number, y: number, width: number, height: number); - - /** - * A reference to the Scene this camera belongs to. - */ - scene: Phaser.Scene; - - /** - * The name of the Camera. This is left empty for your own use. - */ - name: string; - - /** - * The x position of the Camera, relative to the top-left of the game canvas. - */ - x: number; - - /** - * The y position of the Camera, relative to the top-left of the game canvas. - */ - y: number; - - /** - * The width of the Camera, in pixels. - */ - width: number; - - /** - * The height of the Camera, in pixels. - */ - height: number; - - /** - * Should this camera round its pixel values to integers? - */ - roundPixels: boolean; - - /** - * Is this Camera visible or not? - * - * A visible camera will render and perform input tests. - * An invisible camera will not render anything and will skip input tests. - */ - visible: boolean; - - /** - * Is this Camera using a bounds to restrict scrolling movement? - * Set this property along with the bounds via `Camera.setBounds`. - */ - useBounds: boolean; - - /** - * Does this Camera allow the Game Objects it renders to receive input events? - */ - inputEnabled: boolean; - - /** - * The horizontal scroll position of this camera. - * Optionally restricted via the Camera bounds. - */ - scrollX: number; - - /** - * The vertical scroll position of this camera. - * Optionally restricted via the Camera bounds. - */ - scrollY: number; - - /** - * The Camera zoom value. Change this value to zoom in, or out of, a Scene. - * Set to 1 to return to the default zoom level. - */ - zoom: number; - - /** - * The rotation of the Camera. This influences the rendering of all Game Objects visible by this camera. - */ - rotation: number; - - /** - * A local transform matrix used for internal calculations. - */ - matrix: Phaser.GameObjects.Components.TransformMatrix; - - /** - * Does this Camera have a transparent background? - */ - transparent: boolean; - - /** - * The background color of this Camera. Only used if `transparent` is `false`. - */ - backgroundColor: Phaser.Display.Color; - - /** - * The Camera Fade effect handler. - * To fade this camera see the `Camera.fade` methods. - */ - fadeEffect: Phaser.Cameras.Scene2D.Effects.Fade; - - /** - * The Camera Flash effect handler. - * To flash this camera see the `Camera.flash` method. - */ - flashEffect: Phaser.Cameras.Scene2D.Effects.Flash; - - /** - * The Camera Shake effect handler. - * To shake this camera see the `Camera.shake` method. - */ - shakeEffect: Phaser.Cameras.Scene2D.Effects.Shake; - - /** - * Should the camera cull Game Objects before checking them for input hit tests? - * In some special cases it may be beneficial to disable this. - */ - disableCull: boolean; - - /** - * A temporary array of culled objects. - */ - culledObjects: Phaser.GameObjects.GameObject[]; - - /** - * The linear interpolation value to use when following a target. - * - * Can also be set via `setLerp` or as part of the `startFollow` call. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - */ - lerp: Phaser.Math.Vector2; - - /** - * The values stored in this property are subtracted from the Camera targets position, allowing you to - * offset the camera from the actual target x/y coordinates by this amount. - * Can also be set via `setFollowOffset` or as part of the `startFollow` call. - */ - followOffset: Phaser.Math.Vector2; - - /** - * Scrolls the Camera so that it is looking at the center of the Camera Bounds (if previously enabled) - */ - centerToBounds(): Phaser.Cameras.Scene2D.Camera; - - /** - * Scrolls the Camera so that it is re-centered based on its viewport size. - */ - centerToSize(): Phaser.Cameras.Scene2D.Camera; - - /** - * Takes an array of Game Objects and returns a new array featuring only those objects - * visible by this camera. - * @param renderableObjects An array of Game Objects to cull. - */ - cull(renderableObjects: G): G; - - /** - * Fades the Camera in from the given color over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fadeIn(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Fades the Camera out to the given color over the duration specified. - * This is an alias for Camera.fade that forces the fade to start, regardless of existing fades. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fadeOut(duration?: integer, red?: integer, green?: integer, blue?: integer, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Fades the Camera from the given color to transparent over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fadeFrom(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Fades the Camera from transparent to the given color over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - fade(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Flashes the Camera by setting it to the given color immediately and then fading it away again quickly over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 250. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - flash(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Shakes the Camera by the given intensity over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 100. - * @param intensity The intensity of the shake. Default 0.05. - * @param force Force the shake effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - shake(duration?: integer, intensity?: number, force?: boolean, callback?: Function, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * Converts the given `x` and `y` coordinates into World space, based on this Cameras transform. - * You can optionally provide a Vector2, or similar object, to store the results in. - * @param x The x position to convert to world space. - * @param y The y position to convert to world space. - * @param output An optional object to store the results in. If not provided a new Vector2 will be created. - */ - getWorldPoint(x: number, y: number, output?: O): O; - - /** - * Given a Game Object, or an array of Game Objects, it will update all of their camera filter settings - * so that they are ignored by this Camera. This means they will not be rendered by this Camera. - * @param gameObject The Game Object, or array of Game Objects, to be ignored by this Camera. - */ - ignore(gameObject: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.Cameras.Scene2D.Camera; - - /** - * Internal preRender step. - * @param baseScale The base scale, as set in the Camera Manager. - * @param resolution The game resolution. - */ - protected preRender(baseScale: number, resolution: number): void; - - /** - * If this Camera has previously had movement bounds set on it, this will remove them. - */ - removeBounds(): Phaser.Cameras.Scene2D.Camera; - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * @param value The cameras angle of rotation, given in degrees. Default 0. - */ - setAngle(value?: number): Phaser.Cameras.Scene2D.Camera; - - /** - * Sets the linear interpolation value to use when following a target. - * - * The default values of 1 means the camera will instantly snap to the target coordinates. - * A lower value, such as 0.1 means the camera will more slowly track the target, giving - * a smooth transition. You can set the horizontal and vertical values independently, and also - * adjust this value in real-time during your game. - * - * Be sure to keep the value between 0 and 1. A value of zero will disable tracking on that axis. - * @param x The amount added to the horizontal linear interpolation of the follow target. Default 1. - * @param y The amount added to the vertical linear interpolation of the follow target. Default 1. - */ - setLerp(x?: number, y?: number): this; - - /** - * Sets the horizontal and vertical offset of the camera from its follow target. - * The values are subtracted from the targets position during the Cameras update step. - * @param x The horizontal offset from the camera follow target.x position. Default 0. - * @param y The vertical offset from the camera follow target.y position. Default 0. - */ - setFollowOffset(x?: number, y?: number): this; - - /** - * Sets the background color for this Camera. - * - * By default a Camera has a transparent background but it can be given a solid color, with any level - * of transparency, via this method. - * - * The color value can be specified using CSS color notation, hex or numbers. - * @param color The color value. In CSS, hex or numeric color notation. Default 'rgba(0,0,0,0)'. - */ - setBackgroundColor(color?: string | number | InputColorObject): Phaser.Cameras.Scene2D.Camera; - - /** - * Set the world bounds for this Camera. - * - * A Camera bounds controls where the camera can scroll to within the world. It does not limit - * rendering of the camera, or placement of the viewport within your game. - * @param x The top-left x coordinate of the bounds. - * @param y The top-left y coordinate of the bounds. - * @param width The width of the bounds, in pixels. - * @param height The height of the bounds, in pixels. - */ - setBounds(x: integer, y: integer, width: integer, height: integer): Phaser.Cameras.Scene2D.Camera; - - /** - * Sets the name of this Camera. - * This value is for your own use and isn't used internally. - * @param value The name of the Camera. Default ''. - */ - setName(value?: string): Phaser.Cameras.Scene2D.Camera; - - /** - * Set the position of the Camera viewport within the game. - * - * This does not change where the camera is 'looking'. See `setScroll` to control that. - * @param x The top-left x coordinate of the Camera viewport. - * @param y The top-left y coordinate of the Camera viewport. Default x. - */ - setPosition(x: number, y?: number): Phaser.Cameras.Scene2D.Camera; - - /** - * Set the rotation of this Camera. This causes everything it renders to appear rotated. - * - * Rotating a camera does not rotate the viewport itself, it is applied during rendering. - * @param value The rotation of the Camera, in radians. Default 0. - */ - setRotation(value?: number): Phaser.Cameras.Scene2D.Camera; - - /** - * Should the Camera round pixel values to whole integers when scrolling? - * In some types of game this is required to prevent sub-pixel aliasing. - * @param value `true` to round Camera pixels, `false` to not. - */ - setRoundPixels(value: boolean): Phaser.Cameras.Scene2D.Camera; - - /** - * Sets the Scene the Camera is bound to. - * @param scene The Scene the camera is bound to. - */ - setScene(scene: Phaser.Scene): Phaser.Cameras.Scene2D.Camera; - - /** - * Set the position of where the Camera is looking within the game. - * You can also modify the properties `Camera.scrollX` and `Camera.scrollY` directly. - * Use this method, or the scroll properties, to move your camera around the game world. - * - * This does not change where the camera viewport is placed. See `setPosition` to control that. - * @param x The x coordinate of the Camera in the game world. - * @param y The y coordinate of the Camera in the game world. Default x. - */ - setScroll(x: number, y?: number): Phaser.Cameras.Scene2D.Camera; - - /** - * Set the size of the Camera viewport. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * @param width The width of the Camera viewport. - * @param height The height of the Camera viewport. Default width. - */ - setSize(width: integer, height?: integer): Phaser.Cameras.Scene2D.Camera; - - /** - * This method sets the position and size of the Camera viewport in a single call. - * - * If you're trying to change where the Camera is looking at in your game, then see - * the method `Camera.setScroll` instead. This method is for changing the viewport - * itself, not what the camera can see. - * - * By default a Camera is the same size as the game, but can be made smaller via this method, - * allowing you to create mini-cam style effects by creating and positioning a smaller Camera - * viewport within your game. - * @param x The top-left x coordinate of the Camera viewport. - * @param y The top-left y coordinate of the Camera viewport. - * @param width The width of the Camera viewport. - * @param height The height of the Camera viewport. Default width. - */ - setViewport(x: number, y: number, width: integer, height?: integer): Phaser.Cameras.Scene2D.Camera; - - /** - * Set the zoom value of the Camera. - * - * Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. - * Changing to a larger value, such as 2, will cause the camera to 'zoom in'. - * - * A value of 1 means 'no zoom' and is the default. - * - * Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. - * @param value The zoom value of the Camera. Default 1. - */ - setZoom(value?: number): Phaser.Cameras.Scene2D.Camera; - - /** - * Sets the visibility of this Camera. - * - * An invisible Camera will skip rendering and input tests of everything it can see. - * @param value The visible state of the Camera. - */ - setVisible(value: boolean): this; - - /** - * Sets the Camera to follow a Game Object. - * - * When enabled the Camera will automatically adjust its scroll position to keep the target Game Object - * in its center. - * - * You can set the linear interpolation value used in the follow code. - * Use low lerp values (such as 0.1) to automatically smooth the camera motion. - * - * If you find you're getting a slight "jitter" effect when following an object it's probably to do with sub-pixel - * rendering of the targets position. This can be rounded by setting the `roundPixels` argument to `true` to - * force full pixel rounding rendering. Note that this can still be broken if you have specified a non-integer zoom - * value on the camera. So be sure to keep the camera zoom to integers. - * @param target The target for the Camera to follow. - * @param roundPixels Round the camera position to whole integers to avoid sub-pixel rendering? Default false. - * @param lerpX A value between 0 and 1. This value specifies the amount of linear interpolation to use when horizontally tracking the target. The closer the value to 1, the faster the camera will track. Default 1. - * @param lerpY A value between 0 and 1. This value specifies the amount of linear interpolation to use when vertically tracking the target. The closer the value to 1, the faster the camera will track. Default 1. - * @param offsetX The horizontal offset from the camera follow target.x position. Default 0. - * @param offsetY The vertical offset from the camera follow target.y position. Default 0. - */ - startFollow(target: Phaser.GameObjects.GameObject | object, roundPixels?: boolean, lerpX?: number, lerpY?: number, offsetX?: number, offsetY?: number): this; - - /** - * Stops a Camera from following a Game Object, if previously set via `Camera.startFollow`. - */ - stopFollow(): Phaser.Cameras.Scene2D.Camera; - - /** - * Returns an Object suitable for JSON storage containing all of the Camera viewport and rendering properties. - */ - toJSON(): JSONCamera; - - /** - * Resets any active FX, such as a fade, flash or shake. Useful to call after a fade in order to - * remove the fade. - */ - resetFX(): Phaser.Cameras.Scene2D.Camera; - - /** - * Internal method called automatically by the Camera Manager. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - protected update(time: integer, delta: number): void; - - /** - * Destroys this Camera instance. You rarely need to call this directly. - * - * Called by the Camera Manager. If you wish to destroy a Camera please use `CameraManager.remove` as - * cameras are stored in a pool, ready for recycling later, and calling this directly will prevent that. - */ - destroy(): void; - - /** - * The x position of the center of the Camera's viewport, relative to the top-left of the game canvas. - */ - readonly centerX: number; - - /** - * The y position of the center of the Camera's viewport, relative to the top-left of the game canvas. - */ - readonly centerY: number; - - } - - /** - * [description] - */ - class CameraManager { - /** - * - * @param scene The Scene that owns the Camera Manager plugin. - */ - constructor(scene: Phaser.Scene); - - /** - * The Scene that owns the Camera Manager plugin. - */ - scene: Phaser.Scene; - - /** - * A reference to the Scene.Systems handler for the Scene that owns the Camera Manager. - */ - systems: Phaser.Scenes.Systems; - - /** - * The current Camera ID. - */ - readonly currentCameraId: number; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - */ - cameras: Phaser.Cameras.Scene2D.Camera[]; - - /** - * A pool of Camera objects available to be used by the Camera Manager. - */ - cameraPool: Phaser.Cameras.Scene2D.Camera[]; - - /** - * The default Camera in the Camera Manager. - */ - main: Phaser.Cameras.Scene2D.Camera; - - /** - * This scale affects all cameras. It's used by Scale Manager. - */ - baseScale: number; - - /** - * [description] - * @param x [description] Default 0. - * @param y [description] Default 0. - * @param width [description] - * @param height [description] - * @param makeMain [description] Default false. - * @param name [description] Default ''. - */ - add(x?: number, y?: number, width?: number, height?: number, makeMain?: boolean, name?: string): Phaser.Cameras.Scene2D.Camera; - - /** - * [description] - * @param camera [description] - */ - addExisting(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Scene2D.Camera; - - /** - * [description] - * @param config [description] - */ - fromJSON(config: InputJSONCameraObject | InputJSONCameraObject[]): Phaser.Cameras.Scene2D.CameraManager; - - /** - * [description] - * @param name [description] - */ - getCamera(name: string): Phaser.Cameras.Scene2D.Camera; - - /** - * Returns an array of all cameras below the given Pointer. - * - * The first camera in the array is the top-most camera in the camera list. - * @param pointer The Pointer to check against. - */ - getCamerasBelowPointer(pointer: Phaser.Input.Pointer): Phaser.Cameras.Scene2D.Camera[]; - - /** - * [description] - * @param camera [description] - */ - remove(camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param renderer The Renderer that will render the children to this camera. - * @param children An array of renderable Game Objects. - * @param interpolation Interpolation value. Reserved for future use. - */ - render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, children: Phaser.GameObjects.GameObject[], interpolation: number): void; - - /** - * [description] - */ - resetAll(): Phaser.Cameras.Scene2D.Camera; - - /** - * [description] - * @param timestep [description] - * @param delta [description] - */ - update(timestep: number, delta: number): void; - - /** - * Resizes all cameras to the given dimensions. - * @param width The new width of the camera. - * @param height The new height of the camera. - */ - resize(width: number, height: number): void; - - } - - namespace Effects { - /** - * A Camera Fade effect. - * - * This effect will fade the camera viewport to the given color, over the duration specified. - * - * Only the camera viewport is faded. None of the objects it is displaying are impacted, i.e. their colors do - * not change. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect, if required. - */ - class Fade { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * Has this effect finished running? - * - * This is different from `isRunning` because it remains set to `true` when the effect is over, - * until the effect is either reset or started again. - */ - readonly isComplete: boolean; - - /** - * The direction of the fade. - * `true` = fade out (transparent to color), `false` = fade in (color to transparent) - */ - readonly direction: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * Fades the Camera to or from the given color over the duration specified. - * @param direction The direction of the fade. `true` = fade out (transparent to color), `false` = fade in (color to transparent) Default true. - * @param duration The duration of the effect in milliseconds. Default 1000. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 0. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 0. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 0. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(direction?: boolean, duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFadeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally by the Canvas Renderer. - * @param ctx The Canvas context to render to. - */ - postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; - - /** - * Called internally by the WebGL Renderer. - * @param pipeline The WebGL Pipeline to render to. - * @param getTintFunction A function that will return the gl safe tint colors. - */ - postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline, getTintFunction: Function): boolean; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - /** - * A Camera Flash effect. - * - * This effect will flash the camera viewport to the given color, over the duration specified. - * - * Only the camera viewport is flashed. None of the objects it is displaying are impacted, i.e. their colors do - * not change. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect, if required. - */ - class Flash { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * Flashes the Camera to or from the given color over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 250. - * @param red The amount to fade the red channel towards. A value between 0 and 255. Default 255. - * @param green The amount to fade the green channel towards. A value between 0 and 255. Default 255. - * @param blue The amount to fade the blue channel towards. A value between 0 and 255. Default 255. - * @param force Force the effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(duration?: integer, red?: integer, green?: integer, blue?: integer, force?: boolean, callback?: CameraFlashCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally by the Canvas Renderer. - * @param ctx The Canvas context to render to. - */ - postRenderCanvas(ctx: CanvasRenderingContext2D): boolean; - - /** - * Called internally by the WebGL Renderer. - * @param pipeline The WebGL Pipeline to render to. - * @param getTintFunction A function that will return the gl safe tint colors. - */ - postRenderWebGL(pipeline: Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline, getTintFunction: Function): boolean; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - /** - * A Camera Shake effect. - * - * This effect will shake the camera viewport by a random amount, bounded by the specified intensity, each frame. - * - * Only the camera viewport is moved. None of the objects it is displaying are impacted, i.e. their positions do - * not change. - * - * The effect will dispatch several events on the Camera itself and you can also specify an `onUpdate` callback, - * which is invoked each frame for the duration of the effect if required. - */ - class Shake { - /** - * - * @param camera The camera this effect is acting upon. - */ - constructor(camera: Phaser.Cameras.Scene2D.Camera); - - /** - * The Camera this effect belongs to. - */ - readonly camera: Phaser.Cameras.Scene2D.Camera; - - /** - * Is this effect actively running? - */ - readonly isRunning: boolean; - - /** - * The duration of the effect, in milliseconds. - */ - readonly duration: integer; - - /** - * The intensity of the effect. Use small float values. The default when the effect starts is 0.05. - * This is a Vector2 object, allowing you to control the shake intensity independently across x and y. - * You can modify this value while the effect is active to create more varied shake effects. - */ - intensity: Phaser.Math.Vector2; - - /** - * If this effect is running this holds the current percentage of the progress, a value between 0 and 1. - */ - progress: number; - - /** - * Shakes the Camera by the given intensity over the duration specified. - * @param duration The duration of the effect in milliseconds. Default 100. - * @param intensity The intensity of the shake. Default 0.05. - * @param force Force the shake effect to start immediately, even if already running. Default false. - * @param callback This callback will be invoked every frame for the duration of the effect. - * It is sent two arguments: A reference to the camera and a progress amount between 0 and 1 indicating how complete the effect is. - * @param context The context in which the callback is invoked. Defaults to the Scene to which the Camera belongs. - */ - start(duration?: integer, intensity?: number, force?: boolean, callback?: CameraShakeCallback, context?: any): Phaser.Cameras.Scene2D.Camera; - - /** - * The pre-render step for this effect. Called automatically by the Camera. - */ - preRender(): void; - - /** - * The main update loop for this effect. Called automatically by the Camera. - * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(time: integer, delta: number): void; - - /** - * Called internally when the effect completes. - */ - effectComplete(): void; - - /** - * Resets this camera effect. - * If it was previously running, it stops instantly without calling its onComplete callback or emitting an event. - */ - reset(): void; - - /** - * Destroys this effect, releasing it from the Camera. - */ - destroy(): void; - - } - - } - - } - - namespace Controls { - /** - * [description] - */ - class FixedKeyControl { - /** - * - * @param config [description] - */ - constructor(config: FixedKeyControlConfig); - - /** - * The Camera that this Control will update. - */ - camera: Phaser.Cameras.Scene2D.Camera; - - /** - * The Key to be pressed that will move the Camera left. - */ - left: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera right. - */ - right: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera up. - */ - up: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera down. - */ - down: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera in. - */ - zoomIn: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera out. - */ - zoomOut: Phaser.Input.Keyboard.Key; - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - */ - zoomSpeed: number; - - /** - * The horizontal speed the camera will move. - */ - speedX: number; - - /** - * The vertical speed the camera will move. - */ - speedY: number; - - /** - * A flag controlling if the Controls will update the Camera or not. - */ - active: boolean; - - /** - * Starts the Key Control running, providing it has been linked to a camera. - */ - start(): Phaser.Cameras.Controls.FixedKeyControl; - - /** - * Stops this Key Control from running. Call `start` to start it again. - */ - stop(): Phaser.Cameras.Controls.FixedKeyControl; - - /** - * Binds this Key Control to a camera. - * @param camera The camera to bind this Key Control to. - */ - setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.FixedKeyControl; - - /** - * [description] - * @param delta [description] - */ - update(delta: number): void; - - /** - * Destroys this Key Control. - */ - destroy(): void; - - } - - /** - * [description] - */ - class SmoothedKeyControl { - /** - * - * @param config [description] - */ - constructor(config: SmoothedKeyControlConfig); - - /** - * The Camera that this Control will update. - */ - camera: Phaser.Cameras.Scene2D.Camera; - - /** - * The Key to be pressed that will move the Camera left. - */ - left: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera right. - */ - right: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera up. - */ - up: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will move the Camera down. - */ - down: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera in. - */ - zoomIn: Phaser.Input.Keyboard.Key; - - /** - * The Key to be pressed that will zoom the Camera out. - */ - zoomOut: Phaser.Input.Keyboard.Key; - - /** - * The speed at which the camera will zoom if the `zoomIn` or `zoomOut` keys are pressed. - */ - zoomSpeed: number; - - /** - * The horizontal acceleration the camera will move. - */ - accelX: number; - - /** - * The vertical acceleration the camera will move. - */ - accelY: number; - - /** - * The horizontal drag applied to the camera when it is moving. - */ - dragX: number; - - /** - * The vertical drag applied to the camera when it is moving. - */ - dragY: number; - - /** - * The maximum horizontal speed the camera will move. - */ - maxSpeedX: number; - - /** - * The maximum vertical speed the camera will move. - */ - maxSpeedY: number; - - /** - * A flag controlling if the Controls will update the Camera or not. - */ - active: boolean; - - /** - * Starts the Key Control running, providing it has been linked to a camera. - */ - start(): Phaser.Cameras.Controls.SmoothedKeyControl; - - /** - * Stops this Key Control from running. Call `start` to start it again. - */ - stop(): Phaser.Cameras.Controls.SmoothedKeyControl; - - /** - * Binds this Key Control to a camera. - * @param camera The camera to bind this Key Control to. - */ - setCamera(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Cameras.Controls.SmoothedKeyControl; - - /** - * [description] - * @param delta The delta time, in ms, elapsed since the last frame. - */ - update(delta: number): void; - - /** - * Destroys this Key Control. - */ - destroy(): void; - - } - - } - - namespace Sprite3D { - /** - * [description] - */ - class Camera { - /** - * - * @param scene [description] - */ - constructor(scene: Phaser.Scene); - - /** - * [description] - * @param x [description] - * @param y [description] - * @param z [description] - */ - setPosition(x: number, y: number, z: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param scene [description] - */ - setScene(scene: Phaser.Scene): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param value [description] - */ - setPixelScale(value: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param sprite3D [description] - */ - add(sprite3D: Phaser.GameObjects.Sprite3D): Phaser.GameObjects.Sprite3D; - - /** - * [description] - * @param child [description] - */ - remove(child: Phaser.GameObjects.GameObject): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - */ - clear(): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - */ - getChildren(): any[]; - - /** - * [description] - * @param x [description] - * @param y [description] - * @param z [description] - * @param key [description] - * @param frame [description] - * @param visible [description] Default true. - */ - create(x: number, y: number, z: number, key: string, frame: string | number, visible?: boolean): Phaser.GameObjects.Sprite3D; - - /** - * [description] - * @param quantity [description] - * @param key [description] - * @param frame [description] - * @param visible [description] Default true. - */ - createMultiple(quantity: number, key: string, frame: string | number, visible?: boolean): Phaser.GameObjects.Sprite3D[]; - - /** - * [description] - * @param size [description] - * @param spacing [description] - * @param key [description] - * @param frame [description] - */ - createRect(size: number | Object, spacing: number | Object, key: string, frame?: string | number): Phaser.GameObjects.Sprite3D[]; - - /** - * [description] - * @param radius [description] Default 1. - * @param sprites [description] - */ - randomSphere(radius?: number, sprites?: Phaser.GameObjects.Sprite3D[]): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param scale [description] Default 1. - * @param sprites [description] - */ - randomCube(scale?: number, sprites?: Phaser.GameObjects.Sprite3D[]): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param vec3 [description] - * @param sprites [description] - */ - translateChildren(vec3: Phaser.Math.Vector3, sprites: Phaser.GameObjects.Sprite3D[]): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param mat4 [description] - * @param sprites [description] - */ - transformChildren(mat4: Phaser.Math.Matrix4, sprites: Phaser.GameObjects.Sprite3D[]): Phaser.Cameras.Sprite3D.Camera; - - /** - * Sets the width and height of the viewport. Does not update any matrices. - * @param width [description] - * @param height [description] - */ - setViewport(width: number, height: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * Translates this camera by a specified Vector3 object - * or x, y, z parameters. Any undefined x y z values will - * default to zero, leaving that component unaffected. - * If you wish to set the camera position directly call setPosition instead. - * @param x [description] - * @param y [description] - * @param z [description] - */ - translate(x: number | object, y?: number, z?: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param x [description] - * @param y [description] - * @param z [description] - */ - lookAt(x: number | object, y?: number, z?: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param radians [description] - * @param axis [description] - */ - rotate(radians: number, axis: Phaser.Math.Vector3): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param point [description] - * @param radians [description] - * @param axis [description] - */ - rotateAround(point: Phaser.Math.Vector3, radians: number, axis: Phaser.Math.Vector3): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param vec [description] - * @param out [description] - */ - project(vec: Phaser.Math.Vector3, out: Phaser.Math.Vector4): Phaser.Math.Vector4; - - /** - * [description] - * @param vec [description] - * @param out [description] - */ - unproject(vec: Phaser.Math.Vector4, out: Phaser.Math.Vector3): Phaser.Math.Vector3; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - getPickRay(x: number, y?: number): RayDef; - - /** - * [description] - */ - updateChildren(): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - */ - update(): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - */ - updateBillboardMatrix(): void; - - /** - * This is a utility function for canvas 3D rendering, - * which determines the "point size" of a camera-facing - * sprite billboard given its 3D world position - * (origin at center of sprite) and its world width - * and height in x/y. - * - * We place into the output Vector2 the scaled width - * and height. If no `out` is specified, a new Vector2 - * will be created for convenience (this should be avoided - * in tight loops). - * @param vec The position of the 3D Sprite. - * @param size The x and y dimensions. - * @param out The result, scaled x and y dimensions. - */ - getPointSize(vec: Phaser.Math.Vector2, size: Phaser.Math.Vector2, out: Phaser.Math.Vector2): Phaser.Math.Vector2; - - /** - * [description] - */ - destroy(): void; - - /** - * [description] - * @param value [description] - */ - setX(value: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param value [description] - */ - setY(value: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - * @param value [description] - */ - setZ(value: number): Phaser.Cameras.Sprite3D.Camera; - - /** - * [description] - */ - x: number; - - /** - * [description] - */ - y: number; - - /** - * [description] - */ - z: number; - - } - - /** - * [description] - */ - var scene: Phaser.Scene; - - /** - * [description] - */ - var displayList: Phaser.GameObjects.DisplayList; - - /** - * [description] - */ - var updateList: Phaser.GameObjects.UpdateList; - - /** - * [description] - */ - var name: string; - - /** - * [description] - */ - var direction: Phaser.Math.Vector3; - - /** - * [description] - */ - var up: Phaser.Math.Vector3; - - /** - * [description] - */ - var position: Phaser.Math.Vector3; - - /** - * [description] - */ - var pixelScale: number; - - /** - * [description] - */ - var projection: Phaser.Math.Matrix4; - - /** - * [description] - */ - var view: Phaser.Math.Matrix4; - - /** - * [description] - */ - var combined: Phaser.Math.Matrix4; - - /** - * [description] - */ - var invProjectionView: Phaser.Math.Matrix4; - - /** - * [description] - */ - var near: number; - - /** - * [description] - */ - var far: number; - - /** - * [description] - */ - var ray: RayDef; - - /** - * [description] - */ - var viewportWidth: number; - - /** - * [description] - */ - var viewportHeight: number; - - /** - * [description] - */ - var billboardMatrixDirty: boolean; - - /** - * [description] - */ - var children: Phaser.Structs.Set; - - /** - * [description] - */ - class CameraManager { - /** - * - * @param scene [description] - */ - constructor(scene: Phaser.Scene); - - /** - * [description] - */ - scene: Phaser.Scene; - - /** - * [description] - */ - systems: Phaser.Scenes.Systems; - - /** - * An Array of the Camera objects being managed by this Camera Manager. - */ - cameras: Phaser.Cameras.Sprite3D.Camera[]; - - /** - * [description] - * @param fieldOfView [description] Default 80. - * @param width [description] - * @param height [description] - */ - add(fieldOfView?: number, width?: number, height?: number): Phaser.Cameras.Sprite3D.PerspectiveCamera; - - /** - * [description] - * @param width [description] - * @param height [description] - */ - addOrthographicCamera(width: number, height: number): Phaser.Cameras.Sprite3D.OrthographicCamera; - - /** - * [description] - * @param fieldOfView [description] Default 80. - * @param width [description] - * @param height [description] - */ - addPerspectiveCamera(fieldOfView?: number, width?: number, height?: number): Phaser.Cameras.Sprite3D.PerspectiveCamera; - - /** - * [description] - * @param name [description] - */ - getCamera(name: string): Phaser.Cameras.Sprite3D.OrthographicCamera | Phaser.Cameras.Sprite3D.PerspectiveCamera; - - /** - * [description] - * @param camera [description] - */ - removeCamera(camera: Phaser.Cameras.Sprite3D.OrthographicCamera | Phaser.Cameras.Sprite3D.PerspectiveCamera): void; - - /** - * [description] - */ - removeAll(): Phaser.Cameras.Sprite3D.OrthographicCamera | Phaser.Cameras.Sprite3D.PerspectiveCamera; - - /** - * [description] - * @param timestep [description] - * @param delta [description] - */ - update(timestep: number, delta: number): void; - - } - - /** - * [description] - */ - class OrthographicCamera extends Phaser.Cameras.Sprite3D.Camera { - /** - * - * @param scene [description] - * @param viewportWidth [description] Default 0. - * @param viewportHeight [description] Default 0. - */ - constructor(scene: Phaser.Scene, viewportWidth?: integer, viewportHeight?: integer); - - /** - * [description] - */ - viewportWidth: integer; - - /** - * [description] - */ - viewportHeight: integer; - - /** - * [description] - */ - near: number; - - /** - * [description] - * @param yDown [description] - * @param viewportWidth [description] - * @param viewportHeight [description] - */ - setToOrtho(yDown: number, viewportWidth?: number, viewportHeight?: number): Phaser.Cameras.Sprite3D.OrthographicCamera; - - /** - * [description] - */ - update(): Phaser.Cameras.Sprite3D.OrthographicCamera; - - /** - * [description] - */ - zoom: number; - - } - - /** - * [description] - */ - class PerspectiveCamera extends Phaser.Cameras.Sprite3D.Camera { - /** - * - * @param scene [description] - * @param fieldOfView [description] Default 80. - * @param viewportWidth [description] Default 0. - * @param viewportHeight [description] Default 0. - */ - constructor(scene: Phaser.Scene, fieldOfView?: integer, viewportWidth?: integer, viewportHeight?: integer); - - /** - * [description] - */ - viewportWidth: integer; - - /** - * [description] - */ - viewportHeight: integer; - - /** - * [description] - */ - fieldOfView: integer; - - /** - * [description] - * @param value [description] - */ - setFOV(value: number): Phaser.Cameras.Sprite3D.PerspectiveCamera; - - /** - * [description] - */ - update(): Phaser.Cameras.Sprite3D.PerspectiveCamera; - - } - - } - - } - - /** - * Phaser Release Version - */ - var VERSION: string; - - /** - * AUTO Detect Renderer. - */ - var AUTO: integer; - - /** - * Canvas Renderer. - */ - var CANVAS: integer; - - /** - * WebGL Renderer. - */ - var WEBGL: integer; - - /** - * Headless Renderer. - */ - var HEADLESS: integer; - - /** - * In Phaser the value -1 means 'forever' in lots of cases, this const allows you to use it instead - * to help you remember what the value is doing in your code. - */ - var FOREVER: integer; - - /** - * Direction constant. - */ - var NONE: integer; - - /** - * Direction constant. - */ - var UP: integer; - - /** - * Direction constant. - */ - var DOWN: integer; - - /** - * Direction constant. - */ - var LEFT: integer; - - /** - * Direction constant. - */ - var RIGHT: integer; - namespace Create { /** * [description] @@ -6565,7 +7372,7 @@ declare namespace Phaser { namespace Curves { /** - * [description] + * A higher-order Bézier curve constructed of four points. */ class CubicBezier extends Phaser.Curves.Curve { /** @@ -6578,22 +7385,22 @@ declare namespace Phaser { constructor(p0: Phaser.Math.Vector2 | Phaser.Math.Vector2[], p1: Phaser.Math.Vector2, p2: Phaser.Math.Vector2, p3: Phaser.Math.Vector2); /** - * [description] + * The start point of this curve. */ p0: Phaser.Math.Vector2; /** - * [description] + * The first control point of this curve. */ p1: Phaser.Math.Vector2; /** - * [description] + * The second control point of this curve. */ p2: Phaser.Math.Vector2; /** - * [description] + * The end point of this curve. */ p3: Phaser.Math.Vector2; @@ -6604,7 +7411,7 @@ declare namespace Phaser { getStartPoint(out?: O): O; /** - * [description] + * Returns the resolution of this curve. * @param divisions The amount of divisions used by this curve. */ getResolution(divisions: number): number; @@ -6617,19 +7424,19 @@ declare namespace Phaser { getPoint(t: number, out?: O): O; /** - * [description] - * @param graphics [description] - * @param pointsTotal [description] Default 32. + * Draws this curve to the specified graphics object. + * @param graphics The graphics object this curve should be drawn to. + * @param pointsTotal The number of intermediary points that make up this curve. A higher number of points will result in a smoother curve. Default 32. */ draw(graphics: G, pointsTotal?: integer): G; /** - * [description] + * Returns a JSON object that describes this curve. */ toJSON(): JSONCurve; /** - * [description] + * Generates a curve from a JSON object. * @param data The JSON object containing this curve data. */ static fromJSON(data: JSONCurve): Phaser.Curves.CubicBezier; @@ -6707,9 +7514,9 @@ declare namespace Phaser { /** * [description] - * @param out [description] + * @param out Optional Vector object to store the result in. */ - getEndPoint(out: Phaser.Math.Vector2): Phaser.Math.Vector2; + getEndPoint(out?: Phaser.Math.Vector2): Phaser.Math.Vector2; /** * [description] @@ -6790,24 +7597,26 @@ declare namespace Phaser { } /** - * [description] + * An Elliptical Curve derived from the Base Curve class. + * + * See https://en.wikipedia.org/wiki/Elliptic_curve for more details. */ class Ellipse extends Phaser.Curves.Curve { /** * - * @param x [description] Default 0. - * @param y [description] Default 0. - * @param xRadius [description] Default 0. - * @param yRadius [description] Default 0. - * @param startAngle [description] Default 0. - * @param endAngle [description] Default 360. - * @param clockwise [description] Default false. - * @param rotation [description] Default 0. + * @param x The x coordinate of the ellipse, or an Ellipse Curve configuration object. Default 0. + * @param y The y coordinate of the ellipse. Default 0. + * @param xRadius The horizontal radius of ellipse. Default 0. + * @param yRadius The vertical radius of ellipse. Default 0. + * @param startAngle The start angle of the ellipse, in degrees. Default 0. + * @param endAngle The end angle of the ellipse, in degrees. Default 360. + * @param clockwise Sets if the the ellipse rotation is clockwise (true) or anti-clockwise (false) Default false. + * @param rotation The rotation of the ellipse, in degrees. Default 0. */ constructor(x?: number | EllipseCurveConfig, y?: number, xRadius?: number, yRadius?: number, startAngle?: integer, endAngle?: integer, clockwise?: boolean, rotation?: integer); /** - * [description] + * The center point of the ellipse. Used for calculating rotation. */ p0: Phaser.Math.Vector2; @@ -6879,52 +7688,57 @@ declare namespace Phaser { setRotation(value: number): Phaser.Curves.Ellipse; /** - * [description] + * The x coordinate of the center of the ellipse. */ x: number; /** - * [description] + * The y coordinate of the center of the ellipse. */ y: number; /** - * [description] + * The horizontal radius of the ellipse. */ xRadius: number; /** - * [description] + * The vertical radius of the ellipse. */ yRadius: number; /** - * [description] + * The start angle of the ellipse in degrees. */ startAngle: number; /** - * [description] + * The end angle of the ellipse in degrees. */ endAngle: number; /** - * [description] + * `true` if the ellipse rotation is clockwise or `false` if anti-clockwise. */ clockwise: boolean; /** - * [description] + * The rotation of the ellipse, relative to the center, in degrees. + */ + angle: number; + + /** + * The rotation of the ellipse, relative to the center, in radians. */ rotation: number; /** - * [description] + * JSON serialization of the curve. */ toJSON(): JSONEllipseCurve; /** - * [description] + * Creates a curve from the provided Ellipse Curve Configuration object. * @param data The JSON object containing this curve data. */ static fromJSON(data: JSONEllipseCurve): Phaser.Curves.Ellipse; @@ -6932,23 +7746,23 @@ declare namespace Phaser { } /** - * [description] + * A LineCurve is a "curve" comprising exactly two points (a line segment). */ class Line extends Phaser.Curves.Curve { /** * - * @param p0 [description] - * @param p1 [description] + * @param p0 The first endpoint. + * @param p1 The second endpoint. */ constructor(p0: Phaser.Math.Vector2 | number[], p1?: Phaser.Math.Vector2); /** - * [description] + * The first endpoint. */ p0: Phaser.Math.Vector2; /** - * [description] + * The second endpoint. */ p1: Phaser.Math.Vector2; @@ -6965,8 +7779,8 @@ declare namespace Phaser { getStartPoint(out?: O): O; /** - * [description] - * @param divisions [description] Default 1. + * Gets the resolution of the line. + * @param divisions The number of divisions to consider. Default 1. */ getResolution(divisions?: number): number; @@ -6978,14 +7792,14 @@ declare namespace Phaser { getPoint(t: number, out?: O): O; /** - * [description] + * Gets a point at a given position on the line. * @param u The position along the curve to return. Where 0 is the start and 1 is the end. * @param out A Vector2 object to store the result in. If not given will be created. */ getPointAt(u: number, out?: O): O; /** - * [description] + * Gets the slope of the line as a unit vector. */ getTangent(): O; @@ -6999,12 +7813,12 @@ declare namespace Phaser { draw(graphics: G): G; /** - * [description] + * Gets a JSON representation of the line. */ toJSON(): JSONCurve; /** - * [description] + * Configures this line from a JSON representation. * @param data The JSON object containing this curve data. */ static fromJSON(data: JSONCurve): Phaser.Curves.Line; @@ -7012,23 +7826,23 @@ declare namespace Phaser { } /** - * [description] + * A MoveTo Curve is a very simple curve consisting of only a single point. Its intended use is to move the ending point in a Path. */ class MoveTo { /** * - * @param x [description] - * @param y [description] + * @param x `x` pixel coordinate. + * @param y `y` pixel coordinate. */ constructor(x?: number, y?: number); /** - * [description] + * Denotes that this Curve does not influence the bounds, points, and drawing of its parent Path. Must be `false` or some methods in the parent Path will throw errors. */ active: boolean; /** - * [description] + * The lone point which this curve consists of. */ p0: Phaser.Math.Vector2; @@ -7040,9 +7854,9 @@ declare namespace Phaser { getPoint(t: number, out?: O): O; /** - * [description] - * @param u [description] - * @param out [description] + * Retrieves the point at given position in the curve. This will always return this curve's only point. + * @param u The position in the path to retrieve, between 0 and 1. Not used. + * @param out An optional vector in which to store the point. */ getPointAt(u: number, out?: O): O; @@ -7057,35 +7871,40 @@ declare namespace Phaser { getLength(): number; /** - * [description] + * Converts this curve into a JSON-serializable object. */ toJSON(): JSONCurve; } /** - * [description] + * A Path combines multiple Curves into one continuous compound curve. It does not matter how many Curves are in the Path or what type they are. + * + * A Curve in a Path does not have to start where the previous Curve ends - that is to say, a Path does not have to be an uninterrupted curve. Only the order of the Curves influences the actual points on the Path. */ class Path { /** * - * @param x [description] Default 0. - * @param y [description] Default 0. + * @param x The X coordinate of the Path's starting point or a {@link JSONPath}. Default 0. + * @param y The Y coordinate of the Path's starting point. Default 0. */ constructor(x?: number, y?: number); /** - * [description] + * The name of this Path. + * Empty by default and never populated by Phaser, this is left for developers to use. */ name: string; /** - * [description] + * The list of Curves which make up this Path. */ curves: Phaser.Curves.Curve[]; /** - * [description] + * The cached length of each Curve in the Path. + * + * Used internally by {@link #getCurveLengths}. */ cacheLengths: number[]; @@ -7095,26 +7914,34 @@ declare namespace Phaser { autoClose: boolean; /** - * [description] + * The starting point of the Path. + * + * This is not necessarily equivalent to the starting point of the first Curve in the Path. In an empty Path, it's also treated as the ending point. */ startPoint: Phaser.Math.Vector2; /** - * [description] - * @param curve [description] + * Appends a Curve to the end of the Path. + * + * The Curve does not have to start where the Path ends or, for an empty Path, at its defined starting point. + * @param curve The Curve to append. */ add(curve: Phaser.Curves.Curve): Phaser.Curves.Path; /** - * [description] - * @param radius [description] - * @param clockwise [description] Default false. - * @param rotation [description] Default 0. + * Creates a circular Ellipse Curve positioned at the end of the Path. + * @param radius The radius of the circle. + * @param clockwise `true` to create a clockwise circle as opposed to a counter-clockwise circle. Default false. + * @param rotation The rotation of the circle in degrees. Default 0. */ circleTo(radius: number, clockwise?: boolean, rotation?: number): Phaser.Curves.Path; /** - * [description] + * Ensures that the Path is closed. + * + * A closed Path starts and ends at the same point. If the Path is not closed, a straight Line Curve will be created from the ending point directly to the starting point. During the check, the actual starting point of the Path, i.e. the starting point of the first Curve, will be used as opposed to the Path's defined {@link startPoint}, which could differ. + * + * Calling this method on an empty Path will result in an error. */ closePath(): Phaser.Curves.Path; @@ -7130,83 +7957,93 @@ declare namespace Phaser { cubicBezierTo(x: number | Phaser.Math.Vector2, y: number | Phaser.Math.Vector2, control1X: number | Phaser.Math.Vector2, control1Y?: number, control2X?: number, control2Y?: number): Phaser.Curves.Path; /** - * [description] - * @param x [description] - * @param y [description] - * @param controlX [description] - * @param controlY [description] + * Creates a Quadratic Bezier Curve starting at the ending point of the Path. + * @param x The X coordinate of the second control point or, if it's a `Vector2`, the first control point. + * @param y The Y coordinate of the second control point or, if `x` is a `Vector2`, the second control point. + * @param controlX If `x` is not a `Vector2`, the X coordinate of the first control point. + * @param controlY If `x` is not a `Vector2`, the Y coordinate of the first control point. */ quadraticBezierTo(x: number | Phaser.Math.Vector2[], y?: number, controlX?: number, controlY?: number): Phaser.Curves.Path; /** - * [description] - * @param graphics [description] - * @param pointsTotal [description] Default 32. + * Draws all Curves in the Path to a Graphics Game Object. + * @param graphics The Graphics Game Object to draw to. + * @param pointsTotal The number of points to draw for each Curve. Higher numbers result in a smoother curve but require more processing. Default 32. */ draw(graphics: Phaser.GameObjects.Graphics, pointsTotal?: integer): G; /** * Creates an ellipse curve positioned at the previous end point, using the given parameters. - * @param xRadius [description] - * @param yRadius [description] - * @param startAngle [description] - * @param endAngle [description] - * @param clockwise [description] - * @param rotation [description] + * @param xRadius The horizontal radius of the ellipse. + * @param yRadius The vertical radius of the ellipse. + * @param startAngle The start angle of the ellipse, in degrees. + * @param endAngle The end angle of the ellipse, in degrees. + * @param clockwise Whether the ellipse should be rotated clockwise (`true`) or counter-clockwise (`false`). + * @param rotation The rotation of the ellipse, in degrees. */ ellipseTo(xRadius: number, yRadius: number, startAngle: number, endAngle: number, clockwise: boolean, rotation: number): Phaser.Curves.Path; /** - * [description] - * @param data [description] + * Creates a Path from a Path Configuration object. + * + * The provided object should be a {@link JSONPath}, as returned by {@link #toJSON}. Providing a malformed object may cause errors. + * @param data The JSON object containing the Path data. */ fromJSON(data: object): Phaser.Curves.Path; /** - * [description] - * @param out [description] - * @param accuracy [description] Default 16. + * Returns a Rectangle with a position and size matching the bounds of this Path. + * @param out The Rectangle to store the bounds in. + * @param accuracy The accuracy of the bounds calculations. Higher values are more accurate at the cost of calculation speed. Default 16. */ getBounds(out?: O, accuracy?: integer): O; /** - * [description] + * Returns an array containing the length of the Path at the end of each Curve. + * + * The result of this method will be cached to avoid recalculating it in subsequent calls. The cache is only invalidated when the {@link #curves} array changes in length, leading to potential inaccuracies if a Curve in the Path is changed, or if a Curve is removed and another is added in its place. */ getCurveLengths(): number[]; /** - * [description] - * @param out [description] + * Returns the ending point of the Path. + * + * A Path's ending point is equivalent to the ending point of the last Curve in the Path. For an empty Path, the ending point is at the Path's defined {@link #startPoint}. + * @param out The object to store the point in. */ getEndPoint(out?: O): O; /** - * [description] + * Returns the total length of the Path. */ getLength(): number; /** - * [description] - * @param t [description] - * @param out [description] + * Calculates the coordinates of the point at the given normalized location (between 0 and 1) on the Path. + * + * The location is relative to the entire Path, not to an individual Curve. A location of 0.5 is always in the middle of the Path and is thus an equal distance away from both its starting and ending points. In a Path with one Curve, it would be in the middle of the Curve; in a Path with two Curves, it could be anywhere on either one of them depending on their lengths. + * @param t The location of the point to return, between 0 and 1. + * @param out The object in which to store the calculated point. */ getPoint(t: number, out?: O): O; /** - * [description] - * @param divisions [description] Default 12. + * Returns the defined starting point of the Path. + * + * This is not necessarily equal to the starting point of the first Curve if it differs from {@link startPoint}. + * @param divisions The number of points to divide the path in to. Default 12. */ getPoints(divisions?: integer): Phaser.Math.Vector2[]; /** * [description] - * @param out [description] + * @param out `Vector2` instance that should be used for storing the result. If `undefined` a new `Vector2` will be created. */ getRandomPoint(out?: O): O; /** - * [description] - * @param divisions [description] Default 40. + * Creates a straight Line Curve from the ending point of the Path to the given coordinates. + * @param divisions The X coordinate of the line's ending point, or the line's ending point as a `Vector2`. Default 40. */ getSpacedPoints(divisions?: integer): Phaser.Math.Vector2[]; @@ -7301,18 +8138,18 @@ declare namespace Phaser { /** * [description] - * @param graphics [description] - * @param pointsTotal [description] Default 32. + * @param graphics `Graphics` object to draw onto. + * @param pointsTotal Number of points to be used for drawing the curve. Higher numbers result in smoother curve but require more processing. Default 32. */ draw(graphics: G, pointsTotal?: integer): G; /** - * [description] + * Converts the curve into a JSON compatible object. */ toJSON(): JSONCurve; /** - * [description] + * Creates a curve from a JSON object, e. g. created by `toJSON`. * @param data The JSON object containing this curve data. */ static fromJSON(data: JSONCurve): Phaser.Curves.QuadraticBezier; @@ -7383,7 +8220,7 @@ declare namespace Phaser { namespace Data { /** - * The Data Component features a means to store pieces of data specific to a Game Object, System or Plugin. + * The Data Manager Component features a means to store pieces of data specific to a Game Object, System or Plugin. * You can then search, query it, and retrieve the data. The parent must either extend EventEmitter, * or have a property called `events` that is an instance of it. */ @@ -7426,6 +8263,9 @@ declare namespace Phaser { * ``` * * Doing so will emit a `setdata` event from the parent of this Data Manager. + * + * Do not modify this object directly. Adding properties directly to this object will not + * emit any events. Always use `DataManager.set` to create new items the first time around. */ values: {[key: string]: any}; @@ -7494,7 +8334,7 @@ declare namespace Phaser { * When the value is first set, a `setdata` event is emitted. * * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. * * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. @@ -7612,6 +8452,54 @@ declare namespace Phaser { } + namespace Events { + /** + * The Change Data Event. + * + * This event is dispatched by a Data Manager when an item in the data store is changed. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * a change data event from a Game Object you would use: `sprite.data.on('changedata', listener)`. + * + * This event is dispatched for all items that change in the Data Manager. + * To listen for the change of a specific item, use the `CHANGE_DATA_KEY_EVENT` event. + */ + const CHANGE_DATA: any; + + /** + * The Change Data Key Event. + * + * This event is dispatched by a Data Manager when an item in the data store is changed. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * the change of a specific data item from a Game Object you would use: `sprite.data.on('changedata-key', listener)`, + * where `key` is the unique string key of the data item. For example, if you have a data item stored called `gold` + * then you can listen for `sprite.data.on('changedata-gold')`. + */ + const CHANGE_DATA_KEY: any; + + /** + * The Remove Data Event. + * + * This event is dispatched by a Data Manager when an item is removed from it. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * the removal of a data item on a Game Object you would use: `sprite.data.on('removedata', listener)`. + */ + const REMOVE_DATA: any; + + /** + * The Set Data Event. + * + * This event is dispatched by a Data Manager when a new item is added to the data store. + * + * Game Objects with data enabled have an instance of a Data Manager under the `data` property. So, to listen for + * the addition of a new data item on a Game Object you would use: `sprite.data.on('setdata', listener)`. + */ + const SET_DATA: any; + + } + } namespace Device { @@ -8456,7 +9344,7 @@ declare namespace Phaser { /** * Looks up a canvas based on its parent, and if found puts it back in the pool, freeing it up for re-use. * The canvas has its width and height set to 1, and its parent attribute nulled. - * @param parent [description] + * @param parent The canvas or the parent of the canvas to free. */ function remove(parent: any): void; @@ -8485,7 +9373,7 @@ declare namespace Phaser { namespace Smoothing { /** * Gets the Smoothing Enabled vendor prefix being used on the given context, or null if not set. - * @param context [description] + * @param context The canvas context to check. */ function getPrefix(context: CanvasRenderingContext2D | WebGLRenderingContext): string; @@ -8495,7 +9383,7 @@ declare namespace Phaser { * when using pixel art in a game. Note that this sets the property on the context itself, so that any image * drawn to the context will be affected. This sets the property across all current browsers but support is * patchy on earlier browsers, especially on mobile. - * @param context [description] + * @param context The context on which to enable smoothing. */ function enable(context: CanvasRenderingContext2D | WebGLRenderingContext): CanvasRenderingContext2D | WebGLRenderingContext; @@ -8505,14 +9393,14 @@ declare namespace Phaser { * when using pixel art in a game. Note that this sets the property on the context itself, so that any image * drawn to the context will be affected. This sets the property across all current browsers but support is * patchy on earlier browsers, especially on mobile. - * @param context [description] + * @param context The context on which to disable smoothing. */ function disable(context: CanvasRenderingContext2D | WebGLRenderingContext): CanvasRenderingContext2D | WebGLRenderingContext; /** * Returns `true` if the given context has image smoothing enabled, otherwise returns `false`. * Returns null if no smoothing prefix is available. - * @param context [description] + * @param context The context to check. */ function isEnabled(context: CanvasRenderingContext2D | WebGLRenderingContext): boolean; @@ -8534,6 +9422,45 @@ declare namespace Phaser { } + namespace Color { + namespace Interpolate { + /** + * Interpolates between the two given color ranges over the length supplied. + * @param r1 Red value. + * @param g1 Blue value. + * @param b1 Green value. + * @param r2 Red value. + * @param g2 Blue value. + * @param b2 Green value. + * @param length Distance to interpolate over. Default 100. + * @param index Index to start from. Default 0. + */ + function RGBWithRGB(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number, length?: number, index?: number): ColorObject; + + /** + * Interpolates between the two given color objects over the length supplied. + * @param color1 The first Color object. + * @param color2 The second Color object. + * @param length Distance to interpolate over. Default 100. + * @param index Index to start from. Default 0. + */ + function ColorWithColor(color1: Phaser.Display.Color, color2: Phaser.Display.Color, length?: number, index?: number): ColorObject; + + /** + * Interpolates between the Color object and color values over the length supplied. + * @param color1 The first Color object. + * @param r Red value. + * @param g Blue value. + * @param b Green value. + * @param length Distance to interpolate over. Default 100. + * @param index Index to start from. Default 0. + */ + function ColorWithRGB(color1: Phaser.Display.Color, r: number, g: number, b: number, length?: number, index?: number): ColorObject; + + } + + } + /** * The Color class holds a single color value and allows for easy modification and reading of it. */ @@ -8563,8 +9490,9 @@ declare namespace Phaser { * @param green The green color value. A number between 0 and 255. * @param blue The blue color value. A number between 0 and 255. * @param alpha The alpha value. A number between 0 and 255. Default 255. + * @param updateHSV Update the HSV values after setting the RGB values? Default true. */ - setTo(red: integer, green: integer, blue: integer, alpha?: integer): Phaser.Display.Color; + setTo(red: integer, green: integer, blue: integer, alpha?: integer, updateHSV?: boolean): Phaser.Display.Color; /** * Sets the red, green, blue and alpha GL values of this Color component. @@ -8582,15 +9510,70 @@ declare namespace Phaser { setFromRGB(color: InputColorObject): Phaser.Display.Color; /** - * Updates the internal cache values. + * Sets the color based on the hue, saturation and lightness values given. + * @param h The hue, in the range 0 - 1. This is the base color. + * @param s The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param v The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. */ - update(): Phaser.Display.Color; + setFromHSV(h: number, s: number, v: number): Phaser.Display.Color; /** * Returns a new Color component using the values from this one. */ clone(): Phaser.Display.Color; + /** + * Sets this Color object to be grayscaled based on the shade value given. + * @param shade A value between 0 and 255. + */ + gray(shade: integer): Phaser.Display.Color; + + /** + * Sets this Color object to be a random color between the `min` and `max` values given. + * @param min The minimum random color value. Between 0 and 255. Default 0. + * @param max The maximum random color value. Between 0 and 255. Default 255. + */ + random(min?: integer, max?: integer): Phaser.Display.Color; + + /** + * Sets this Color object to be a random grayscale color between the `min` and `max` values given. + * @param min The minimum random color value. Between 0 and 255. Default 0. + * @param max The maximum random color value. Between 0 and 255. Default 255. + */ + randomGray(min?: integer, max?: integer): Phaser.Display.Color; + + /** + * Increase the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + saturate(amount: integer): Phaser.Display.Color; + + /** + * Decrease the saturation of this Color by the percentage amount given. + * The saturation is the amount of the base color in the hue. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + desaturate(amount: integer): Phaser.Display.Color; + + /** + * Increase the lightness of this Color by the percentage amount given. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + lighten(amount: integer): Phaser.Display.Color; + + /** + * Decrease the lightness of this Color by the percentage amount given. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + darken(amount: integer): Phaser.Display.Color; + + /** + * Brighten this Color by the percentage amount given. + * @param amount The percentage amount to change this color by. A value between 0 and 100. + */ + brighten(amount: integer): Phaser.Display.Color; + /** * The color of this Color component, not including the alpha channel. */ @@ -8646,6 +9629,24 @@ declare namespace Phaser { */ alpha: number; + /** + * The hue color value. A number between 0 and 1. + * This is the base color. + */ + h: number; + + /** + * The saturation color value. A number between 0 and 1. + * This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + */ + s: number; + + /** + * The lightness color value. A number between 0 and 1. + * This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + */ + v: number; + /** * Converts the given color value into an Object containing r,g,b and a properties. * @param color A color value, optionally including the alpha value. @@ -8705,11 +9706,12 @@ declare namespace Phaser { * Conversion formula from http://en.wikipedia.org/wiki/HSL_color_space. * Assumes HSV values are contained in the set [0, 1]. * Based on code by Michael Jackson (https://github.com/mjijackson) - * @param h The hue, in the range 0 - 1. - * @param s The saturation, in the range 0 - 1. - * @param v The value, in the range 0 - 1. + * @param h The hue, in the range 0 - 1. This is the base color. + * @param s The saturation, in the range 0 - 1. This controls how much of the hue will be in the final color, where 1 is fully saturated and 0 will give you white. + * @param v The value, in the range 0 - 1. This controls how dark the color is. Where 1 is as bright as possible and 0 is black. + * @param out A Color object to store the results in. If not given a new ColorObject will be created. */ - static HSVToRGB(h: number, s: number, v: number): ColorObject; + static HSVToRGB(h: number, s: number, v: number, out?: ColorObject | Phaser.Display.Color): ColorObject | Phaser.Display.Color; /** * Converts a hue to an RGB color. @@ -8761,8 +9763,9 @@ declare namespace Phaser { * @param r The red color value. A number between 0 and 255. * @param g The green color value. A number between 0 and 255. * @param b The blue color value. A number between 0 and 255. + * @param out An object to store the color values in. If not given an HSV Color Object will be created. */ - static RGBToHSV(r: integer, g: integer, b: integer): HSLColorObject; + static RGBToHSV(r: integer, g: integer, b: integer, out?: HSVColorObject | Phaser.Display.Color): HSVColorObject | Phaser.Display.Color; /** * Converts the color values into an HTML compatible color string, prefixed with either `#` or `0x`. @@ -8785,82 +9788,116 @@ declare namespace Phaser { namespace Masks { /** - * [description] + * A Bitmap Mask combines the alpha (opacity) of a masked pixel with the alpha of another pixel. + * Unlike the Geometry Mask, which is a clipping path, a Bitmap Mask behaves like an alpha mask, + * not a clipping path. It is only available when using the WebGL Renderer. + * + * A Bitmap Mask can use any Game Object to determine the alpha of each pixel of the masked Game Object(s). + * For any given point of a masked Game Object's texture, the pixel's alpha will be multiplied by the alpha + * of the pixel at the same position in the Bitmap Mask's Game Object. The color of the pixel from the + * Bitmap Mask doesn't matter. + * + * For example, if a pure blue pixel with an alpha of 0.95 is masked with a pure red pixel with an + * alpha of 0.5, the resulting pixel will be pure blue with an alpha of 0.475. Naturally, this means + * that a pixel in the mask with an alpha of 0 will hide the corresponding pixel in all masked Game Objects + * A pixel with an alpha of 1 in the masked Game Object will receive the same alpha as the + * corresponding pixel in the mask. + * + * The Bitmap Mask's location matches the location of its Game Object, not the location of the + * masked objects. Moving or transforming the underlying Game Object will change the mask + * (and affect the visibility of any masked objects), whereas moving or transforming a masked object + * will not affect the mask. + * + * The Bitmap Mask will not render its Game Object by itself. If the Game Object is not in a + * Scene's display list, it will only be used for the mask and its full texture will not be directly + * visible. Adding the underlying Game Object to a Scene will not cause any problems - it will + * render as a normal Game Object and will also serve as a mask. */ class BitmapMask { /** * - * @param scene [description] + * @param scene The Scene which this Bitmap Mask will be used in. * @param renderable A renderable Game Object that uses a texture, such as a Sprite. */ constructor(scene: Phaser.Scene, renderable: Phaser.GameObjects.GameObject); + /** + * A reference to either the Canvas or WebGL Renderer that this Mask is using. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + /** * A renderable Game Object that uses a texture, such as a Sprite. */ bitmapMask: Phaser.GameObjects.GameObject; /** - * [description] + * The texture used for the mask's framebuffer. */ maskTexture: WebGLTexture; /** - * [description] + * The texture used for the main framebuffer. */ mainTexture: WebGLTexture; /** - * [description] + * Whether the Bitmap Mask is dirty and needs to be updated. */ dirty: boolean; /** - * [description] + * The framebuffer to which a masked Game Object is rendered. */ mainFramebuffer: WebGLFramebuffer; /** - * [description] + * The framebuffer to which the Bitmap Mask's masking Game Object is rendered. */ maskFramebuffer: WebGLFramebuffer; /** - * [description] + * Whether to invert the mask's alpha. + * + * If `true`, the alpha of the masking pixel will be inverted before it's multiplied with the masked pixel. Essentially, this means that a masked area will be visible only if the corresponding area in the mask is invisible. */ invertAlpha: boolean; /** - * [description] + * Sets a new masking Game Object for the Bitmap Mask. * @param renderable A renderable Game Object that uses a texture, such as a Sprite. */ setBitmap(renderable: Phaser.GameObjects.GameObject): void; /** - * [description] - * @param renderer [description] - * @param maskedObject [description] + * Prepares the WebGL Renderer to render a Game Object with this mask applied. + * + * This renders the masking Game Object to the mask framebuffer and switches to the main framebuffer so that the masked Game Object will be rendered to it instead of being rendered directly to the frame. + * @param renderer The WebGL Renderer to prepare. + * @param maskedObject The masked Game Object which will be drawn. * @param camera The Camera to render to. */ preRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, maskedObject: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; /** - * [description] - * @param renderer [description] + * Finalizes rendering of a masked Game Object. + * + * This resets the previously bound framebuffer and switches the WebGL Renderer to the Bitmap Mask Pipeline, which uses a special fragment shader to apply the masking effect. + * @param renderer The WebGL Renderer to clean up. */ postRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; /** - * [description] - * @param renderer [description] - * @param mask [description] + * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. + * @param renderer The Canvas Renderer which would be rendered to. + * @param mask The masked Game Object which would be rendered. * @param camera The Camera to render to. */ preRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; /** - * [description] - * @param renderer [description] + * This is a NOOP method. Bitmap Masks are not supported by the Canvas Renderer. + * @param renderer The Canvas Renderer which would be rendered to. */ postRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; @@ -8875,54 +9912,74 @@ declare namespace Phaser { } /** - * [description] + * A Geometry Mask can be applied to a Game Object to hide any pixels of it which don't intersect + * a visible pixel from the geometry mask. The mask is essentially a clipping path which can only + * make a masked pixel fully visible or fully invisible without changing its alpha (opacity). + * + * A Geometry Mask uses a Graphics Game Object to determine which pixels of the masked Game Object(s) + * should be clipped. For any given point of a masked Game Object's texture, the pixel will only be displayed + * if the Graphics Game Object of the Geometry Mask has a visible pixel at the same position. The color and + * alpha of the pixel from the Geometry Mask do not matter. + * + * The Geometry Mask's location matches the location of its Graphics object, not the location of the masked objects. + * Moving or transforming the underlying Graphics object will change the mask (and affect the visibility + * of any masked objects), whereas moving or transforming a masked object will not affect the mask. + * You can think of the Geometry Mask (or rather, of the its Graphics object) as an invisible curtain placed + * in front of all masked objects which has its own visual properties and, naturally, respects the camera's + * visual properties, but isn't affected by and doesn't follow the masked objects by itself. */ class GeometryMask { /** * - * @param scene [description] - * @param graphicsGeometry [description] + * @param scene This parameter is not used. + * @param graphicsGeometry The Graphics Game Object to use for the Geometry Mask. Doesn't have to be in the Display List. */ constructor(scene: Phaser.Scene, graphicsGeometry: Phaser.GameObjects.Graphics); /** - * [description] + * The Graphics object which describes the Geometry Mask. */ geometryMask: Phaser.GameObjects.Graphics; /** - * [description] - * @param graphicsGeometry [description] + * Similar to the BitmapMasks invertAlpha setting this to true will then hide all pixels + * drawn to the Geometry Mask. + */ + invertAlpha: boolean; + + /** + * Sets a new Graphics object for the Geometry Mask. + * @param graphicsGeometry The Graphics object which will be used for the Geometry Mask. */ setShape(graphicsGeometry: Phaser.GameObjects.Graphics): void; /** - * [description] - * @param renderer [description] - * @param mask [description] - * @param camera [description] + * Renders the Geometry Mask's underlying Graphics object to the OpenGL stencil buffer and enables the stencil test, which clips rendered pixels according to the mask. + * @param renderer The WebGL Renderer instance to draw to. + * @param mask The Game Object being rendered. + * @param camera The camera the Game Object is being rendered through. */ - preRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + preRenderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; /** - * [description] - * @param renderer [description] + * Flushes all rendered pixels and disables the stencil test of a WebGL context, thus disabling the mask for it. + * @param renderer The WebGL Renderer instance to draw flush. */ - postRenderWebGL(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; + postRenderWebGL(renderer: Phaser.Renderer.WebGL.WebGLRenderer): void; /** - * [description] - * @param renderer [description] - * @param mask [description] - * @param camera [description] + * Sets the clipping path of a 2D canvas context to the Geometry Mask's underlying Graphics object. + * @param renderer The Canvas Renderer instance to set the clipping path on. + * @param mask The Game Object being rendered. + * @param camera The camera the Game Object is being rendered through. */ - preRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; + preRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer, mask: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera): void; /** - * [description] - * @param renderer [description] + * Restore the canvas context's previous clipping path, thus turning off the mask for it. + * @param renderer The Canvas Renderer instance being restored. */ - postRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; + postRenderCanvas(renderer: Phaser.Renderer.Canvas.CanvasRenderer): void; /** * Destroys this GeometryMask and nulls any references it holds. @@ -8941,12 +9998,11 @@ declare namespace Phaser { namespace DOM { /** * Adds the given element to the DOM. If a parent is provided the element is added as a child of the parent, providing it was able to access it. - * If no parent was given or falls back to using `document.body`. + * If no parent was given it falls back to using `document.body`. * @param element The element to be added to the DOM. Usually a Canvas object. * @param parent The parent in which to add the element. Can be a string which is passed to `getElementById` or an actual DOM object. - * @param overflowHidden Whether or not to hide overflowing content inside the parent. Default true. */ - function AddToDOM(element: HTMLElement, parent?: string | HTMLElement, overflowHidden?: boolean): HTMLElement; + function AddToDOM(element: HTMLElement, parent?: string | HTMLElement): HTMLElement; /** * Inspects the readyState of the document. If the document is already complete then it invokes the given callback. @@ -8956,6 +10012,14 @@ declare namespace Phaser { */ function DOMContentLoaded(callback: ContentLoadedCallback): void; + /** + * Attempts to get the target DOM element based on the given value, which can be either + * a string, in which case it will be looked-up by ID, or an element node. If nothing + * can be found it will return a reference to the document.body. + * @param element The DOM element to look-up. + */ + function GetTarget(element: HTMLElement): void; + /** * Takes the given data string and parses it as XML. * First tries to use the window.DOMParser and reverts to the Microsoft.XMLDOM if that fails. @@ -9108,7 +10172,7 @@ declare namespace Phaser { * @param context Only remove the listeners that have this context. * @param once Only remove one-time listeners. */ - removeListener(event: string | symbol, fn: Function, context: any, once: boolean): Phaser.Events.EventEmitter; + removeListener(event: string | symbol, fn?: Function, context?: any, once?: boolean): Phaser.Events.EventEmitter; /** * Remove the listeners of a given event. @@ -9117,7 +10181,7 @@ declare namespace Phaser { * @param context Only remove the listeners that have this context. * @param once Only remove one-time listeners. */ - off(event: string | symbol, fn: Function, context: any, once: boolean): Phaser.Events.EventEmitter; + off(event: string | symbol, fn?: Function, context?: any, once?: boolean): Phaser.Events.EventEmitter; /** * Remove all listeners, or those of the specified event. @@ -9131,9 +10195,33 @@ declare namespace Phaser { namespace GameObjects { /** - * [description] + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson */ - class DynamicBitmapText extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class DynamicBitmapText extends Phaser.GameObjects.BitmapText { /** * * @param scene The Scene to which this Game Object belongs. It can only belong to one Scene at any given time. @@ -9142,34 +10230,9 @@ declare namespace Phaser { * @param font The key of the font to use from the Bitmap Font cache. * @param text The string, or array of strings, to be set as the content of this Bitmap Text. * @param size The font size of this Bitmap Text. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. */ - constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number); - - /** - * The key of the Bitmap Font used by this Bitmap Text. - */ - font: string; - - /** - * The data of the Bitmap Font used by this Bitmap Text. - */ - fontData: BitmapFontData; - - /** - * The text that this Bitmap Text object displays. - */ - text: string; - - /** - * The font size of this Bitmap Text. - */ - fontSize: number; - - /** - * Adds/Removes spacing between characters - * Can be a negative or positive number - */ - letterSpacing: number; + constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer); /** * The horizontal scroll position of the Bitmap Text. @@ -9194,7 +10257,17 @@ declare namespace Phaser { /** * A callback that alters how each character of the Bitmap Text is rendered. */ - "displayCallback;": DisplayCallback; + displayCallback: DisplayCallback; + + /** + * The data object that is populated during rendering, then passed to the displayCallback. + * You should modify this object then return it back from the callback. It's updated values + * will be used to render the specific glyph. + * + * Please note that if you need a reference to this object locally in your game code then you + * should shallow copy it, as it's updated and re-used for every glyph in the text. + */ + callbackData: DisplayCallbackConfig; /** * Set the crop size of this Bitmap Text. @@ -9215,20 +10288,6 @@ declare namespace Phaser { */ setDisplayCallback(callback: DisplayCallback): Phaser.GameObjects.DynamicBitmapText; - /** - * Set the font size of this Bitmap Text. - * @param size The font size to set. - */ - setFontSize(size: number): Phaser.GameObjects.DynamicBitmapText; - - /** - * Set the content of this BitmapText. - * - * An array of strings will be converted multi-line text. - * @param value The string, or array of strings, to be set as the content of this BitmapText. - */ - setText(value: string | string[]): Phaser.GameObjects.DynamicBitmapText; - /** * Set the horizontal scroll position of this Bitmap Text. * @param value The horizontal scroll position to set. @@ -9241,34 +10300,6 @@ declare namespace Phaser { */ setScrollY(value: number): Phaser.GameObjects.DynamicBitmapText; - /** - * Calculate the bounds of this Bitmap Text. - * - * An object is returned that contains the position, width and height of the Bitmap Text in local and global - * contexts. - * - * Local size is based on just the font size and a [0, 0] position. - * - * Global size takes into account the Game Object's scale and world position. - * @param round Whether to round the results to the nearest integer. - */ - getTextBounds(round?: boolean): BitmapTextSize; - - /** - * The width of this Bitmap Text. - */ - readonly width: number; - - /** - * The height of this Bitmap Text. - */ - readonly height: number; - - /** - * Build a JSON representation of this Bitmap Text. - */ - toJSON(): JSONBitmapText; - /** * Clears all alpha values associated with this Game Object. * @@ -9330,6 +10361,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -9352,6 +10384,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -9359,7 +10392,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -9400,12 +10433,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -9516,15 +10553,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -9536,6 +10573,19 @@ declare namespace Phaser { */ getPipelineName(): string; + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + /** * The horizontal scroll factor of this Game Object. * @@ -9547,6 +10597,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -9561,6 +10616,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -9575,6 +10635,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -9614,21 +10679,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -9658,6 +10766,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -9781,8 +10894,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -9902,12 +11016,34 @@ declare namespace Phaser { * If the characters in the font set have vertical spacing between them set the required amount here. */ "spacing.y": number; + /** + * The amount of vertical space to add to the line height of the font. + */ + lineSpacing: number; }; } /** - * [description] + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): {@link http://www.angelcode.com/products/bmfont/|http://www.angelcode.com/products/bmfont/} + * Glyph Designer (OS X, commercial): {@link http://www.71squared.com/en/glyphdesigner|http://www.71squared.com/en/glyphdesigner} + * Littera (Web-based, free): {@link http://kvazars.com/littera/|http://kvazars.com/littera/} + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: {@link http://codebeautify.org/xmltojson|http://codebeautify.org/xmltojson} */ class BitmapText extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** @@ -9918,41 +11054,44 @@ declare namespace Phaser { * @param font The key of the font to use from the Bitmap Font cache. * @param text The string, or array of strings, to be set as the content of this Bitmap Text. * @param size The font size of this Bitmap Text. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. */ - constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number); + constructor(scene: Phaser.Scene, x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer); /** * The key of the Bitmap Font used by this Bitmap Text. + * To change the font after creation please use `setFont`. */ - font: string; + readonly font: string; /** * The data of the Bitmap Font used by this Bitmap Text. */ - fontData: BitmapFontData; + readonly fontData: BitmapFontData; /** - * The text that this Bitmap Text object displays. + * Set the lines of text in this BitmapText to be left-aligned. + * This only has any effect if this BitmapText contains more than one line of text. */ - text: string; + setLeftAlign(): this; /** - * The font size of this Bitmap Text. + * Set the lines of text in this BitmapText to be center-aligned. + * This only has any effect if this BitmapText contains more than one line of text. */ - fontSize: number; + setCenterAlign(): this; /** - * Adds/Removes spacing between characters. - * - * Can be a negative or positive number. + * Set the lines of text in this BitmapText to be right-aligned. + * This only has any effect if this BitmapText contains more than one line of text. */ - letterSpacing: number; + setRightAlign(): this; /** * Set the font size of this Bitmap Text. * @param size The font size to set. */ - setFontSize(size: number): Phaser.GameObjects.BitmapText; + setFontSize(size: number): this; /** * Sets the letter spacing between each character of this Bitmap Text. @@ -9960,15 +11099,15 @@ declare namespace Phaser { * Spacing is applied after the kerning values have been set. * @param spacing The amount of horizontal space to add between each character. Default 0. */ - setLetterSpacing(spacing?: number): Phaser.GameObjects.BitmapText; + setLetterSpacing(spacing?: number): this; /** - * Set the content of this BitmapText. + * Set the textual content of this BitmapText. * - * An array of strings will be converted multi-line text. + * An array of strings will be converted into multi-line text. Use the align methods to change multi-line alignment. * @param value The string, or array of strings, to be set as the content of this BitmapText. */ - setText(value: string | string[]): Phaser.GameObjects.BitmapText; + setText(value: string | string[]): this; /** * Calculate the bounds of this Bitmap Text. @@ -9978,11 +11117,63 @@ declare namespace Phaser { * * Local size is based on just the font size and a [0, 0] position. * - * Global size takes into account the Game Object's scale and world position. + * Global size takes into account the Game Object's scale, world position and display origin. + * + * Also in the object is data regarding the length of each line, should this be a multi-line BitmapText. * @param round Whether to round the results to the nearest integer. */ getTextBounds(round?: boolean): BitmapTextSize; + /** + * Changes the font this BitmapText is using to render. + * + * The new texture is loaded and applied to the BitmapText. The existing test, size and alignment are preserved, + * unless overridden via the arguments. + * @param font The key of the font to use from the Bitmap Font cache. + * @param size The font size of this Bitmap Text. If not specified the current size will be used. + * @param align The alignment of the text in a multi-line BitmapText object. If not specified the current alignment will be used. Default 0. + */ + setFont(font: string, size?: number, align?: integer): this; + + /** + * Controls the alignment of each line of text in this BitmapText object. + * + * Only has any effect when this BitmapText contains multiple lines of text, split with carriage-returns. + * Has no effect with single-lines of text. + * + * See the methods `setLeftAlign`, `setCenterAlign` and `setRightAlign`. + * + * 0 = Left aligned (default) + * 1 = Middle aligned + * 2 = Right aligned + * + * The alignment position is based on the longest line of text. + */ + align: integer; + + /** + * The text that this Bitmap Text object displays. + * + * You can also use the method `setText` if you want a chainable way to change the text content. + */ + text: string; + + /** + * The font size of this Bitmap Text. + * + * You can also use the method `setFontSize` if you want a chainable way to change the font size. + */ + fontSize: number; + + /** + * Adds / Removes spacing between characters. + * + * Can be a negative or positive number. + * + * You can also use the method `setLetterSpacing` if you want a chainable way to change the letter spacing. + */ + letterSpacing: number; + /** * The width of this Bitmap Text. */ @@ -9998,6 +11189,28 @@ declare namespace Phaser { */ toJSON(): JSONBitmapText; + /** + * Left align the text characters in a multi-line BitmapText object. + */ + static ALIGN_LEFT: integer; + + /** + * Center align the text characters in a multi-line BitmapText object. + */ + static ALIGN_CENTER: integer; + + /** + * Right align the text characters in a multi-line BitmapText object. + */ + static ALIGN_RIGHT: integer; + + /** + * Parse an XML Bitmap Font from an Atlas. + * + * Adds the parsed Bitmap Font data to the cache with the `fontName` key. + */ + static ParseFromAtlas: any; + /** * Clears all alpha values associated with this Game Object. * @@ -10059,6 +11272,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -10081,6 +11295,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -10088,7 +11303,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -10129,12 +11344,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -10245,15 +11464,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -10289,6 +11508,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -10303,6 +11527,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -10317,6 +11546,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -10356,21 +11590,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -10400,6 +11677,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -10523,8 +11805,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -10573,7 +11856,7 @@ declare namespace Phaser { * The children of this Blitter. * This List contains all of the Bob objects created by the Blitter. */ - children: Phaser.Structs.List; + children: Phaser.Structs.List; /** * Is the Blitter considered dirty? @@ -10592,7 +11875,7 @@ declare namespace Phaser { * @param visible Should the created Bob render or not? Default true. * @param index The position in the Blitters Display List to add the new Bob at. Defaults to the top of the list. */ - create(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame, visible?: boolean, index?: integer): Phaser.GameObjects.Blitter.Bob; + create(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame, visible?: boolean, index?: integer): Phaser.GameObjects.Bob; /** * Creates multiple Bob objects within this Blitter and then passes each of them to the specified callback. @@ -10601,7 +11884,7 @@ declare namespace Phaser { * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. * @param visible Should the created Bob render or not? Default true. */ - createFromCallback(callback: Phaser.GameObjects.Blitter.CreateCallback, quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Blitter.Bob[]; + createFromCallback(callback: CreateCallback, quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; /** * Creates multiple Bobs in one call. @@ -10614,19 +11897,19 @@ declare namespace Phaser { * @param frame The Frame the Bobs will use. It must be part of the Blitter Texture. * @param visible Should the created Bob render or not? Default true. */ - createMultiple(quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Blitter.Bob[]; + createMultiple(quantity: integer, frame?: string | integer | Phaser.Textures.Frame | string[] | integer[] | Phaser.Textures.Frame[], visible?: boolean): Phaser.GameObjects.Bob[]; /** * Checks if the given child can render or not, by checking its `visible` and `alpha` values. * @param child The Bob to check for rendering. */ - childCanRender(child: Phaser.GameObjects.Blitter.Bob): boolean; + childCanRender(child: Phaser.GameObjects.Bob): boolean; /** * Returns an array of Bobs to be rendered. * If the Blitter is dirty then a new list is generated and stored in `renderList`. */ - getRenderList(): Phaser.GameObjects.Blitter.Bob[]; + getRenderList(): Phaser.GameObjects.Bob[]; /** * Removes all Bobs from the children List and clears the dirty flag. @@ -10699,6 +11982,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -10721,6 +12005,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -10728,7 +12013,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -10769,12 +12054,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -10827,15 +12116,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -10871,6 +12160,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -10885,6 +12179,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -10899,6 +12198,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -10906,34 +12210,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -10941,6 +12275,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -11104,8 +12439,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -11124,6 +12460,155 @@ declare namespace Phaser { } + /** + * A Bob Game Object. + * + * A Bob belongs to a Blitter Game Object. The Blitter is responsible for managing and rendering this object. + * + * A Bob has a position, alpha value and a frame from a texture that it uses to render with. You can also toggle + * the flipped and visible state of the Bob. The Frame the Bob uses to render can be changed dynamically, but it + * must be a Frame within the Texture used by the parent Blitter. + * + * Bob positions are relative to the Blitter parent. So if you move the Blitter parent, all Bob children will + * have their positions impacted by this change as well. + * + * You can manipulate Bob objects directly from your game code, but the creation and destruction of them should be + * handled via the Blitter parent. + */ + class Bob { + /** + * + * @param blitter The parent Blitter object is responsible for updating this Bob. + * @param x The horizontal position of this Game Object in the world, relative to the parent Blitter position. + * @param y The vertical position of this Game Object in the world, relative to the parent Blitter position. + * @param frame The Frame this Bob will render with, as defined in the Texture the parent Blitter is using. + * @param visible Should the Bob render visible or not to start with? + */ + constructor(blitter: Phaser.GameObjects.Blitter, x: number, y: number, frame: string | integer, visible: boolean); + + /** + * The Blitter object that this Bob belongs to. + */ + parent: Phaser.GameObjects.Blitter; + + /** + * The x position of this Bob, relative to the x position of the Blitter. + */ + x: number; + + /** + * The y position of this Bob, relative to the y position of the Blitter. + */ + y: number; + + /** + * The frame that the Bob uses to render with. + * To change the frame use the `Bob.setFrame` method. + */ + protected frame: Phaser.Textures.Frame; + + /** + * A blank object which can be used to store data related to this Bob in. + */ + data: object; + + /** + * The horizontally flipped state of the Bob. + * A Bob that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Bob. + * A Bob that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture. + */ + flipY: boolean; + + /** + * Changes the Texture Frame being used by this Bob. + * The frame must be part of the Texture the parent Blitter is using. + * If no value is given it will use the default frame of the Blitter parent. + * @param frame The frame to be used during rendering. + */ + setFrame(frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Bob; + + /** + * Resets the horizontal and vertical flipped state of this Bob back to their default un-flipped state. + */ + resetFlip(): Phaser.GameObjects.Bob; + + /** + * Resets this Bob. + * + * Changes the position to the values given, and optionally changes the frame. + * + * Also resets the flipX and flipY values, sets alpha back to 1 and visible to true. + * @param x The x position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param y The y position of the Bob. Bob coordinate are relative to the position of the Blitter object. + * @param frame The Frame the Bob will use. It _must_ be part of the Texture the parent Blitter object is using. + */ + reset(x: number, y: number, frame?: string | integer | Phaser.Textures.Frame): Phaser.GameObjects.Bob; + + /** + * Sets the horizontal flipped state of this Bob. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): Phaser.GameObjects.Bob; + + /** + * Sets the vertical flipped state of this Bob. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): Phaser.GameObjects.Bob; + + /** + * Sets the horizontal and vertical flipped state of this Bob. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlip(x: boolean, y: boolean): Phaser.GameObjects.Bob; + + /** + * Sets the visibility of this Bob. + * + * An invisible Bob will skip rendering. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): Phaser.GameObjects.Bob; + + /** + * Set the Alpha level of this Bob. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * A Bob with alpha 0 will skip rendering. + * @param value The alpha value used for this Bob. Between 0 and 1. + */ + setAlpha(value: number): Phaser.GameObjects.Bob; + + /** + * Destroys this Bob instance. + * Removes itself from the Blitter and clears the parent, frame and data properties. + */ + destroy(): void; + + /** + * The visible state of the Bob. + * + * An invisible Bob will skip rendering. + */ + visible: boolean; + + /** + * The alpha value of the Bob, between 0 and 1. + * + * A Bob with alpha 0 will skip rendering. + */ + alpha: number; + + } + /** * Builds a Game Object using the provided configuration object. * @param scene A reference to the Scene. @@ -11212,6 +12697,10 @@ declare namespace Phaser { * The current AnimationFrame being displayed by this Animation Controller. */ currentFrame: Phaser.Animations.AnimationFrame; + /** + * The key of the next Animation to be loaded into this Animation Controller when the current animation completes. + */ + nextAnim: string; /** * The frame rate of playback in frames per second. * The default is 24 if the `duration` property is `null`. @@ -11232,7 +12721,7 @@ declare namespace Phaser { */ skipMissedFrames: boolean; /** - * Will the playhead move forwards (`true`) or in reverse (`false`) + * Will the playhead move forwards (`true`) or in reverse (`false`). */ forward: boolean; /** @@ -11251,6 +12740,20 @@ declare namespace Phaser { * An internal flag keeping track of pending repeats. */ pendingRepeat: boolean; + /** + * Sets an animation to be played immediately after the current one completes. + * + * The current animation must enter a 'completed' state for this to happen, i.e. finish all of its repeats, delays, etc, or have the `stop` method called directly on it. + * + * An animation set to repeat forever will never enter a completed state. + * + * You can chain a new animation at any point, including before the current one starts playing, during it, or when it ends (via its `animationcomplete` callback). + * Chained animations are specific to a Game Object, meaning different Game Objects can have different chained animations without impacting the global animation they're playing. + * + * Call this method with no arguments to reset the chained animation. + * @param key The string-based key of the animation to play next, as defined previously in the Animation Manager. Or an Animation instance. + */ + chain(key?: string | Phaser.Animations.Animation): Phaser.GameObjects.GameObject; /** * Sets the amount of time, in milliseconds, that the animation will be delayed before starting playback. * @param value The amount of time, in milliseconds, to wait before starting playback. Default 0. @@ -11294,12 +12797,31 @@ declare namespace Phaser { */ readonly isPaused: boolean; /** - * Plays an Animation on the Game Object that owns this Animation Component. - * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. + * Plays an Animation on a Game Object that has the Animation component, such as a Sprite. + * + * Animations are stored in the global Animation Manager and are referenced by a unique string-based key. + * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. * @param startFrame Optionally start the animation playing from this frame index. Default 0. */ - play(key: string, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.GameObject; + play(key: string | Phaser.Animations.Animation, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Plays an Animation (in reverse mode) on the Game Object that owns this Animation Component. + * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. Or an Animation instance. + * @param ignoreIfPlaying If an animation is already playing then ignore this call. Default false. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + playReverse(key: string | Phaser.Animations.Animation, ignoreIfPlaying?: boolean, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Load an Animation and fires 'onStartEvent' event, extracted from 'play' method. + * @param key The string-based key of the animation to play, as defined previously in the Animation Manager. + * @param startFrame Optionally start the animation playing from this frame index. Default 0. + */ + _startAnimation(key: string, startFrame?: integer): Phaser.GameObjects.GameObject; + /** + * Reverse the Animation that is already playing on the Game Object. + */ + reverse(): Phaser.GameObjects.GameObject; /** * Returns a value between 0 and 1 indicating how far this animation is through, ignoring repeats and yoyos. * If the animation has a non-zero repeat defined, `getProgress` and `getTotalProgress` will be different @@ -11352,6 +12874,10 @@ declare namespace Phaser { restart(includeDelay?: boolean): Phaser.GameObjects.GameObject; /** * Immediately stops the current animation from playing and dispatches the `animationcomplete` event. + * + * If no animation is set, no event will be dispatched. + * + * If there is another animation queued (via the `chain` method) then it will start playing immediately. */ stop(): Phaser.GameObjects.GameObject; /** @@ -11366,9 +12892,9 @@ declare namespace Phaser { /** * Stops the current animation from playing when it next sets the given frame. * If this frame doesn't exist within the animation it will not stop it from playing. - * @param delay The frame to check before stopping this animation. + * @param frame The frame to check before stopping this animation. */ - stopOnFrame(delay: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; + stopOnFrame(frame: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; /** * Sets the Time Scale factor, allowing you to make the animation go go faster or slower than default. * Where 1 = normal speed (the default), 0.5 = half speed, 2 = double speed, etc. @@ -11395,6 +12921,22 @@ declare namespace Phaser { * @param animationFrame The Animation Frame to set as being current. */ setCurrentFrame(animationFrame: Phaser.Animations.AnimationFrame): Phaser.GameObjects.GameObject; + /** + * Advances the animation to the next frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in reverse, calling this method doesn't then change the direction to forwards. + */ + nextFrame(): Phaser.GameObjects.GameObject; + /** + * Advances the animation to the previous frame, regardless of the time or animation state. + * If the animation is set to repeat, or yoyo, this will still take effect. + * + * Calling this does not change the direction of the animation. I.e. if it was currently + * playing in forwards, calling this method doesn't then change the direction to backwards. + */ + previousFrame(): Phaser.GameObjects.GameObject; /** * Sets if the current Animation will yoyo when it reaches the end. * A yoyo'ing animation will play through consecutively, and then reverse-play back to the start again. @@ -11429,6 +12971,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -11450,6 +12993,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -11457,7 +13001,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -11471,30 +13015,53 @@ declare namespace Phaser { interface ComputedSize { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ setSize(width: number, height: number): this; /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -11502,6 +13069,54 @@ declare namespace Phaser { setDisplaySize(width: number, height: number): this; } + /** + * Provides methods used for getting and setting the texture of a Game Object. + */ + interface Crop { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + } + /** * Provides methods used for setting the depth of a Game Object. * Should be applied as a mixin and not used directly. @@ -11639,12 +13254,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -11682,66 +13301,6 @@ declare namespace Phaser { createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; } - /** - * Provides methods used for getting and setting the transform values of a Game Object. - * Should be applied as a mixin and not used directly. - */ - interface MatrixStack { - /** - * [description] - */ - initMatrixStack(): this; - /** - * [description] - */ - save(): this; - /** - * [description] - */ - restore(): this; - /** - * [description] - */ - loadIdentity(): this; - /** - * [description] - * @param a [description] - * @param b [description] - * @param c [description] - * @param d [description] - * @param tx [description] - * @param ty [description] - */ - transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - /** - * [description] - * @param a [description] - * @param b [description] - * @param c [description] - * @param d [description] - * @param tx [description] - * @param ty [description] - */ - setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - /** - * [description] - * @param x [description] - * @param y [description] - */ - translate(x: number, y: number): this; - /** - * [description] - * @param x [description] - * @param y [description] - */ - scale(x: number, y: number): this; - /** - * [description] - * @param t The angle of rotation, in radians. - */ - rotate(t: number): this; - } - /** * Provides methods used for getting and setting the origin of a Game Object. * Values are normalized, given in the range 0 to 1. @@ -11816,14 +13375,14 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. */ @@ -11866,6 +13425,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; /** @@ -11879,6 +13443,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; /** @@ -11892,6 +13461,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -11904,35 +13478,66 @@ declare namespace Phaser { interface Size { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ setSize(width: number, height: number): this; /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -11976,24 +13581,135 @@ declare namespace Phaser { setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; } + /** + * Provides methods used for getting and setting the texture of a Game Object. + */ + interface TextureCrop { + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + */ + setTexture(key: string, frame?: string | integer): this; + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + } + /** * Provides methods used for setting the tint of a Game Object. * Should be applied as a mixin and not used directly. */ interface Tint { + /** + * Fill or additive? + */ + tintFill: boolean; /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -12018,15 +13734,19 @@ declare namespace Phaser { * The tint value being applied to the whole of the Game Object. */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; } /** * Build a JSON representation of the given Game Object. * * This is typically extended further by Game Object specific implementations. - * @param gameObject The Game Object to export as JSON. */ - function ToJSON(gameObject: Phaser.GameObjects.GameObject): JSONGameObject; + interface ToJSON { + } /** * Provides methods used for getting and setting the position, scale and rotation of a Game Object. @@ -12137,12 +13857,21 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; } /** - * [description] + * A Matrix used for display transformations for rendering. + * + * It is represented like so: + * + * ``` + * | a | c | tx | + * | b | d | ty | + * | 0 | 0 | 1 | + * ``` */ class TransformMatrix { /** @@ -12157,93 +13886,119 @@ declare namespace Phaser { constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); /** - * [description] + * The matrix values. */ matrix: Float32Array; /** - * [description] + * The decomposed matrix. */ decomposedMatrix: object; /** - * [description] + * The Scale X value. */ a: number; /** - * [description] + * The Shear Y value. */ b: number; /** - * [description] + * The Shear X value. */ c: number; /** - * [description] + * The Scale Y value. */ d: number; /** - * [description] + * The Translate X value. + */ + e: number; + + /** + * The Translate Y value. + */ + f: number; + + /** + * The Translate X value. */ tx: number; /** - * [description] + * The Translate Y value. */ ty: number; /** - * [description] + * The rotation of the Matrix. */ readonly rotation: number; /** - * [description] + * The horizontal scale of the Matrix. */ readonly scaleX: number; /** - * [description] + * The vertical scale of the Matrix. */ readonly scaleY: number; /** - * [description] + * Reset the Matrix to an identity matrix. */ loadIdentity(): this; /** - * [description] - * @param x [description] - * @param y [description] + * Translate the Matrix. + * @param x The horizontal translation value. + * @param y The vertical translation value. */ translate(x: number, y: number): this; /** - * [description] - * @param x [description] - * @param y [description] + * Scale the Matrix. + * @param x The horizontal scale value. + * @param y The vertical scale value. */ scale(x: number, y: number): this; /** - * [description] - * @param radian [description] + * Rotate the Matrix. + * @param angle The angle of rotation in radians. */ - rotate(radian: number): this; + rotate(angle: number): this; /** - * [description] - * @param rhs [description] + * Multiply this Matrix by the given Matrix. + * + * If an `out` Matrix is given then the results will be stored in it. + * If it is not given, this matrix will be updated in place instead. + * Use an `out` Matrix if you do not wish to mutate this matrix. + * @param rhs The Matrix to multiply by. + * @param out An optional Matrix to store the results in. */ - multiply(rhs: Phaser.GameObjects.Components.TransformMatrix): this; + multiply(rhs: Phaser.GameObjects.Components.TransformMatrix, out?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** - * [description] + * Multiply this Matrix by the matrix given, including the offset. + * + * The offsetX is added to the tx value: `offsetX * a + offsetY * c + tx`. + * The offsetY is added to the ty value: `offsetY * b + offsetY * d + ty`. + * @param src The source Matrix to copy from. + * @param offsetX Horizontal offset to factor in to the multiplication. + * @param offsetY Vertical offset to factor in to the multiplication. + */ + multiplyWithOffset(src: Phaser.GameObjects.Components.TransformMatrix, offsetX: number, offsetY: number): this; + + /** + * Transform the Matrix. * @param a The Scale X value. * @param b The Shear Y value. * @param c The Shear X value. @@ -12254,44 +14009,115 @@ declare namespace Phaser { transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; /** - * [description] - * @param x [description] - * @param y [description] - * @param point [description] + * Transform a point using this Matrix. + * @param x The x coordinate of the point to transform. + * @param y The y coordinate of the point to transform. + * @param point The Point object to store the transformed coordinates. */ transformPoint(x: number, y: number, point: Phaser.Geom.Point | Phaser.Math.Vector2 | object): Phaser.Geom.Point | Phaser.Math.Vector2 | object; /** - * [description] + * Invert the Matrix. */ invert(): this; /** - * [description] - * @param a [description] - * @param b [description] - * @param c [description] - * @param d [description] - * @param tx [description] - * @param ty [description] + * Set the values of this Matrix to copy those of the matrix given. + * @param src The source Matrix to copy from. + */ + copyFrom(src: Phaser.GameObjects.Components.TransformMatrix): this; + + /** + * Set the values of this Matrix to copy those of the array given. + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * @param src The array of values to set into this matrix. + */ + copyFromArray(src: any[]): this; + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.transform method. + * @param ctx The Canvas Rendering Context to copy the matrix values to. + */ + copyToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; + + /** + * Copy the values from this Matrix to the given Canvas Rendering Context. + * This will use the Context.setTransform method. + * @param ctx The Canvas Rendering Context to copy the matrix values to. + */ + setToContext(ctx: CanvasRenderingContext2D): CanvasRenderingContext2D; + + /** + * Copy the values in this Matrix to the array given. + * + * Where array indexes 0, 1, 2, 3, 4 and 5 are mapped to a, b, c, d, e and f. + * @param out The array to copy the matrix values in to. + */ + copyToArray(out?: any[]): any[]; + + /** + * Set the values of this Matrix. + * @param a The Scale X value. + * @param b The Shear Y value. + * @param c The Shear X value. + * @param d The Scale Y value. + * @param tx The Translate X value. + * @param ty The Translate Y value. */ setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; /** - * [description] + * Decompose this Matrix into its translation, scale and rotation values using QR decomposition. + * + * The result must be applied in the following order to reproduce the current matrix: + * + * translate -> rotate -> scale */ decomposeMatrix(): object; /** - * Identity + Translate + Rotate + Scale - * @param x [description] - * @param y [description] - * @param rotation [description] - * @param scaleX [description] - * @param scaleY [description] + * Apply the identity, translate, rotate and scale operations on the Matrix. + * @param x The horizontal translation. + * @param y The vertical translation. + * @param rotation The angle of rotation in radians. + * @param scaleX The horizontal scale. + * @param scaleY The vertical scale. */ applyITRS(x: number, y: number, rotation: number, scaleX: number, scaleY: number): this; + /** + * Takes the `x` and `y` values and returns a new position in the `output` vector that is the inverse of + * the current matrix with its transformation applied. + * + * Can be used to translate points from world to local space. + * @param x The x position to translate. + * @param y The y position to translate. + * @param output A Vector2, or point-like object, to store the results in. + */ + applyInverse(x: number, y: number, output?: Phaser.Math.Vector2): Phaser.Math.Vector2; + + /** + * Returns the X component of this matrix multiplied by the given values. + * This is the same as `x * a + y * c + e`. + * @param x The x value. + * @param y The y value. + */ + getX(x: number, y: number): number; + + /** + * Returns the Y component of this matrix multiplied by the given values. + * This is the same as `x * b + y * d + f`. + * @param x The x value. + * @param y The y value. + */ + getY(x: number, y: number): number; + + /** + * Returns a string that can be used in a CSS Transform call as a `matrix` property. + */ + getCSSMatrix(): string; + /** * Destroys this Transform Matrix. */ @@ -12469,6 +14295,7 @@ declare namespace Phaser { /** * Returns the world transform matrix as used for Bounds checks. + * * The returned matrix is temporal and shouldn't be stored. */ getBoundsTransformMatrix(): Phaser.GameObjects.Components.TransformMatrix; @@ -12508,8 +14335,9 @@ declare namespace Phaser { * Sort the contents of this Container so the items are in order based on the given property. * For example: `sort('alpha')` would sort the elements based on the value of their `alpha` property. * @param property The property to lexically sort by. + * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. */ - sort(property: string): Phaser.GameObjects.Container; + sort(property: string, handler?: Function): Phaser.GameObjects.Container; /** * Searches for the first instance of a child with its `name` property matching the given argument. @@ -12539,7 +14367,7 @@ declare namespace Phaser { * @param startIndex An optional start index to search from. Default 0. * @param endIndex An optional end index to search up to (but not included) Default Container.length. */ - getFirst(property?: string, value?: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.GameObject; + getFirst(property: string, value: any, startIndex?: integer, endIndex?: integer): Phaser.GameObjects.GameObject; /** * Returns all Game Objects in this Container. @@ -12824,6 +14652,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -12846,6 +14675,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -12853,7 +14683,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -12861,28 +14691,50 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -12890,6 +14742,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -12931,12 +14784,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -12987,6 +14844,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -13001,6 +14863,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -13015,6 +14882,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -13143,8 +15015,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -13210,19 +15083,693 @@ declare namespace Phaser { sortByDepth(childA: Phaser.GameObjects.GameObject, childB: Phaser.GameObjects.GameObject): integer; /** - * Given an array of Game Objects, sort the array and return it, so that - * the objects are in index order with the lowest at the bottom. - * @param gameObjects The array of Game Objects to sort. + * Returns an array which contains all objects currently on the Display List. + * This is a reference to the main list array, not a copy of it, so be careful not to modify it. */ - sortGameObjects(gameObjects: Phaser.GameObjects.GameObject[]): any[]; + getChildren(): Phaser.GameObjects.GameObject[]; + + } + + namespace Events { + /** + * The Game Object Destroy Event. + * + * This event is dispatched when a Game Object instance is being destroyed. + * + * Listen for it on a Game Object instance using `GameObject.on('destroy', listener)`. + */ + const DESTROY: any; + + } + + /** + * An Extern Game Object is a special type of Game Object that allows you to pass + * rendering off to a 3rd party. + * + * When you create an Extern and place it in the display list of a Scene, the renderer will + * process the list as usual. When it finds an Extern it will flush the current batch, + * clear down the pipeline and prepare a transform matrix which your render function can + * take advantage of, if required. + * + * The WebGL context is then left is a 'clean' state, ready for you to bind your own shaders, + * or draw to it, whatever you wish to do. Once you've finished, you should free-up any + * of your resources. The Extern will then rebind the Phaser pipeline and carry on + * rendering the display list. + * + * Although this object has lots of properties such as Alpha, Blend Mode and Tint, none of + * them are used during rendering unless you take advantage of them in your own render code. + */ + class Extern extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + */ + constructor(scene: Phaser.Scene); /** - * Get the top-most Game Object in the given array of Game Objects, after sorting it. + * Clears all alpha values associated with this Game Object. * - * Note that the given array is sorted in place, even though it isn't returned directly it will still be updated. - * @param gameObjects The array of Game Objects. + * Immediately sets the alpha levels back to 1 (fully opaque). */ - getTopGameObject(gameObjects: Phaser.GameObjects.GameObject[]): Phaser.GameObjects.GameObject; + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * The horizontally flipped state of the Game Object. + * A Game Object that is flipped horizontally will render inversed on the horizontal axis. + * Flipping always takes place from the middle of the texture and does not impact the scale value. + */ + flipX: boolean; + + /** + * The vertically flipped state of the Game Object. + * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) + * Flipping always takes place from the middle of the texture and does not impact the scale value. + */ + flipY: boolean; + + /** + * Toggles the horizontal flipped state of this Game Object. + */ + toggleFlipX(): this; + + /** + * Toggles the vertical flipped state of this Game Object. + */ + toggleFlipY(): this; + + /** + * Sets the horizontal flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipX(value: boolean): this; + + /** + * Sets the vertical flipped state of this Game Object. + * @param value The flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlipY(value: boolean): this; + + /** + * Sets the horizontal and vertical flipped state of this Game Object. + * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. + * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. + */ + setFlip(x: boolean, y: boolean): this; + + /** + * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. + */ + resetFlip(): this; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param frame The frame to base the size of this Game Object on. + */ + setSizeToFrame(frame: Phaser.Textures.Frame): this; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture. + * @param updateSize Should this call adjust the size of the Game Object? Default true. + * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. + */ + setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + + /** + * Fill or additive? + */ + tintFill: boolean; + + /** + * Clears all tint values associated with this Game Object. + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. + */ + clearTint(): this; + + /** + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + + /** + * The tint value being applied to the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopLeft: integer; + + /** + * The tint value being applied to the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintTopRight: integer; + + /** + * The tint value being applied to the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomLeft: integer; + + /** + * The tint value being applied to the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + tintBottomRight: integer; + + /** + * The tint value being applied to the whole of the Game Object. + */ + tint: integer; + + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; } @@ -13251,6 +15798,18 @@ declare namespace Phaser { */ type: string; + /** + * The current state of this Game Object. + * + * Phaser itself will never modify this value, although plugins may do so. + * + * Use this property to track the state of a Game Object during its lifetime. For example, it could move from + * a state of 'moving', to 'attacking', to 'dead'. The state value should be an integer (ideally mapped to a constant + * in your game code), or a string. These are recommended to keep it light and simple, with fast comparisons. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + */ + state: integer | string; + /** * The parent Container of this Game Object, if it has one. */ @@ -13291,7 +15850,8 @@ declare namespace Phaser { /** * A bitmask that controls if this Game Object is drawn by a Camera or not. - * Not usually set directly. Instead call `Camera.ignore`. + * Not usually set directly, instead call `Camera.ignore`, however you can + * set this property directly using the Camera.id property: */ cameraFilter: number; @@ -13319,19 +15879,32 @@ declare namespace Phaser { * A Game Object with its `active` property set to `true` will be updated by the Scenes UpdateList. * @param value True if this Game Object should be set as active, false if not. */ - setActive(value: boolean): Phaser.GameObjects.GameObject; + setActive(value: boolean): this; /** * Sets the `name` property of this Game Object and returns this Game Object for further chaining. * The `name` property is not populated by Phaser and is presented for your own use. * @param value The name to be given to this Game Object. */ - setName(value: string): Phaser.GameObjects.GameObject; + setName(value: string): this; + + /** + * Sets the current state of this Game Object. + * + * Phaser itself will never modify the State of a Game Object, although plugins may do so. + * + * For example, a Game Object could change from a state of 'moving', to 'attacking', to 'dead'. + * The state value should typically be an integer (ideally mapped to a constant + * in your game code), but could also be a string. It is recommended to keep it light and simple. + * If you need to store complex data about your Game Object, look at using the Data Component instead. + * @param value The state of the Game Object. + */ + setState(value: integer | string): this; /** * Adds a Data Manager component to this Game Object. */ - setDataEnabled(): Phaser.GameObjects.GameObject; + setDataEnabled(): this; /** * Allows you to store a key value pair within this Game Objects Data Manager. @@ -13366,7 +15939,7 @@ declare namespace Phaser { * When the value is first set, a `setdata` event is emitted from this Game Object. * * If the key already exists, a `changedata` event is emitted instead, along an event named after the key. - * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata_PlayerLives`. + * For example, if you updated an existing key called `PlayerLives` then it would emit the event `changedata-PlayerLives`. * These events will be emitted regardless if you use this method to set the value, or the direct `values` setter. * * Please note that the data keys are case-sensitive and must be valid JavaScript Object property strings. @@ -13418,7 +15991,7 @@ declare namespace Phaser { * @param callback A callback to be invoked when the Game Object is interacted with. If you provide a shape you must also provide a callback. * @param dropZone Should this Game Object be treated as a drop zone target? Default false. */ - setInteractive(shape?: Phaser.Input.InputConfiguration | any, callback?: HitAreaCallback, dropZone?: boolean): Phaser.GameObjects.GameObject; + setInteractive(shape?: Phaser.Input.InputConfiguration | any, callback?: HitAreaCallback, dropZone?: boolean): this; /** * If this Game Object has previously been enabled for input, this will disable it. @@ -13429,27 +16002,35 @@ declare namespace Phaser { * * If want to completely remove interaction from this Game Object then use `removeInteractive` instead. */ - disableInteractive(): Phaser.GameObjects.GameObject; + disableInteractive(): this; /** - * If this Game Object has previously been enabled for input, this will remove it. + * If this Game Object has previously been enabled for input, this will queue it + * for removal, causing it to no longer be interactive. The removal happens on + * the next game step, it is not immediate. * * The Interactive Object that was assigned to this Game Object will be destroyed, * removed from the Input Manager and cleared from this Game Object. * * If you wish to re-enable this Game Object at a later date you will need to - * re-create its InteractiveOobject by calling `setInteractive` again. + * re-create its InteractiveObject by calling `setInteractive` again. * * If you wish to only temporarily stop an object from receiving input then use * `disableInteractive` instead, as that toggles the interactive state, where-as * this erases it completely. + * + * If you wish to resize a hit area, don't remove and then set it as being + * interactive. Instead, access the hitarea object directly and resize the shape + * being used. I.e.: `sprite.input.hitArea.setSize(width, height)` (assuming the + * shape is a Rectangle, which it is by default.) */ - removeInteractive(): Phaser.GameObjects.GameObject; + removeInteractive(): this; /** * To be overridden by custom GameObjects. Allows base objects to be used in a Pool. + * @param args args */ - update(): void; + update(...args: any[]): void; /** * Returns a JSON representation of the Game Object. @@ -13458,8 +16039,10 @@ declare namespace Phaser { /** * Compares the renderMask with the renderFlags to see if this Game Object will render or not. + * Also checks the Game Object against the given Cameras exclusion list. + * @param camera The Camera to check against this Game Object. */ - willRender(): boolean; + willRender(camera: Phaser.Cameras.Scene2D.Camera): boolean; /** * Returns an array containing the display list index of either this Game Object, or if it has one, @@ -13483,8 +16066,9 @@ declare namespace Phaser { * * If you just want to temporarily disable an object then look at using the * Game Object Pool instead of destroying it, as destroyed objects cannot be resurrected. + * @param fromScene Is this Game Object being destroyed as the result of a Scene shutdown? Default false. */ - destroy(): void; + destroy(fromScene?: boolean): void; /** * The bitmask that `GameObject.renderFlags` is compared against to determine if the Game Object will render or not. @@ -13577,9 +16161,9 @@ declare namespace Phaser { * Creates a new Group Game Object and returns it. * * Note: This method will only be available if the Group Game Object has been built into Phaser. - * @param config [description] + * @param config The configuration object this Game Object will use to create itself. */ - group(config: GroupConfig): Phaser.GameObjects.Group; + group(config: GroupConfig | GroupCreateConfig): Phaser.GameObjects.Group; /** * Creates a new Image Game Object and returns it. @@ -13633,16 +16217,7 @@ declare namespace Phaser { * @param config The configuration object this Game Object will use to create itself. * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. */ - sprite(config: object, addToScene?: boolean): Phaser.GameObjects.Sprite; - - /** - * Creates a new Sprite3D Game Object and returns it. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * @param config The configuration object this Game Object will use to create itself. - * @param addToScene Add this Game Object to the Scene after creating it? If set this argument overrides the `add` property in the config object. - */ - sprite3D(config: object, addToScene?: boolean): Phaser.GameObjects.Sprite3D; + sprite(config: SpriteConfig, addToScene?: boolean): Phaser.GameObjects.Sprite; /** * Creates a new Text Game Object and returns it. @@ -13666,7 +16241,7 @@ declare namespace Phaser { * Creates a new Zone Game Object and returns it. * * Note: This method will only be available if the Zone Game Object has been built into Phaser. - * @param config [description] + * @param config The configuration object this Game Object will use to create itself. */ zone(config: object): Phaser.GameObjects.Zone; @@ -13713,6 +16288,32 @@ declare namespace Phaser { /** * Creates a new Dynamic Bitmap Text Game Object and adds it to the Scene. * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * Dynamic Bitmap Text objects are different from Static Bitmap Text in that they invoke a callback for each + * letter being rendered during the render pass. This callback allows you to manipulate the properties of + * each letter being rendered, such as its position, scale or tint, allowing you to create interesting effects + * like jiggling text, which can't be done with Static text. This means that Dynamic Text takes more processing + * time, so only use them if you require the callback ability they have. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * * Note: This method will only be available if the Dynamic Bitmap Text Game Object has been built into Phaser. * @param x The x position of the Game Object. * @param y The y position of the Game Object. @@ -13725,14 +16326,35 @@ declare namespace Phaser { /** * Creates a new Bitmap Text Game Object and adds it to the Scene. * + * BitmapText objects work by taking a texture file and an XML or JSON file that describes the font structure. + * + * During rendering for each letter of the text is rendered to the display, proportionally spaced out and aligned to + * match the font structure. + * + * BitmapText objects are less flexible than Text objects, in that they have less features such as shadows, fills and the ability + * to use Web Fonts, however you trade this flexibility for rendering speed. You can also create visually compelling BitmapTexts by + * processing the font texture in an image editor, applying fills and any other effects required. + * + * To create multi-line text insert \r, \n or \r\n escape codes into the text string. + * + * To create a BitmapText data files you need a 3rd party app such as: + * + * BMFont (Windows, free): http://www.angelcode.com/products/bmfont/ + * Glyph Designer (OS X, commercial): http://www.71squared.com/en/glyphdesigner + * Littera (Web-based, free): http://kvazars.com/littera/ + * + * For most use cases it is recommended to use XML. If you wish to use JSON, the formatting should be equal to the result of + * converting a valid XML file through the popular X2JS library. An online tool for conversion can be found here: http://codebeautify.org/xmltojson + * * Note: This method will only be available if the Bitmap Text Game Object has been built into Phaser. * @param x The x position of the Game Object. * @param y The y position of the Game Object. * @param font The key of the font to use from the BitmapFont cache. * @param text The string, or array of strings, to be set as the content of this Bitmap Text. * @param size The font size to set. + * @param align The alignment of the text in a multi-line BitmapText object. Default 0. */ - bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number): Phaser.GameObjects.BitmapText; + bitmapText(x: number, y: number, font: string, text?: string | string[], size?: number, align?: integer): Phaser.GameObjects.BitmapText; /** * Creates a new Blitter Game Object and adds it to the Scene. @@ -13755,6 +16377,13 @@ declare namespace Phaser { */ container(x: number, y: number, children?: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[]): Phaser.GameObjects.Container; + /** + * Creates a new Extern Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Extern Game Object has been built into Phaser. + */ + extern(): Phaser.GameObjects.Extern; + /** * The Scene to which this Game Object Factory belongs. */ @@ -13799,7 +16428,7 @@ declare namespace Phaser { * @param children Game Objects to add to this Group; or the `config` argument. * @param config A Group Configuration object. */ - group(children?: Phaser.GameObjects.GameObject[] | GroupConfig, config?: GroupConfig): Phaser.GameObjects.Group; + group(children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupConfig[], config?: GroupConfig | GroupCreateConfig): Phaser.GameObjects.Group; /** * Creates a new Image Game Object and adds it to the Scene. @@ -13832,10 +16461,10 @@ declare namespace Phaser { * * Note: This method will only be available if the Particles Game Object has been built into Phaser. * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame [description] - * @param emitters [description] + * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param emitters Configuration settings for one or more emitters to create. */ - particles(texture: string, frame?: string | integer | object, emitters?: object): Phaser.GameObjects.Particles.ParticleEmitterManager; + particles(texture: string, frame?: string | integer | object, emitters?: ParticleEmitterConfig | ParticleEmitterConfig[]): Phaser.GameObjects.Particles.ParticleEmitterManager; /** * Creates a new PathFollower Game Object and adds it to the Scene. @@ -13864,6 +16493,10 @@ declare namespace Phaser { * Creates a new Render Texture Game Object and adds it to the Scene. * * Note: This method will only be available if the Render Texture Game Object has been built into Phaser. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. * @param width The width of the Render Texture. Default 32. @@ -13871,6 +16504,330 @@ declare namespace Phaser { */ renderTexture(x: number, y: number, width?: integer, height?: integer): Phaser.GameObjects.RenderTexture; + /** + * Creates a new Arc Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param radius The radius of the arc. Default 128. + * @param startAngle The start angle of the arc, in degrees. Default 0. + * @param endAngle The end angle of the arc, in degrees. Default 360. + * @param anticlockwise The winding order of the start and end angles. Default false. + * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + arc(x?: number, y?: number, radius?: number, startAngle?: integer, endAngle?: integer, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; + + /** + * Creates a new Circle Shape Game Object and adds it to the Scene. + * + * A Circle is an Arc with no defined start and end angle, making it render as a complete circle. + * + * Note: This method will only be available if the Arc Game Object has been built into Phaser. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param radius The radius of the circle. Default 128. + * @param fillColor The color the circle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the circle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + circle(x?: number, y?: number, radius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Arc; + + /** + * Creates a new Curve Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Curve Game Object has been built into Phaser. + * + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param curve The Curve object to use to create the Shape. + * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + curve(x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Curve; + + /** + * Creates a new Ellipse Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Ellipse Game Object has been built into Phaser. + * + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + ellipse(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Ellipse; + + /** + * Creates a new Grid Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Grid Game Object has been built into Phaser. + * + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the grid. Default 128. + * @param height The height of the grid. Default 128. + * @param cellWidth The width of one cell in the grid. Default 32. + * @param cellHeight The height of one cell in the grid. Default 32. + * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param outlineFillColor The color of the lines between the grid cells. + * @param outlineFillAlpha The alpha of the lines between the grid cells. + */ + grid(x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number): Phaser.GameObjects.Grid; + + /** + * Creates a new IsoBox Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoBox Game Object has been built into Phaser. + * + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. + * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. + * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. + */ + isobox(x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoBox; + + /** + * Creates a new IsoTriangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the IsoTriangle Game Object has been built into Phaser. + * + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. + * @param reversed Is the iso triangle upside down? Default false. + * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. + * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. + */ + isotriangle(x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number): Phaser.GameObjects.IsoTriangle; + + /** + * Creates a new Line Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Line Game Object has been built into Phaser. + * + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the start of the line. Default 0. + * @param y1 The vertical position of the start of the line. Default 0. + * @param x2 The horizontal position of the end of the line. Default 128. + * @param y2 The vertical position of the end of the line. Default 0. + * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. + * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ + line(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number): Phaser.GameObjects.Line; + + /** + * Creates a new Polygon Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Polygon Game Object has been built into Phaser. + * + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The points that make up the polygon. + * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + polygon(x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Polygon; + + /** + * Creates a new Rectangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Rectangle Game Object has been built into Phaser. + * + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the rectangle. Default 128. + * @param height The height of the rectangle. Default 128. + * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + rectangle(x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Rectangle; + + /** + * Creates a new Star Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Star Game Object has been built into Phaser. + * + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The number of points on the star. Default 5. + * @param innerRadius The inner radius of the star. Default 32. + * @param outerRadius The outer radius of the star. Default 64. + * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + star(x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Star; + + /** + * Creates a new Triangle Shape Game Object and adds it to the Scene. + * + * Note: This method will only be available if the Triangle Game Object has been built into Phaser. + * + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the first point in the triangle. Default 0. + * @param y1 The vertical position of the first point in the triangle. Default 128. + * @param x2 The horizontal position of the second point in the triangle. Default 64. + * @param y2 The vertical position of the second point in the triangle. Default 0. + * @param x3 The horizontal position of the third point in the triangle. Default 128. + * @param y3 The vertical position of the third point in the triangle. Default 128. + * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + triangle(x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number): Phaser.GameObjects.Triangle; + /** * Creates a new Sprite Game Object and adds it to the Scene. * @@ -13882,21 +16839,32 @@ declare namespace Phaser { */ sprite(x: number, y: number, texture: string, frame?: string | integer): Phaser.GameObjects.Sprite; - /** - * Creates a new Sprite3D Game Object and adds it to the Scene. - * - * Note: This method will only be available if the Sprite3D Game Object has been built into Phaser. - * @param x The horizontal position of this Game Object. - * @param y The vertical position of this Game Object. - * @param z The z position of this Game Object. - * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - sprite3D(x: number, y: number, z: number, texture: string, frame?: string | integer): Phaser.GameObjects.Sprite3D; - /** * Creates a new Text Game Object and adds it to the Scene. * + * A Text Game Object. + * + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. + * * Note: This method will only be available if the Text Game Object has been built into Phaser. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. @@ -13911,12 +16879,12 @@ declare namespace Phaser { * Note: This method will only be available if the TileSprite Game Object has been built into Phaser. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. - * @param height The height of the Game Object. + * @param width The width of the Game Object. If zero it will use the size of the texture frame. + * @param height The height of the Game Object. If zero it will use the size of the texture frame. * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. * @param frame An optional frame from the Texture this Game Object is rendering with. */ - tileSprite(x: number, y: number, width: number, height: number, texture: string, frame?: string | integer): Phaser.GameObjects.TileSprite; + tileSprite(x: number, y: number, width: integer, height: integer, texture: string, frame?: string | integer): Phaser.GameObjects.TileSprite; /** * Creates a new Zone Game Object and adds it to the Scene. @@ -13965,7 +16933,7 @@ declare namespace Phaser { } /** - * A Graphics object is a way to draw primitive shapes to you game. Primitives include forms of geometry, such as + * A Graphics object is a way to draw primitive shapes to your game. Primitives include forms of geometry, such as * Rectangles, Circles, and Polygons. They also include lines, arcs and curves. When you initially create a Graphics * object it will be empty. * @@ -14010,7 +16978,7 @@ declare namespace Phaser { * @param scene The Scene to which this Graphics object belongs. * @param options Options that set the position and default style of this Graphics object. */ - constructor(scene: Phaser.Scene, options?: Partial); + constructor(scene: Phaser.Scene, options?: GraphicsOptions); /** * The horizontal display origin of the Graphics. @@ -14073,6 +17041,68 @@ declare namespace Phaser { */ fillStyle(color: number, alpha?: number): Phaser.GameObjects.Graphics; + /** + * Sets a gradient fill style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all filled shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `fillStyle` and provide a new single fill color. + * + * When filling a triangle only the first 3 color values provided are used for the 3 points of a triangle. + * + * This feature is best used only on rectangles and triangles. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient fill a shape or path as a single + * entity at this time. + * @param topLeft The tint being applied to the top-left of the Game Object. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * @param alpha The fill alpha. Default 1. + */ + fillGradientStyle(topLeft: integer, topRight: integer, bottomLeft: integer, bottomRight: integer, alpha?: number): Phaser.GameObjects.Graphics; + + /** + * Sets a gradient line style. This is a WebGL only feature. + * + * The gradient color values represent the 4 corners of an untransformed rectangle. + * The gradient is used to color all stroked shapes and paths drawn after calling this method. + * If you wish to turn a gradient off, call `lineStyle` and provide a new single line color. + * + * This feature is best used only on single lines. All other shapes will give strange results. + * + * Note that for objects such as arcs or ellipses, or anything which is made out of triangles, each triangle used + * will be filled with a gradient on its own. There is no ability to gradient stroke a shape or path as a single + * entity at this time. + * @param lineWidth The stroke width. + * @param topLeft The tint being applied to the top-left of the Game Object. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + * @param alpha The fill alpha. Default 1. + */ + lineGradientStyle(lineWidth: number, topLeft: integer, topRight: integer, bottomLeft: integer, bottomRight: integer, alpha?: number): Phaser.GameObjects.Graphics; + + /** + * Sets the texture frame this Graphics Object will use when drawing all shapes defined after calling this. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * Once set, all shapes will use this texture. Call this method with no arguments to clear it. + * + * The textures are not tiled. They are stretched to the dimensions of the shapes being rendered. For this reason, + * it works best with seamless / tileable textures. + * + * The mode argument controls how the textures are combined with the fill colors. The default value (0) will + * multiply the texture by the fill color. A value of 1 will use just the fill color, but the alpha data from the texture, + * and a value of 2 will use just the texture and no fill color at all. + * @param key The key of the texture to be used, as stored in the Texture Manager. Leave blank to clear a previously set texture. + * @param frame The name or index of the frame within the Texture. + * @param mode The texture tint mode. 0 is multiply, 1 is alpha only and 2 is texture only. Default 0. + */ + setTexture(key?: string, frame?: string | integer, mode?: number): this; + /** * Start a new shape path. */ @@ -14088,11 +17118,27 @@ declare namespace Phaser { */ fillPath(): Phaser.GameObjects.Graphics; + /** + * Fill the current path. + * + * This is an alias for `Graphics.fillPath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + */ + fill(): Phaser.GameObjects.Graphics; + /** * Stroke the current path. */ strokePath(): Phaser.GameObjects.Graphics; + /** + * Stroke the current path. + * + * This is an alias for `Graphics.strokePath` and does the same thing. + * It was added to match the CanvasRenderingContext 2D API. + */ + stroke(): Phaser.GameObjects.Graphics; + /** * Fill the given circle. * @param circle The circle to fill. @@ -14151,6 +17197,26 @@ declare namespace Phaser { */ strokeRect(x: number, y: number, width: number, height: number): Phaser.GameObjects.Graphics; + /** + * Fill a rounded rectangle with the given position, size and radius. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. + */ + fillRoundedRect(x: number, y: number, width: number, height: number, radius?: RoundedRectRadius | number): Phaser.GameObjects.Graphics; + + /** + * Stroke a rounded rectangle with the given position, size and radius. + * @param x The x coordinate of the top-left of the rectangle. + * @param y The y coordinate of the top-left of the rectangle. + * @param width The width of the rectangle. + * @param height The height of the rectangle. + * @param radius The corner radius; It can also be an object to specify different radii for corners. Default 20. + */ + strokeRoundedRect(x: number, y: number, width: number, height: number, radius?: RoundedRectRadius | number): Phaser.GameObjects.Graphics; + /** * Fill the given point. * @@ -14236,20 +17302,20 @@ declare namespace Phaser { moveTo(x: number, y: number): Phaser.GameObjects.Graphics; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param rgb [description] + * Draw a line from the current drawing position to the given position with a specific width and color. + * @param x The x coordinate to draw the line to. + * @param y The y coordinate to draw the line to. + * @param width The width of the stroke. + * @param rgb The color of the stroke. */ lineFxTo(x: number, y: number, width: number, rgb: number): Phaser.GameObjects.Graphics; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param rgb [description] + * Move the current drawing position to the given position and change the pen width and color. + * @param x The x coordinate to move to. + * @param y The y coordinate to move to. + * @param width The new stroke width. + * @param rgb The new stroke color. */ moveFxTo(x: number, y: number, width: number, rgb: number): Phaser.GameObjects.Graphics; @@ -14312,6 +17378,13 @@ declare namespace Phaser { * * This method can be used to create circles, or parts of circles. * + * Make sure you call `beginPath` before starting the arc unless you wish for the arc to automatically + * close when filled or stroked. + * + * Use the optional `overshoot` argument increase the number of iterations that take place when + * the arc is rendered in WebGL. This is useful if you're drawing an arc with an especially thick line, + * as it will allow the arc to fully join-up. Try small values at first, i.e. 0.01. + * * Call {@link Phaser.GameObjects.Graphics#fillPath} or {@link Phaser.GameObjects.Graphics#strokePath} after calling * this method to draw the arc. * @param x The x coordinate of the center of the circle. @@ -14320,8 +17393,9 @@ declare namespace Phaser { * @param startAngle The starting angle, in radians. * @param endAngle The ending angle, in radians. * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. + * @param overshoot This value allows you to increase the segment iterations in WebGL rendering. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Use small numbers such as 0.01 to start with and increase as needed. Default 0. */ - arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): Phaser.GameObjects.Graphics; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): Phaser.GameObjects.Graphics; /** * Creates a pie-chart slice shape centered at `x`, `y` with the given radius. @@ -14337,17 +17411,24 @@ declare namespace Phaser { * @param radius The radius of the slice. * @param startAngle The start angle of the slice, given in radians. * @param endAngle The end angle of the slice, given in radians. - * @param anticlockwise Draw the slice piece anticlockwise or clockwise? Default false. + * @param anticlockwise Whether the drawing should be anticlockwise or clockwise. Default false. + * @param overshoot This value allows you to overshoot the endAngle by this amount. Useful if the arc has a thick stroke and needs to overshoot to join-up cleanly. Default 0. */ - slice(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean): Phaser.GameObjects.Graphics; + slice(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise?: boolean, overshoot?: number): Phaser.GameObjects.Graphics; /** - * [description] + * Saves the state of the Graphics by pushing the current state onto a stack. + * + * The most recently saved state can then be restored with {@link Phaser.GameObjects.Graphics#restore}. */ save(): Phaser.GameObjects.Graphics; /** - * [description] + * Restores the most recently saved state of the Graphics by popping from the state stack. + * + * Use {@link Phaser.GameObjects.Graphics#save} to save the current state, and call this afterwards to restore that state. + * + * If there is no saved state, this command does nothing. */ restore(): Phaser.GameObjects.Graphics; @@ -14461,6 +17542,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -14483,6 +17565,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -14490,7 +17573,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -14531,12 +17614,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -14589,15 +17676,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -14732,8 +17819,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -14761,6 +17849,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -14775,6 +17868,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -14789,6 +17887,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -14807,10 +17910,10 @@ declare namespace Phaser { /** * * @param scene The scene this group belongs to. - * @param children Game objects to add to this group; or the `config` argument. + * @param children Game Objects to add to this group; or the `config` argument. * @param config Settings for this group. If `key` is set, Phaser.GameObjects.Group#createMultiple is also called with these settings. */ - constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | GroupConfig, config?: GroupConfig | GroupCreateConfig); + constructor(scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig); /** * This scene this group belongs to. @@ -14830,7 +17933,7 @@ declare namespace Phaser { /** * The class to create new group members from. */ - classType: object; + classType: GroupClassTypeConstructor; /** * Whether this group runs its {@link Phaser.GameObjects.Group#preUpdate} method @@ -15149,7 +18252,7 @@ declare namespace Phaser { * 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 Image extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Image extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. @@ -15221,6 +18324,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -15243,6 +18347,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -15250,7 +18355,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -15385,12 +18490,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -15501,15 +18610,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -15545,6 +18654,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -15559,6 +18673,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -15573,6 +18692,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -15580,34 +18704,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -15615,6 +18769,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -15631,6 +18786,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -15655,21 +18846,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -15699,6 +18933,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -15822,8 +19061,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -15845,7 +19085,11 @@ declare namespace Phaser { /** * A 2D point light. * - * Add these to a scene using the ForwardDiffuseLightPipeline for lighting effects, or just to represent a point light. + * These are typically created by a {@link Phaser.GameObjects.LightsManager}, available from within a scene via `this.lights`. + * + * Any Game Objects using the Light2D pipeline will then be affected by these Lights. + * + * They can also simply be used to represent a point light for your own purposes. */ class Light { /** @@ -15929,7 +19173,7 @@ declare namespace Phaser { /** * Set the color of the light from a single integer RGB value. - * @param rgb [description] + * @param rgb The integer RGB color of the light. */ setColor(rgb: number): Phaser.GameObjects.Light; @@ -15955,59 +19199,73 @@ declare namespace Phaser { } /** - * [description] + * Manages Lights for a Scene. + * + * Affects the rendering of Game Objects using the `Light2D` pipeline. */ class LightsManager { /** - * [description] + * The pool of Lights. + * + * Used to recycle removed Lights for a more efficient use of memory. */ lightPool: Phaser.GameObjects.Light[]; /** - * [description] + * The Lights in the Scene. */ lights: Phaser.GameObjects.Light[]; /** - * [description] + * Lights that have been culled from a Camera's viewport. + * + * Lights in this list will not be rendered. */ culledLights: Phaser.GameObjects.Light[]; /** - * [description] + * The ambient color. */ ambientColor: Object; /** - * [description] + * Whether the Lights Manager is enabled. */ active: boolean; /** - * [description] + * The maximum number of lights that a single Camera and the lights shader can process. + * Change this via the `maxLights` property in your game config, as it cannot be changed at runtime. + */ + readonly maxLights: integer; + + /** + * Enable the Lights Manager. */ enable(): Phaser.GameObjects.LightsManager; /** - * [description] + * Disable the Lights Manager. */ disable(): Phaser.GameObjects.LightsManager; /** - * [description] - * @param camera [description] + * Cull any Lights that aren't visible to the given Camera. + * + * Culling Lights improves performance by ensuring that only Lights within a Camera's viewport are rendered. + * @param camera The Camera to cull Lights for. */ cull(camera: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Light[]; /** - * [description] - * @param callback [description] + * Iterate over each Light with a callback. + * @param callback The callback that is called with each Light. */ forEachLight(callback: LightForEach): Phaser.GameObjects.LightsManager; /** - * [description] - * @param rgb [description] + * Set the ambient light color. + * @param rgb The integer RGB color of the ambient light. */ setAmbientColor(rgb: number): Phaser.GameObjects.LightsManager; @@ -16017,65 +19275,90 @@ declare namespace Phaser { getMaxVisibleLights(): integer; /** - * [description] + * Get the number of Lights managed by this Lights Manager. */ getLightCount(): integer; /** - * [description] - * @param x [description] - * @param y [description] - * @param radius [description] - * @param rgb [description] - * @param intensity [description] + * Add a Light. + * @param x The horizontal position of the Light. Default 0. + * @param y The vertical position of the Light. Default 0. + * @param radius The radius of the Light. Default 100. + * @param rgb The integer RGB color of the light. Default 0xffffff. + * @param intensity The intensity of the Light. Default 1. */ - addLight(x: number, y: number, radius: number, rgb: number, intensity: number): Phaser.GameObjects.Light; + addLight(x?: number, y?: number, radius?: number, rgb?: number, intensity?: number): Phaser.GameObjects.Light; /** - * [description] - * @param light [description] + * Remove a Light. + * @param light The Light to remove. */ removeLight(light: Phaser.GameObjects.Light): Phaser.GameObjects.LightsManager; /** - * [description] + * Shut down the Lights Manager. + * + * Recycles all active Lights into the Light pool, resets ambient light color and clears the lists of Lights and + * culled Lights. */ shutdown(): void; /** - * [description] + * Destroy the Lights Manager. + * + * Cleans up all references by calling {@link Phaser.GameObjects.LightsManager#shutdown}. */ destroy(): void; } /** - * [description] + * A Scene plugin that provides a {@link Phaser.GameObjects.LightsManager} for the Light2D pipeline. + * + * Available from within a Scene via `this.lights`. + * + * Add Lights using the {@link Phaser.GameObjects.LightsManager#addLight} method: + * + * ```javascript + * // Enable the Lights Manager because it is disabled by default + * this.lights.enable(); + * + * // Create a Light at [400, 300] with a radius of 200 + * this.lights.addLight(400, 300, 200); + * ``` + * + * For Game Objects to be affected by the Lights when rendered, you will need to set them to use the `Light2D` pipeline like so: + * + * ```javascript + * sprite.setPipeline('Light2D'); + * ``` */ class LightsPlugin extends Phaser.GameObjects.LightsManager { /** * - * @param scene [description] + * @param scene The Scene that this Lights Plugin belongs to. */ constructor(scene: Phaser.Scene); /** - * [description] + * A reference to the Scene that this Lights Plugin belongs to. */ scene: Phaser.Scene; /** - * [description] + * A reference to the Scene's systems. */ systems: Phaser.Scenes.Systems; /** - * [description] + * Boot the Lights Plugin. */ boot(): void; /** - * [description] + * Destroy the Lights Plugin. + * + * Cleans up all references. */ destroy(): void; @@ -16084,7 +19367,7 @@ declare namespace Phaser { /** * A Mesh Game Object. */ - class Mesh extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { + class Mesh extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. @@ -16120,55 +19403,15 @@ declare namespace Phaser { alphas: Float32Array; /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). + * Fill or additive mode used when blending the color values? */ - clearAlpha(): this; + tintFill: boolean; /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + * This method is left intentionally empty and does not do anything. + * It is retained to allow a Mesh or Quad to be added to a Container. */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: number; + setAlpha(): void; /** * Sets the Blend Mode being used by this Game Object. @@ -16180,6 +19423,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -16202,6 +19446,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -16209,7 +19454,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -16242,54 +19487,6 @@ declare namespace Phaser { */ setDepth(value: integer): this; - /** - * The horizontally flipped state of the Game Object. - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Game Object. - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; - - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; - /** * Gets the center coordinate of this Game Object, regardless of origin. * The returned point is calculated in local space and does not factor in any parent containers @@ -16344,12 +19541,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -16389,64 +19590,6 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - /** * The initial WebGL pipeline of this Game Object. */ @@ -16460,15 +19603,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -16495,34 +19638,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -16530,6 +19703,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -16693,8 +19867,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -16722,6 +19897,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -16736,6 +19916,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -16750,6 +19935,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -16759,174 +19949,194 @@ declare namespace Phaser { namespace Particles { /** - * [description] + * A Particle Emitter property. + * + * Facilitates changing Particle properties as they are emitted and throughout their lifetime. */ class EmitterOp { /** * - * @param config [description] - * @param key [description] - * @param defaultValue [description] - * @param emitOnly [description] Default false. + * @param config Settings for the Particle Emitter that owns this property. + * @param key The name of the property. + * @param defaultValue The default value of the property. + * @param emitOnly Whether the property can only be modified when a Particle is emitted. Default false. */ - constructor(config: object, key: string, defaultValue: number, emitOnly?: boolean); + constructor(config: ParticleEmitterConfig, key: string, defaultValue: number, emitOnly?: boolean); /** - * [description] + * The name of this property. */ propertyKey: string; /** - * [description] + * The value of this property. */ propertyValue: number; /** - * [description] + * The default value of this property. */ defaultValue: number; /** - * [description] + * The number of steps for stepped easing between {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} values, per emit. */ steps: number; /** - * [description] + * The step counter for stepped easing, per emit. */ counter: number; /** - * [description] + * The start value for this property to ease between. */ start: number; /** - * [description] + * The end value for this property to ease between. */ end: number; /** - * [description] + * The easing function to use for updating this property. */ ease: Function; /** - * [description] + * Whether this property can only be modified when a Particle is emitted. + * + * Set to `true` to allow only {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} callbacks to be set and + * affect this property. + * + * Set to `false` to allow both {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks to be set and affect this property. */ emitOnly: boolean; /** - * [description] + * The callback to run for Particles when they are emitted from the Particle Emitter. */ onEmit: EmitterOpOnEmitCallback; /** - * [description] + * The callback to run for Particles when they are updated. */ onUpdate: EmitterOpOnUpdateCallback; /** - * [description] - * @param config [description] - * @param newKey [description] + * Load the property from a Particle Emitter configuration object. + * + * Optionally accepts a new property key to use, replacing the current one. + * @param config Settings for the Particle Emitter that owns this property. + * @param newKey The new key to use for this property, if any. */ - loadConfig(config?: object, newKey?: string): void; + loadConfig(config?: ParticleEmitterConfig, newKey?: string): void; /** - * [description] + * Build a JSON representation of this Particle Emitter property. */ toJSON(): object; /** - * [description] - * @param value [description] + * Change the current value of the property and update its callback methods. + * @param value The value of the property. */ onChange(value: number): Phaser.GameObjects.Particles.EmitterOp; /** - * [description] + * Update the {@link Phaser.GameObjects.Particles.EmitterOp#onEmit} and + * {@link Phaser.GameObjects.Particles.EmitterOp#onUpdate} callbacks based on the type of the current + * {@link Phaser.GameObjects.Particles.EmitterOp#propertyValue}. */ setMethods(): Phaser.GameObjects.Particles.EmitterOp; /** - * [description] - * @param object [description] - * @param key [description] + * Check whether an object has the given property. + * @param object The object to check. + * @param key The key of the property to look for in the object. */ has(object: object, key: string): boolean; /** - * [description] - * @param object [description] - * @param key1 [description] - * @param key2 [description] + * Check whether an object has both of the given properties. + * @param object The object to check. + * @param key1 The key of the first property to check the object for. + * @param key2 The key of the second property to check the object for. */ hasBoth(object: object, key1: string, key2: string): boolean; /** - * [description] - * @param object [description] - * @param key1 [description] - * @param key2 [description] + * Check whether an object has at least one of the given properties. + * @param object The object to check. + * @param key1 The key of the first property to check the object for. + * @param key2 The key of the second property to check the object for. */ hasEither(object: object, key1: string, key2: string): boolean; /** * The returned value sets what the property will be at the START of the particles life, on emit. - * @param particle [description] - * @param key [description] - * @param value [description] + * @param particle The particle. + * @param key The name of the property. + * @param value The current value of the property. */ - defaultEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value: number): number; + defaultEmit(particle: Phaser.GameObjects.Particles.Particle, key: string, value?: number): number; /** * The returned value updates the property for the duration of the particles life. - * @param particle [description] - * @param key [description] + * @param particle The particle. + * @param key The name of the property. * @param t The T value (between 0 and 1) - * @param value [description] + * @param value The current value of the property. */ defaultUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number, value: number): number; /** - * [description] + * An `onEmit` callback that returns the current value of the property. */ staticValueEmit(): number; /** - * [description] + * An `onUpdate` callback that returns the current value of the property. */ staticValueUpdate(): number; /** - * [description] + * An `onEmit` callback that returns a random value from the current value array. */ randomStaticValueEmit(): number; /** - * [description] - * @param particle [description] - * @param key [description] + * An `onEmit` callback that returns a value between the {@link Phaser.GameObjects.Particles.EmitterOp#start} and + * {@link Phaser.GameObjects.Particles.EmitterOp#end} range. + * @param particle The particle. + * @param key The key of the property. */ randomRangedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; /** - * [description] + * An `onEmit` callback that returns a stepped value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. */ steppedEmit(): number; /** - * [description] - * @param particle [description] - * @param key [description] + * An `onEmit` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * @param particle The particle. + * @param key The name of the property. */ easedValueEmit(particle: Phaser.GameObjects.Particles.Particle, key: string): number; /** - * [description] - * @param particle [description] - * @param key [description] + * An `onUpdate` callback that returns an eased value between the + * {@link Phaser.GameObjects.Particles.EmitterOp#start} and {@link Phaser.GameObjects.Particles.EmitterOp#end} + * range. + * @param particle The particle. + * @param key The name of the property. * @param t The T value (between 0 and 1) */ easeValueUpdate(particle: Phaser.GameObjects.Particles.Particle, key: string, t: number): number; @@ -16934,15 +20144,19 @@ declare namespace Phaser { } /** - * [description] + * The GravityWell action applies a force on the particle to draw it towards, or repel it from, a single point. + * + * The force applied is inversely proportional to the square of the distance from the particle to the point, in accordance with Newton's law of gravity. + * + * This simulates the effect of gravity over large distances (as between planets, for example). */ class GravityWell { /** * * @param x The x coordinate of the Gravity Well, in world space. Default 0. * @param y The y coordinate of the Gravity Well, in world space. Default 0. - * @param power The power of the Gravity Well. Default 0. - * @param epsilon [description] Default 100. + * @param power The strength of the gravity force - larger numbers produce a stronger force. Default 0. + * @param epsilon The minimum distance for which the gravity force is calculated. Default 100. * @param gravity The gravitational force of this Gravity Well. Default 50. */ constructor(x?: number | GravityWellConfig, y?: number, power?: number, epsilon?: number, gravity?: number); @@ -16963,12 +20177,12 @@ declare namespace Phaser { active: boolean; /** - * The power of the Gravity Well. + * The strength of the gravity force - larger numbers produce a stronger force. */ power: number; /** - * [description] + * The minimum distance for which the gravity force is calculated. */ epsilon: number; @@ -17005,11 +20219,6 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; - /** - * The position of this Particle within its Emitter's particle pool. - */ - index: number; - /** * The x coordinate of this Particle. */ @@ -17085,11 +20294,6 @@ declare namespace Phaser { */ tint: integer; - /** - * The full color of this Particle, computed from its alpha and tint. - */ - color: integer; - /** * The lifespan of this Particle in ms. */ @@ -17120,6 +20324,11 @@ declare namespace Phaser { */ isAlive(): boolean; + /** + * Resets the position of this particle back to zero. + */ + resetPosition(): void; + /** * Starts this Particle from the given coordinates. * @param x The x coordinate to launch this Particle from. @@ -17238,7 +20447,7 @@ declare namespace Phaser { gravityY: number; /** - * Whether accelerationX and accelerationY are nonzero. Set automatically during configuration. + * Whether accelerationX and accelerationY are non-zero. Set automatically during configuration. */ acceleration: boolean; @@ -17375,7 +20584,7 @@ declare namespace Phaser { /** * Controls if the emitter is currently emitting a particle flow (when frequency >= 0). * Already alive particles will continue to update until they expire. - * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start}. + * Controlled by {@link Phaser.GameObjects.Particles.ParticleEmitter#start} and {@link Phaser.GameObjects.Particles.ParticleEmitter#stop}. */ on: boolean; @@ -17493,7 +20702,7 @@ declare namespace Phaser { * @param offsetY Vertical offset of the particle origin from the Game Object. Default 0. * @param trackVisible Whether the emitter's visible state will track the target's visible state. Default false. */ - startFollow(target: Phaser.GameObjects.Particles.Particle, offsetX?: number, offsetY?: number, trackVisible?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; + startFollow(target: Phaser.GameObjects.GameObject, offsetX?: number, offsetY?: number, trackVisible?: boolean): Phaser.GameObjects.Particles.ParticleEmitter; /** * Stops following a Game Object. @@ -17698,16 +20907,16 @@ declare namespace Phaser { /** * Calls a function for each active particle in this emitter. * @param callback The function. - * @param thisArg The function's calling context. + * @param context The function's calling context. */ - forEachAlive(callback: ParticleEmitterCallback, thisArg: any): Phaser.GameObjects.Particles.ParticleEmitter; + forEachAlive(callback: ParticleEmitterCallback, context: any): Phaser.GameObjects.Particles.ParticleEmitter; /** * Calls a function for each inactive particle in this emitter. * @param callback The function. - * @param thisArg The function's calling context. + * @param context The function's calling context. */ - forEachDead(callback: ParticleEmitterCallback, thisArg: any): Phaser.GameObjects.Particles.ParticleEmitter; + forEachDead(callback: ParticleEmitterCallback, context: any): Phaser.GameObjects.Particles.ParticleEmitter; /** * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on} the emitter and resets the flow counter. @@ -17719,6 +20928,11 @@ declare namespace Phaser { */ start(): Phaser.GameObjects.Particles.ParticleEmitter; + /** + * Turns {@link Phaser.GameObjects.Particles.ParticleEmitter#on off} the emitter. + */ + stop(): Phaser.GameObjects.Particles.ParticleEmitter; + /** * {@link Phaser.GameObjects.Particles.ParticleEmitter#active Deactivates} the emitter. */ @@ -17781,13 +20995,6 @@ declare namespace Phaser { */ depthSortCallback(a: object, b: object): integer; - /** - * Calculates the difference of two particles, for sorting them by index. - * @param a The first particle. - * @param b The second particle. - */ - indexSortCallback(a: object, b: object): integer; - /** * Sets the Blend Mode being used by this Game Object. * @@ -17798,6 +21005,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -17805,7 +21013,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -17819,12 +21027,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -17875,6 +21087,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -17889,6 +21106,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -17903,6 +21125,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -17921,7 +21148,7 @@ declare namespace Phaser { /** * A Particle Emitter Manager creates and controls {@link Phaser.GameObjects.Particles.ParticleEmitter Particle Emitters} and {@link Phaser.GameObjects.Particles.GravityWell Gravity Wells}. */ - class ParticleEmitterManager extends Phaser.GameObjects.GameObject { + class ParticleEmitterManager extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Emitter Manager belongs. @@ -17929,7 +21156,7 @@ declare namespace Phaser { * @param frame An optional frame from the Texture this Emitter Manager will use to render particles. * @param emitters Configuration settings for one or more emitters to create. */ - constructor(scene: Phaser.Scene, texture: string, frame: string | integer, emitters: ParticleEmitterConfig | ParticleEmitterConfig[]); + constructor(scene: Phaser.Scene, texture: string, frame?: string | integer, emitters?: ParticleEmitterConfig | ParticleEmitterConfig[]); /** * The time scale applied to all emitters and particles, affecting flow rate, lifespan, and movement. @@ -17997,9 +21224,9 @@ declare namespace Phaser { /** * Creates a new Particle Emitter object, adds it to this Emitter Manager and returns a reference to it. - * @param config [description] + * @param config Configuration settings for the Particle Emitter to create. */ - createEmitter(config: object): Phaser.GameObjects.Particles.ParticleEmitter; + createEmitter(config: ParticleEmitterConfig): Phaser.GameObjects.Particles.ParticleEmitter; /** * Adds an existing Gravity Well object to this Emitter Manager. @@ -18009,9 +21236,9 @@ declare namespace Phaser { /** * Creates a new Gravity Well, adds it to this Emitter Manager and returns a reference to it. - * @param config [description] + * @param config Configuration settings for the Gravity Well to create. */ - createGravityWell(config: object): Phaser.GameObjects.Particles.GravityWell; + createGravityWell(config: GravityWellConfig): Phaser.GameObjects.Particles.GravityWell; /** * Emits particles from each active emitter. @@ -18055,6 +21282,208 @@ declare namespace Phaser { */ preUpdate(time: integer, delta: number): void; + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + } namespace Zones { @@ -18101,62 +21530,65 @@ declare namespace Phaser { /** * * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. - * @param quantity [description] - * @param stepRate [description] - * @param yoyo [description] Default false. - * @param seamless [description] Default true. + * @param quantity The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. + * @param stepRate The distance between each particle. When set, `quantity` is implied and should be set to 0. + * @param yoyo Whether particles are placed from start to end and then end to start. Default false. + * @param seamless Whether one endpoint will be removed if it's identical to the other. Default true. */ - constructor(source: EdgeZoneSource, quantity: number, stepRate: number, yoyo?: boolean, seamless?: boolean); + constructor(source: EdgeZoneSource, quantity: integer, stepRate: number, yoyo?: boolean, seamless?: boolean); /** - * [description] + * An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. */ source: EdgeZoneSource | RandomZoneSource; /** - * [description] + * The points placed on the source edge. */ points: Phaser.Geom.Point[]; /** - * [description] + * The number of particles to place on the source edge. Set to 0 to use `stepRate` instead. */ - quantity: number; + quantity: integer; /** - * [description] + * The distance between each particle. When set, `quantity` is implied and should be set to 0. */ stepRate: number; /** - * [description] + * Whether particles are placed from start to end and then end to start. */ yoyo: boolean; /** - * [description] + * The counter used for iterating the EdgeZone's points. */ counter: number; /** - * [description] + * Whether one endpoint will be removed if it's identical to the other. */ seamless: boolean; /** - * [description] + * Update the {@link Phaser.GameObjects.Particles.Zones.EdgeZone#points} from the EdgeZone's + * {@link Phaser.GameObjects.Particles.Zones.EdgeZone#source}. + * + * Also updates internal properties. */ updateSource(): Phaser.GameObjects.Particles.Zones.EdgeZone; /** - * [description] - * @param source [description] + * Change the EdgeZone's source. + * @param source An object instance with a `getPoints(quantity, stepRate)` method returning an array of points. */ - changeSource(source: object): Phaser.GameObjects.Particles.Zones.EdgeZone; + changeSource(source: EdgeZoneSource): Phaser.GameObjects.Particles.Zones.EdgeZone; /** - * [description] - * @param particle [description] + * Get the next point in the Zone and set its coordinates on the given Particle. + * @param particle The Particle. */ getPoint(particle: Phaser.GameObjects.Particles.Particle): void; @@ -18173,13 +21605,13 @@ declare namespace Phaser { constructor(source: RandomZoneSource); /** - * [description] + * An object instance with a `getRandomPoint(point)` method. */ source: RandomZoneSource; /** - * [description] - * @param particle [description] + * Get the next point in the Zone and set its coordinates on the given Particle. + * @param particle The Particle. */ getPoint(particle: Phaser.GameObjects.Particles.Particle): void; @@ -18204,7 +21636,7 @@ declare namespace Phaser { class PathFollower extends Phaser.GameObjects.Sprite { /** * - * @param scene [description] + * @param scene The Scene to which this PathFollower belongs. * @param path The Path this PathFollower is following. It can only follow one Path at a time. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. @@ -18223,11 +21655,6 @@ declare namespace Phaser { */ rotateToPath: boolean; - /** - * [description] - */ - pathRotationVerticalAdjust: boolean; - /** * If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath) * this value is added to the rotation value. This allows you to rotate objects to a path but control @@ -18242,45 +21669,47 @@ declare namespace Phaser { pathOffset: Phaser.Math.Vector2; /** - * [description] + * A Vector2 that stores the current point of the path the follower is on. */ pathVector: Phaser.Math.Vector2; /** - * [description] + * The Tween used for following the Path. */ pathTween: Phaser.Tweens.Tween; /** - * [description] + * Settings for the PathFollower. */ pathConfig: PathConfig; /** - * [description] + * Set the Path that this PathFollower should follow. + * + * Optionally accepts {@link PathConfig} settings. * @param path The Path this PathFollower is following. It can only follow one Path at a time. - * @param config [description] + * @param config Settings for the PathFollower. */ setPath(path: Phaser.Curves.Path, config?: PathConfig): Phaser.GameObjects.PathFollower; /** - * [description] - * @param value [description] + * Set whether the PathFollower should automatically rotate to point in the direction of the Path. + * @param value Whether the PathFollower should automatically rotate to point in the direction of the Path. * @param offset Rotation offset in degrees. Default 0. - * @param verticalAdjust [description] Default false. */ - setRotateToPath(value: number, offset?: number, verticalAdjust?: boolean): Phaser.GameObjects.PathFollower; + setRotateToPath(value: boolean, offset?: number): Phaser.GameObjects.PathFollower; /** * Is this PathFollower actively following a Path or not? + * * To be considered as `isFollowing` it must be currently moving on a Path, and not paused. */ isFollowing(): boolean; /** * Starts this PathFollower following its given Path. - * @param config [description] Default {}. - * @param startAt [description] Default 0. + * @param config The duration of the follow, or a PathFollower config object. Default {}. + * @param startAt Optional start position of the follow, between 0 and 1. Default 0. */ startFollow(config?: number | PathConfig, startAt?: number): Phaser.GameObjects.PathFollower; @@ -18292,18 +21721,21 @@ declare namespace Phaser { /** * Resumes a previously paused PathFollower. + * * If the PathFollower was not paused this has no effect. */ resumeFollow(): Phaser.GameObjects.PathFollower; /** * Stops this PathFollower from following the path any longer. + * * This will invoke any 'stop' conditions that may exist on the Path, or for the follower. */ stopFollow(): Phaser.GameObjects.PathFollower; /** * Internal update handler that advances this PathFollower along the path. + * * Called automatically by the Scene step, should not typically be called directly. * @param time The current timestamp as generated by the Request Animation Frame or SetTimeout. * @param delta The delta time, in ms, elapsed since the last frame. @@ -18371,6 +21803,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -18393,6 +21826,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -18400,7 +21834,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -18535,12 +21969,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -18651,15 +22089,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -18695,6 +22133,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -18709,6 +22152,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -18723,6 +22171,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -18730,34 +22183,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -18765,6 +22248,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -18781,6 +22265,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -18805,21 +22325,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -18849,6 +22412,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -18972,8 +22540,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -19012,6 +22581,19 @@ declare namespace Phaser { */ constructor(scene: Phaser.Scene, x: number, y: number, texture: string, frame?: string | integer); + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * + * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. + * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. + * @param frame The name or index of the frame within the Texture. + */ + setFrame(frame: string | integer): this; + /** * The top-left x vertex of this Quad. */ @@ -19140,57 +22722,6 @@ declare namespace Phaser { */ reset(): Phaser.GameObjects.Quad; - /** - * Clears all alpha values associated with this Game Object. - * - * Immediately sets the alpha levels back to 1 (fully opaque). - */ - clearAlpha(): this; - - /** - * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. - * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. - * - * If your game is running under WebGL you can optionally specify four different alpha values, each of which - * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. - * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. - * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. - * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. - * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. - */ - setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; - - /** - * The alpha value of the Game Object. - * - * This is a global value, impacting the entire Game Object, not just a region of it. - */ - alpha: number; - - /** - * The alpha value starting from the top-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopLeft: number; - - /** - * The alpha value starting from the top-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaTopRight: number; - - /** - * The alpha value starting from the bottom-left of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomLeft: number; - - /** - * The alpha value starting from the bottom-right of the Game Object. - * This value is interpolated from the corner to the center of the Game Object. - */ - alphaBottomRight: number; - /** * Sets the Blend Mode being used by this Game Object. * @@ -19201,6 +22732,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -19223,6 +22755,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -19230,7 +22763,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -19263,54 +22796,6 @@ declare namespace Phaser { */ setDepth(value: integer): this; - /** - * The horizontally flipped state of the Game Object. - * A Game Object that is flipped horizontally will render inversed on the horizontal axis. - * Flipping always takes place from the middle of the texture and does not impact the scale value. - */ - flipX: boolean; - - /** - * The vertically flipped state of the Game Object. - * A Game Object that is flipped vertically will render inversed on the vertical axis (i.e. upside down) - * Flipping always takes place from the middle of the texture and does not impact the scale value. - */ - flipY: boolean; - - /** - * Toggles the horizontal flipped state of this Game Object. - */ - toggleFlipX(): this; - - /** - * Toggles the vertical flipped state of this Game Object. - */ - toggleFlipY(): this; - - /** - * Sets the horizontal flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipX(value: boolean): this; - - /** - * Sets the vertical flipped state of this Game Object. - * @param value The flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlipY(value: boolean): this; - - /** - * Sets the horizontal and vertical flipped state of this Game Object. - * @param x The horizontal flipped state. `false` for no flip, or `true` to be flipped. - * @param y The horizontal flipped state. `false` for no flip, or `true` to be flipped. - */ - setFlip(x: boolean, y: boolean): this; - - /** - * Resets the horizontal and vertical flipped state of this Game Object back to their default un-flipped state. - */ - resetFlip(): this; - /** * Gets the center coordinate of this Game Object, regardless of origin. * The returned point is calculated in local space and does not factor in any parent containers @@ -19365,12 +22850,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -19410,64 +22899,6 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - /** - * The horizontal origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the left of the Game Object. - */ - originX: number; - - /** - * The vertical origin of this Game Object. - * The origin maps the relationship between the size and position of the Game Object. - * The default value is 0.5, meaning all Game Objects are positioned based on their center. - * Setting the value to 0 means the position now relates to the top of the Game Object. - */ - originY: number; - - /** - * The horizontal display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginX: number; - - /** - * The vertical display origin of this Game Object. - * The origin is a normalized value between 0 and 1. - * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. - */ - displayOriginY: number; - - /** - * Sets the origin of this Game Object. - * - * The values are given in the range 0 to 1. - * @param x The horizontal origin value. Default 0.5. - * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. - */ - setOrigin(x?: number, y?: number): this; - - /** - * Sets the origin of this Game Object based on the Pivot values in its Frame. - */ - setOriginFromFrame(): this; - - /** - * Sets the display origin of this Game Object. - * The difference between this and setting the origin is that you can use pixel values for setting the display origin. - * @param x The horizontal display origin value. Default 0. - * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. - */ - setDisplayOrigin(x?: number, y?: number): this; - - /** - * Updates the Display Origin cached values internally stored on this Game Object. - * You don't usually call this directly, but it is exposed for edge-cases where you may. - */ - updateDisplayOrigin(): this; - /** * The initial WebGL pipeline of this Game Object. */ @@ -19481,15 +22912,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -19516,34 +22947,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -19551,6 +23012,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -19576,21 +23038,6 @@ declare namespace Phaser { */ setTexture(key: string, frame?: string | integer): this; - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; - /** * The x position of this Game Object. */ @@ -19714,8 +23161,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -19743,6 +23191,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -19757,6 +23210,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -19771,6 +23229,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -19780,23 +23243,37 @@ declare namespace Phaser { /** * A Render Texture. + * + * A Render Texture is a special texture that allows any number of Game Objects to be drawn to it. You can take many complex objects and + * draw them all to this one texture, which can they be used as the texture for other Game Object's. It's a way to generate dynamic + * textures at run-time that are WebGL friendly and don't invoke expensive GPU uploads. + * + * Note that under WebGL a FrameBuffer, which is what the Render Texture uses internally, cannot be anti-aliased. This means + * that when drawing objects such as Shapes to a Render Texture they will appear to be drawn with no aliasing, however this + * is a technical limitation of WebGL. To get around it, create your shape as a texture in an art package, then draw that + * to the Render Texture. */ - class RenderTexture extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.MatrixStack, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class RenderTexture extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The horizontal position of this Game Object in the world. - * @param y The vertical position of this Game Object in the world. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. * @param width The width of the Render Texture. Default 32. * @param height The height of the Render Texture. Default 32. */ - constructor(scene: Phaser.Scene, x: number, y: number, width?: integer, height?: integer); + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: integer, height?: integer); /** * A reference to either the Canvas or WebGL Renderer that the Game instance is using. */ renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + /** + * A reference to the Texture Manager. + */ + textureManager: Phaser.Textures.TextureManager; + /** * The tint of the Render Texture when rendered. */ @@ -19808,14 +23285,12 @@ declare namespace Phaser { globalAlpha: number; /** - * The HTML Canvas Element that the Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. + * The HTML Canvas Element that the Render Texture is drawing to when using the Canvas Renderer. */ canvas: HTMLCanvasElement; /** * A reference to the Rendering Context belonging to the Canvas Element this Render Texture is drawing to. - * This is only set if Phaser is running with the Canvas Renderer. */ context: CanvasRenderingContext2D; @@ -19825,6 +23300,40 @@ declare namespace Phaser { */ framebuffer: WebGLFramebuffer; + /** + * The Texture corresponding to this Render Texture. + */ + texture: Phaser.Textures.Texture; + + /** + * The Frame corresponding to this Render Texture. + */ + frame: Phaser.Textures.Frame; + + /** + * An internal Camera that can be used to move around the Render Texture. + * Control it just like you would any Scene Camera. The difference is that it only impacts the placement of what + * is drawn to the Render Texture. You can scroll, zoom and rotate this Camera. + */ + camera: Phaser.Cameras.Scene2D.BaseCamera; + + /** + * Is this Render Texture dirty or not? If not it won't spend time clearing or filling itself. + */ + dirty: boolean; + + /** + * A reference to the WebGL Rendering Context. + */ + gl: WebGLRenderingContext; + + /** + * Sets the size of this Game Object. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + /** * Resizes the Render Texture to the new dimensions given. * @@ -19850,6 +23359,162 @@ declare namespace Phaser { */ setGlobalAlpha(alpha: number): this; + /** + * Stores a copy of this Render Texture in the Texture Manager using the given key. + * + * After doing this, any texture based Game Object, such as a Sprite, can use the contents of this + * Render Texture by using the texture key: + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 128, 128); + * + * // Draw something to the Render Texture + * + * rt.saveTexture('doodle'); + * + * this.add.image(400, 300, 'doodle'); + * ``` + * + * Updating the contents of this Render Texture will automatically update _any_ Game Object + * that is using it as a texture. Calling `saveTexture` again will not save another copy + * of the same texture, it will just rename the key of the existing copy. + * + * By default it will create a single base texture. You can add frames to the texture + * by using the `Texture.add` method. After doing this, you can then allow Game Objects + * to use a specific frame from a Render Texture. + * @param key The unique key to store the texture as within the global Texture Manager. + */ + saveTexture(key: string): Phaser.Textures.Texture; + + /** + * Fills the Render Texture with the given color. + * @param rgb The color to fill the Render Texture with. + * @param alpha The alpha value used by the fill. Default 1. + */ + fill(rgb: number, alpha?: number): this; + + /** + * Clears the Render Texture. + */ + clear(): this; + + /** + * Draws the given object, or an array of objects, to this Render Texture using a blend mode of ERASE. + * This has the effect of erasing any filled pixels in the objects from this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot erase a Render Texture from itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * @param entries Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. + * @param y The y position to draw the Frame at, or the offset applied to the object. + */ + erase(entries: any, x?: number, y?: number): this; + + /** + * Draws the given object, or an array of objects, to this Render Texture. + * + * It can accept any of the following: + * + * * Any renderable Game Object, such as a Sprite, Text, Graphics or TileSprite. + * * Dynamic and Static Tilemap Layers. + * * A Group. The contents of which will be iterated and drawn in turn. + * * A Container. The contents of which will be iterated fully, and drawn in turn. + * * A Scene's Display List. Pass in `Scene.children` to draw the whole list. + * * Another Render Texture. + * * A Texture Frame instance. + * * A string. This is used to look-up a texture from the Texture Manager. + * + * Note: You cannot draw a Render Texture to itself. + * + * If passing in a Group or Container it will only draw children that return `true` + * when their `willRender()` method is called. I.e. a Container with 10 children, + * 5 of which have `visible=false` will only draw the 5 visible ones. + * + * If passing in an array of Game Objects it will draw them all, regardless if + * they pass a `willRender` check or not. + * + * You can pass in a string in which case it will look for a texture in the Texture + * Manager matching that string, and draw the base frame. If you need to specify + * exactly which frame to draw then use the method `drawFrame` instead. + * + * You can pass in the `x` and `y` coordinates to draw the objects at. The use of + * the coordinates differ based on what objects are being drawn. If the object is + * a Group, Container or Display List, the coordinates are _added_ to the positions + * of the children. For all other types of object, the coordinates are exact. + * + * The `alpha` and `tint` values are only used by Texture Frames. + * Game Objects use their own alpha and tint values when being drawn. + * + * Calling this method causes the WebGL batch to flush, so it can write the texture + * data to the framebuffer being used internally. The batch is flushed at the end, + * after the entries have been iterated. So if you've a bunch of objects to draw, + * try and pass them in an array in one single call, rather than making lots of + * separate calls. + * @param entries Any renderable Game Object, or Group, Container, Display List, other Render Texture, Texture Frame or an array of any of these. + * @param x The x position to draw the Frame at, or the offset applied to the object. + * @param y The y position to draw the Frame at, or the offset applied to the object. + * @param alpha The alpha value. Only used for Texture Frames and if not specified defaults to the `globalAlpha` property. Game Objects use their own current alpha value. + * @param tint WebGL only. The tint color value. Only used for Texture Frames and if not specified defaults to the `globalTint` property. Game Objects use their own current tint value. + */ + draw(entries: any, x?: number, y?: number, alpha?: number, tint?: number): this; + + /** + * Draws the Texture Frame to the Render Texture at the given position. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * + * ```javascript + * var rt = this.add.renderTexture(0, 0, 800, 600); + * rt.drawFrame(key, frame); + * ``` + * + * You can optionally provide a position, alpha and tint value to apply to the frame + * before it is drawn. + * + * Calling this method will cause a batch flush, so if you've got a stack of things to draw + * in a tight loop, try using the `draw` method instead. + * + * If you need to draw a Sprite to this Render Texture, use the `draw` method instead. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + * @param x The x position to draw the frame at. Default 0. + * @param y The y position to draw the frame at. Default 0. + * @param alpha The alpha to use. If not specified it uses the `globalAlpha` property. + * @param tint WebGL only. The tint color to use. If not specified it uses the `globalTint` property. + */ + drawFrame(key: string, frame?: string | integer, x?: number, y?: number, alpha?: number, tint?: number): this; + /** * Internal destroy handler, called as part of the destroy process. */ @@ -19916,6 +23581,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -19938,6 +23604,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -19945,7 +23612,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -19953,35 +23620,43 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; - /** - * Sets the size of this Game Object. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -20117,12 +23792,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -20162,68 +23841,6 @@ declare namespace Phaser { */ createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; - /** - * [description] - */ - initMatrixStack(): this; - - /** - * [description] - */ - save(): this; - - /** - * [description] - */ - restore(): this; - - /** - * [description] - */ - loadIdentity(): this; - - /** - * [description] - * @param a [description] - * @param b [description] - * @param c [description] - * @param d [description] - * @param tx [description] - * @param ty [description] - */ - transform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - - /** - * [description] - * @param a [description] - * @param b [description] - * @param c [description] - * @param d [description] - * @param tx [description] - * @param ty [description] - */ - setTransform(a: number, b: number, c: number, d: number, tx: number, ty: number): this; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - translate(x: number, y: number): this; - - /** - * [description] - * @param x [description] - * @param y [description] - */ - scale(x: number, y: number): this; - - /** - * [description] - * @param t The angle of rotation, in radians. - */ - rotate(t: number): this; - /** * The horizontal origin of this Game Object. * The origin maps the relationship between the size and position of the Game Object. @@ -20295,15 +23912,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -20339,6 +23956,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -20353,6 +23975,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -20367,26 +23994,74 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ setScrollFactor(x: number, y?: number): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -20416,6 +24091,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -20539,8 +24219,7969 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Arc Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an arc shape. You can control the start and end angles of the arc, + * as well as if the angles are winding clockwise or anti-clockwise. With the default settings + * it renders as a complete circle. By changing the angles you can create other arc shapes, + * such as half-circles. + * + * Arcs also have an `iterations` property and corresponding `setIterations` method. This allows + * you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. + */ + class Arc extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param radius The radius of the arc. Default 128. + * @param startAngle The start angle of the arc, in degrees. Default 0. + * @param endAngle The end angle of the arc, in degrees. Default 360. + * @param anticlockwise The winding order of the start and end angles. Default false. + * @param fillColor The color the arc will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the arc will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, radius?: number, startAngle?: integer, endAngle?: integer, anticlockwise?: boolean, fillColor?: number, fillAlpha?: number); + + /** + * The number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + */ + iterations: number; + + /** + * The radius of the arc. + */ + radius: number; + + /** + * The start angle of the arc, in degrees. + */ + startAngle: integer; + + /** + * The end angle of the arc, in degrees. + */ + endAngle: integer; + + /** + * The winding order of the start and end angles. + */ + anticlockwise: boolean; + + /** + * Sets the radius of the arc. + * This call can be chained. + * @param value The value to set the radius to. + */ + setRadius(value: number): this; + + /** + * Sets the number of iterations used when drawing the arc. + * Increase this value for smoother arcs, at the cost of more polygons being rendered. + * Modify this value by small amounts, such as 0.01. + * This call can be chained. + * @param value The value to set the iterations to. + */ + setIterations(value: number): this; + + /** + * Sets the starting angle of the arc, in degrees. + * This call can be chained. + * @param value The value to set the starting angle to. + */ + setStartAngle(value: integer): this; + + /** + * Sets the ending angle of the arc, in degrees. + * This call can be chained. + * @param value The value to set the ending angle to. + */ + setEndAngle(value: integer): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Curve Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * To render a Curve Shape you must first create a `Phaser.Curves.Curve` object, then pass it to + * the Curve Shape in the constructor. + * + * The Curve shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + */ + class Curve extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param curve The Curve object to use to create the Shape. + * @param fillColor The color the curve will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the curve will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, curve?: Phaser.Curves.Curve, fillColor?: number, fillAlpha?: number); + + /** + * The smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + */ + smoothness: integer; + + /** + * Sets the smoothness of the curve. The number of points used when rendering it. + * Increase this value for smoother curves, at the cost of more polygons being rendered. + * This call can be chained. + * @param value The value to set the smoothness to. + */ + setSmoothness(value: integer): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Ellipse Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * When it renders it displays an ellipse shape. You can control the width and height of the ellipse. + * If the width and height match it will render as a circle. If the width is less than the height, + * it will look more like an egg shape. + * + * The Ellipse shape also has a `smoothness` property and corresponding `setSmoothness` method. + * This allows you to control how smooth the shape renders in WebGL, by controlling the number of iterations + * that take place during construction. Increase and decrease the default value for smoother, or more + * jagged, shapes. + */ + class Ellipse extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param height The height of the ellipse. An ellipse with equal width and height renders as a circle. Default 128. + * @param fillColor The color the ellipse will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the ellipse will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); + + /** + * The smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + */ + smoothness: integer; + + /** + * Sets the size of the ellipse by changing the underlying geometry data, rather than scaling the object. + * This call can be chained. + * @param width The width of the ellipse. + * @param height The height of the ellipse. + */ + setSize(width: number, height: number): this; + + /** + * Sets the smoothness of the ellipse. The number of points used when rendering it. + * Increase this value for a smoother ellipse, at the cost of more polygons being rendered. + * This call can be chained. + * @param value The value to set the smoothness to. + */ + setSmoothness(value: integer): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Grid Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * A Grid Shape allows you to display a grid in your game, where you can control the size of the + * grid as well as the width and height of the grid cells. You can set a fill color for each grid + * cell as well as an alternate fill color. When the alternate fill color is set then the grid + * cells will alternate the fill colors as they render, creating a chess-board effect. You can + * also optionally have an outline fill color. If set, this draws lines between the grid cells + * in the given color. If you specify an outline color with an alpha of zero, then it will draw + * the cells spaced out, but without the lines between them. + */ + class Grid extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param width The width of the grid. Default 128. + * @param height The height of the grid. Default 128. + * @param cellWidth The width of one cell in the grid. Default 32. + * @param cellHeight The height of one cell in the grid. Default 32. + * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + * @param outlineFillColor The color of the lines between the grid cells. See the `setOutline` method. + * @param outlineFillAlpha The alpha of the lines between the grid cells. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, width?: number, height?: number, cellWidth?: number, cellHeight?: number, fillColor?: number, fillAlpha?: number, outlineFillColor?: number, outlineFillAlpha?: number); + + /** + * The width of each grid cell. + * Must be a positive value. + */ + cellWidth: number; + + /** + * The height of each grid cell. + * Must be a positive value. + */ + cellHeight: number; + + /** + * Will the grid render its cells in the `fillColor`? + */ + showCells: boolean; + + /** + * The color of the lines between each grid cell. + */ + outlineFillColor: number; + + /** + * The alpha value for the color of the lines between each grid cell. + */ + outlineFillAlpha: number; + + /** + * Will the grid display the lines between each cell when it renders? + */ + showOutline: boolean; + + /** + * Will the grid render the alternating cells in the `altFillColor`? + */ + showAltCells: boolean; + + /** + * The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + */ + altFillColor: number; + + /** + * The alpha the alternating grid cells will be filled with. + * You can also set the alpha of the overall Shape using its `alpha` property. + */ + altFillAlpha: number; + + /** + * Sets the fill color and alpha level the grid cells will use when rendering. + * + * If this method is called with no values then the grid cells will not be rendered, + * however the grid lines and alternating cells may still be. + * + * Also see the `setOutlineStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * @param fillColor The color the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + */ + setFillStyle(fillColor?: number, fillAlpha?: number): this; + + /** + * Sets the fill color and alpha level that the alternating grid cells will use. + * + * If this method is called with no values then alternating grid cells will not be rendered in a different color. + * + * Also see the `setOutlineStyle` and `setFillStyle` methods. + * + * This call can be chained. + * @param fillColor The color the alternating grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the alternating grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + */ + setAltFillStyle(fillColor?: number, fillAlpha?: number): this; + + /** + * Sets the fill color and alpha level that the lines between each grid cell will use. + * + * If this method is called with no values then the grid lines will not be rendered at all, however + * the cells themselves may still be if they have colors set. + * + * Also see the `setFillStyle` and `setAltFillStyle` methods. + * + * This call can be chained. + * @param fillColor The color the lines between the grid cells will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the lines between the grid cells will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. Default 1. + */ + setOutlineStyle(fillColor?: number, fillAlpha?: number): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The IsoBox Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoBox is an 'isometric' rectangle. Each face of it has a different fill color. You can set + * the color of the top, left and right faces of the rectangle respectively. You can also choose + * which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoBox from under-neath, however you can change the 'angle' by setting + * the `projection` property. + */ + class IsoBox extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso box in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso box. The left and right faces will be this tall. The overall height of the isobox will be this value plus half the `size` value. Default 32. + * @param fillTop The fill color of the top face of the iso box. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso box. Default 0x999999. + * @param fillRight The fill color of the right face of the iso box. Default 0xcccccc. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, fillTop?: number, fillLeft?: number, fillRight?: number); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + */ + projection: integer; + + /** + * The color used to fill in the top of the iso box. + */ + fillTop: number; + + /** + * The color used to fill in the left-facing side of the iso box. + */ + fillLeft: number; + + /** + * The color used to fill in the right-facing side of the iso box. + */ + fillRight: number; + + /** + * Controls if the top-face of the iso box be rendered. + */ + showTop: boolean; + + /** + * Controls if the left-face of the iso box be rendered. + */ + showLeft: boolean; + + /** + * Controls if the right-face of the iso box be rendered. + */ + showRight: boolean; + + /** + * Sets the projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + * This call can be chained. + * @param value The value to set the projection to. + */ + setProjection(value: integer): this; + + /** + * Sets which faces of the iso box will be rendered. + * This call can be chained. + * @param showTop Show the top-face of the iso box. Default true. + * @param showLeft Show the left-face of the iso box. Default true. + * @param showRight Show the right-face of the iso box. Default true. + */ + setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + + /** + * Sets the fill colors for each face of the iso box. + * This call can be chained. + * @param fillTop The color used to fill the top of the iso box. + * @param fillLeft The color used to fill in the left-facing side of the iso box. + * @param fillRight The color used to fill in the right-facing side of the iso box. + */ + setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The IsoTriangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only fill colors and cannot be stroked. + * + * An IsoTriangle is an 'isometric' triangle. Think of it like a pyramid. Each face has a different + * fill color. You can set the color of the top, left and right faces of the triangle respectively + * You can also choose which of the faces are rendered via the `showTop`, `showLeft` and `showRight` properties. + * + * You cannot view an IsoTriangle from under-neath, however you can change the 'angle' by setting + * the `projection` property. The `reversed` property controls if the IsoTriangle is rendered upside + * down or not. + */ + class IsoTriangle extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param size The width of the iso triangle in pixels. The left and right faces will be exactly half this value. Default 48. + * @param height The height of the iso triangle. The left and right faces will be this tall. The overall height of the iso triangle will be this value plus half the `size` value. Default 32. + * @param reversed Is the iso triangle upside down? Default false. + * @param fillTop The fill color of the top face of the iso triangle. Default 0xeeeeee. + * @param fillLeft The fill color of the left face of the iso triangle. Default 0x999999. + * @param fillRight The fill color of the right face of the iso triangle. Default 0xcccccc. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, size?: number, height?: number, reversed?: boolean, fillTop?: number, fillLeft?: number, fillRight?: number); + + /** + * The projection level of the iso box. Change this to change the 'angle' at which you are looking at the box. + */ + projection: integer; + + /** + * The color used to fill in the top of the iso triangle. This is only used if the triangle is reversed. + */ + fillTop: number; + + /** + * The color used to fill in the left-facing side of the iso triangle. + */ + fillLeft: number; + + /** + * The color used to fill in the right-facing side of the iso triangle. + */ + fillRight: number; + + /** + * Controls if the top-face of the iso triangle be rendered. + */ + showTop: boolean; + + /** + * Controls if the left-face of the iso triangle be rendered. + */ + showLeft: boolean; + + /** + * Controls if the right-face of the iso triangle be rendered. + */ + showRight: boolean; + + /** + * Sets if the iso triangle will be rendered upside down or not. + */ + isReversed: boolean; + + /** + * Sets the projection level of the iso triangle. Change this to change the 'angle' at which you are looking at the pyramid. + * This call can be chained. + * @param value The value to set the projection to. + */ + setProjection(value: integer): this; + + /** + * Sets if the iso triangle will be rendered upside down or not. + * This call can be chained. + * @param reversed Sets if the iso triangle will be rendered upside down or not. + */ + setReversed(reversed: boolean): this; + + /** + * Sets which faces of the iso triangle will be rendered. + * This call can be chained. + * @param showTop Show the top-face of the iso triangle (only if `reversed` is true) Default true. + * @param showLeft Show the left-face of the iso triangle. Default true. + * @param showRight Show the right-face of the iso triangle. Default true. + */ + setFaces(showTop?: boolean, showLeft?: boolean, showRight?: boolean): this; + + /** + * Sets the fill colors for each face of the iso triangle. + * This call can be chained. + * @param fillTop The color used to fill the top of the iso triangle. + * @param fillLeft The color used to fill in the left-facing side of the iso triangle. + * @param fillRight The color used to fill in the right-facing side of the iso triangle. + */ + setFillStyle(fillTop?: number, fillLeft?: number, fillRight?: number): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Line Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports only stroke colors and cannot be filled. + * + * A Line Shape allows you to draw a line between two points in your game. You can control the + * stroke color and thickness of the line. In WebGL only you can also specify a different + * thickness for the start and end of the line, allowing you to render lines that taper-off. + * + * If you need to draw multiple lines in a sequence you may wish to use the Polygon Shape instead. + */ + class Line extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the start of the line. Default 0. + * @param y1 The vertical position of the start of the line. Default 0. + * @param x2 The horizontal position of the end of the line. Default 128. + * @param y2 The vertical position of the end of the line. Default 0. + * @param strokeColor The color the line will be drawn in, i.e. 0xff0000 for red. + * @param strokeAlpha The alpha the line will be drawn in. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, strokeColor?: number, strokeAlpha?: number); + + /** + * The width (or thickness) of the line. + * See the setLineWidth method for extra details on changing this on WebGL. + */ + lineWidth: number; + + /** + * Sets the width of the line. + * + * When using the WebGL renderer you can have different start and end widths. + * When using the Canvas renderer only the `startWidth` value is used. The `endWidth` is ignored. + * + * This call can be chained. + * @param startWidth The start width of the line. + * @param endWidth The end width of the line. Only used in WebGL. + */ + setLineWidth(startWidth: number, endWidth?: number): this; + + /** + * Sets the start and end coordinates of this Line. + * @param x1 The horizontal position of the start of the line. Default 0. + * @param y1 The vertical position of the start of the line. Default 0. + * @param x2 The horizontal position of the end of the line. Default 0. + * @param y2 The vertical position of the end of the line. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Polygon Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Polygon Shape is created by providing a list of points, which are then used to create an + * internal Polygon geometry object. The points can be set from a variety of formats: + * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point or Vector2 objects: `[new Phaser.Math.Vec2(x1, y1), ...]` + * - An array of objects with public x/y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` + * + * By default the `x` and `y` coordinates of this Shape refer to the center of it. However, depending + * on the coordinates of the points provided, the final shape may be rendered offset from its origin. + */ + class Polygon extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The points that make up the polygon. + * @param fillColor The color the polygon will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the polygon will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, points?: any, fillColor?: number, fillAlpha?: number); + + /** + * Smooths the polygon over the number of iterations specified. + * The base polygon data will be updated and replaced with the smoothed values. + * This call can be chained. + * @param iterations The number of times to apply the polygon smoothing. Default 1. + */ + smooth(iterations?: integer): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Rectangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * You can change the size of the rectangle by changing the `width` and `height` properties. + */ + class Rectangle extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. + * @param y The vertical position of this Game Object in the world. + * @param width The width of the rectangle. Default 128. + * @param height The height of the rectangle. Default 128. + * @param fillColor The color the rectangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the rectangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x: number, y: number, width?: number, height?: number, fillColor?: number, fillAlpha?: number); + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Shape Game Object is a base class for the various different shapes, such as the Arc, Star or Polygon. + * You cannot add a Shape directly to your Scene, it is meant as a base for your own custom Shape classes. + */ + class Shape extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param type The internal type of the Shape. + * @param data The data of the source shape geometry, if any. + */ + constructor(scene: Phaser.Scene, type?: string, data?: any); + + /** + * The source Shape data. Typically a geometry object. + * You should not manipulate this directly. + */ + readonly data: any; + + /** + * Holds the polygon path data for filled rendering. + */ + readonly pathData: number[]; + + /** + * Holds the earcut polygon path index data for filled rendering. + */ + readonly pathIndexes: integer[]; + + /** + * The fill color used by this Shape. + */ + fillColor: number; + + /** + * The fill alpha value used by this Shape. + */ + fillAlpha: number; + + /** + * The stroke color used by this Shape. + */ + strokeColor: number; + + /** + * The stroke alpha value used by this Shape. + */ + strokeAlpha: number; + + /** + * The stroke line width used by this Shape. + */ + lineWidth: number; + + /** + * Controls if this Shape is filled or not. + * Note that some Shapes do not support being filled (such as Line shapes) + */ + isFilled: boolean; + + /** + * Controls if this Shape is stroked or not. + * Note that some Shapes do not support being stroked (such as Iso Box shapes) + */ + isStroked: boolean; + + /** + * Controls if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + */ + closePath: boolean; + + /** + * Sets the fill color and alpha for this Shape. + * + * If you wish for the Shape to not be filled then call this method with no arguments, or just set `isFilled` to `false`. + * + * Note that some Shapes do not support fill colors, such as the Line shape. + * + * This call can be chained. + * @param color The color used to fill this shape. If not provided the Shape will not be filled. + * @param alpha The alpha value used when filling this shape, if a fill color is given. Default 1. + */ + setFillStyle(color?: number, alpha?: number): this; + + /** + * Sets the stroke color and alpha for this Shape. + * + * If you wish for the Shape to not be stroked then call this method with no arguments, or just set `isStroked` to `false`. + * + * Note that some Shapes do not support being stroked, such as the Iso Box shape. + * + * This call can be chained. + * @param lineWidth The width of line to stroke with. If not provided or undefined the Shape will not be stroked. + * @param color The color used to stroke this shape. If not provided the Shape will not be stroked. + * @param alpha The alpha value used when stroking this shape, if a stroke color is given. Default 1. + */ + setStrokeStyle(lineWidth?: number, color?: number, alpha?: number): this; + + /** + * Sets if this Shape path is closed during rendering when stroked. + * Note that some Shapes are always closed when stroked (such as Ellipse shapes) + * + * This call can be chained. + * @param value Set to `true` if the Shape should be closed when stroked, otherwise `false`. + */ + setClosePath(value: boolean): this; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Star Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * As the name implies, the Star shape will display a star in your game. You can control several + * aspects of it including the number of points that constitute the star. The default is 5. If + * you change it to 4 it will render as a diamond. If you increase them, you'll get a more spiky + * star shape. + * + * You can also control the inner and outer radius, which is how 'long' each point of the star is. + * Modify these values to create more interesting shapes. + */ + class Star extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param points The number of points on the star. Default 5. + * @param innerRadius The inner radius of the star. Default 32. + * @param outerRadius The outer radius of the star. Default 64. + * @param fillColor The color the star will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the star will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, points?: number, innerRadius?: number, outerRadius?: number, fillColor?: number, fillAlpha?: number); + + /** + * Sets the number of points that make up the Star shape. + * This call can be chained. + * @param value The amount of points the Star will have. + */ + setPoints(value: integer): this; + + /** + * Sets the inner radius of the Star shape. + * This call can be chained. + * @param value The amount to set the inner radius to. + */ + setInnerRadius(value: number): this; + + /** + * Sets the outer radius of the Star shape. + * This call can be chained. + * @param value The amount to set the outer radius to. + */ + setOuterRadius(value: number): this; + + /** + * The number of points that make up the Star shape. + */ + points: integer; + + /** + * The inner radius of the Star shape. + */ + innerRadius: number; + + /** + * The outer radius of the Star shape. + */ + outerRadius: number; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * The visible state of the Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + */ + visible: boolean; + + /** + * Sets the visibility of this Game Object. + * + * An invisible Game Object will skip rendering, but will still process update logic. + * @param value The visible state of the Game Object. + */ + setVisible(value: boolean): this; + + } + + /** + * The Triangle Shape is a Game Object that can be added to a Scene, Group or Container. You can + * treat it like any other Game Object in your game, such as tweening it, scaling it, or enabling + * it for input or physics. It provides a quick and easy way for you to render this shape in your + * game without using a texture, while still taking advantage of being fully batched in WebGL. + * + * This shape supports both fill and stroke colors. + * + * The Triangle consists of 3 lines, joining up to form a triangular shape. You can control the + * position of each point of these lines. The triangle is always closed and cannot have an open + * face. If you require that, consider using a Polygon instead. + */ + class Triangle extends Phaser.GameObjects.Shape { + /** + * + * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. + * @param x The horizontal position of this Game Object in the world. Default 0. + * @param y The vertical position of this Game Object in the world. Default 0. + * @param x1 The horizontal position of the first point in the triangle. Default 0. + * @param y1 The vertical position of the first point in the triangle. Default 128. + * @param x2 The horizontal position of the second point in the triangle. Default 64. + * @param y2 The vertical position of the second point in the triangle. Default 0. + * @param x3 The horizontal position of the third point in the triangle. Default 128. + * @param y3 The vertical position of the third point in the triangle. Default 128. + * @param fillColor The color the triangle will be filled with, i.e. 0xff0000 for red. + * @param fillAlpha The alpha the triangle will be filled with. You can also set the alpha of the overall Shape using its `alpha` property. + */ + constructor(scene: Phaser.Scene, x?: number, y?: number, x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number, fillColor?: number, fillAlpha?: number); + + /** + * Sets the data for the lines that make up this Triangle shape. + * @param x1 The horizontal position of the first point in the triangle. Default 0. + * @param y1 The vertical position of the first point in the triangle. Default 0. + * @param x2 The horizontal position of the second point in the triangle. Default 0. + * @param y2 The vertical position of the second point in the triangle. Default 0. + * @param x3 The horizontal position of the third point in the triangle. Default 0. + * @param y3 The vertical position of the third point in the triangle. Default 0. + */ + setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): this; + + /** + * Clears all alpha values associated with this Game Object. + * + * Immediately sets the alpha levels back to 1 (fully opaque). + */ + clearAlpha(): this; + + /** + * Set the Alpha level of this Game Object. The alpha controls the opacity of the Game Object as it renders. + * Alpha values are provided as a float between 0, fully transparent, and 1, fully opaque. + * + * If your game is running under WebGL you can optionally specify four different alpha values, each of which + * correspond to the four corners of the Game Object. Under Canvas only the `topLeft` value given is used. + * @param topLeft The alpha value used for the top-left of the Game Object. If this is the only value given it's applied across the whole Game Object. Default 1. + * @param topRight The alpha value used for the top-right of the Game Object. WebGL only. + * @param bottomLeft The alpha value used for the bottom-left of the Game Object. WebGL only. + * @param bottomRight The alpha value used for the bottom-right of the Game Object. WebGL only. + */ + setAlpha(topLeft?: number, topRight?: number, bottomLeft?: number, bottomRight?: number): this; + + /** + * The alpha value of the Game Object. + * + * This is a global value, impacting the entire Game Object, not just a region of it. + */ + alpha: number; + + /** + * The alpha value starting from the top-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopLeft: number; + + /** + * The alpha value starting from the top-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaTopRight: number; + + /** + * The alpha value starting from the bottom-left of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomLeft: number; + + /** + * The alpha value starting from the bottom-right of the Game Object. + * This value is interpolated from the corner to the center of the Game Object. + */ + alphaBottomRight: number; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * are used. + */ + blendMode: Phaser.BlendModes | string; + + /** + * Sets the Blend Mode being used by this Game Object. + * + * This can be a const, such as `Phaser.BlendModes.SCREEN`, or an integer, such as 4 (for Overlay) + * + * Under WebGL only the following Blend Modes are available: + * + * * ADD + * * MULTIPLY + * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) + * + * Canvas has more available depending on browser support. + * + * You can also create your own custom Blend Modes in WebGL. + * + * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending + * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes + * are used. + * @param value The BlendMode value. Either a string or a CONST. + */ + setBlendMode(value: string | Phaser.BlendModes): this; + + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + */ + depth: number; + + /** + * The depth of this Game Object within the Scene. + * + * The depth is also known as the 'z-index' in some environments, and allows you to change the rendering order + * of Game Objects, without actually moving their position in the display list. + * + * The depth starts from zero (the default value) and increases from that point. A Game Object with a higher depth + * value will always render in front of one with a lower value. + * + * Setting the depth will queue a depth sort event within the Scene. + * @param value The depth of this Game Object. + */ + setDepth(value: integer): this; + + /** + * Gets the center coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + */ + getCenter(output?: O): O; + + /** + * Gets the top-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the top-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getTopRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-left corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomLeft(output?: O, includeParent?: boolean): O; + + /** + * Gets the bottom-right corner coordinate of this Game Object, regardless of origin. + * The returned point is calculated in local space and does not factor in any parent containers + * @param output An object to store the values in. If not provided a new Vector2 will be created. + * @param includeParent If this Game Object has a parent Container, include it (and all other ancestors) in the resulting vector? Default false. + */ + getBottomRight(output?: O, includeParent?: boolean): O; + + /** + * Gets the bounds of this Game Object, regardless of origin. + * The values are stored and returned in a Rectangle, or Rectangle-like, object. + * @param output An object to store the values in. If not provided a new Rectangle will be created. + */ + getBounds(output?: O): O; + + /** + * The Mask this Game Object is using during render. + */ + mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask; + + /** + * Sets the mask that this Game Object will use to render with. + * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. + * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. + * + * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. + * @param mask The mask this Game Object will use when rendering. + */ + setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; + + /** + * Clears the mask that this Game Object was using. + * @param destroyMask Destroy the mask before clearing it? Default false. + */ + clearMask(destroyMask?: boolean): this; + + /** + * Creates and returns a Bitmap Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a renderable Game Object. + * A renderable Game Object is one that uses a texture to render with, such as an + * Image, Sprite, Render Texture or BitmapText. + * + * If you do not provide a renderable object, and this Game Object has a texture, + * it will use itself as the object. This means you can call this method to create + * a Bitmap Mask from any renderable Game Object. + * @param renderable A renderable Game Object that uses a texture, such as a Sprite. + */ + createBitmapMask(renderable?: Phaser.GameObjects.GameObject): Phaser.Display.Masks.BitmapMask; + + /** + * Creates and returns a Geometry Mask. This mask can be used by any Game Object, + * including this one. + * + * To create the mask you need to pass in a reference to a Graphics Game Object. + * + * If you do not provide a graphics object, and this Game Object is an instance + * of a Graphics object, then it will use itself to create the mask. + * + * This means you can call this method to create a Geometry Mask from any Graphics Game Object. + * @param graphics A Graphics Game Object. The geometry within it will be used as the mask. + */ + createGeometryMask(graphics?: Phaser.GameObjects.Graphics): Phaser.Display.Masks.GeometryMask; + + /** + * The horizontal origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the left of the Game Object. + */ + originX: number; + + /** + * The vertical origin of this Game Object. + * The origin maps the relationship between the size and position of the Game Object. + * The default value is 0.5, meaning all Game Objects are positioned based on their center. + * Setting the value to 0 means the position now relates to the top of the Game Object. + */ + originY: number; + + /** + * The horizontal display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginX: number; + + /** + * The vertical display origin of this Game Object. + * The origin is a normalized value between 0 and 1. + * The displayOrigin is a pixel value, based on the size of the Game Object combined with the origin. + */ + displayOriginY: number; + + /** + * Sets the origin of this Game Object. + * + * The values are given in the range 0 to 1. + * @param x The horizontal origin value. Default 0.5. + * @param y The vertical origin value. If not defined it will be set to the value of `x`. Default x. + */ + setOrigin(x?: number, y?: number): this; + + /** + * Sets the origin of this Game Object based on the Pivot values in its Frame. + */ + setOriginFromFrame(): this; + + /** + * Sets the display origin of this Game Object. + * The difference between this and setting the origin is that you can use pixel values for setting the display origin. + * @param x The horizontal display origin value. Default 0. + * @param y The vertical display origin value. If not defined it will be set to the value of `x`. Default x. + */ + setDisplayOrigin(x?: number, y?: number): this; + + /** + * Updates the Display Origin cached values internally stored on this Game Object. + * You don't usually call this directly, but it is exposed for edge-cases where you may. + */ + updateDisplayOrigin(): this; + + /** + * The initial WebGL pipeline of this Game Object. + */ + defaultPipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * The current WebGL pipeline of this Game Object. + */ + pipeline: Phaser.Renderer.WebGL.WebGLPipeline; + + /** + * Sets the initial WebGL Pipeline of this Game Object. + * This should only be called during the instantiation of the Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. + */ + initPipeline(pipelineName?: string): boolean; + + /** + * Sets the active WebGL Pipeline of this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. + */ + setPipeline(pipelineName: string): this; + + /** + * Resets the WebGL Pipeline of this Game Object back to the default it was created with. + */ + resetPipeline(): boolean; + + /** + * Gets the name of the WebGL Pipeline this Game Object is currently using. + */ + getPipelineName(): string; + + /** + * The Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + */ + scaleMode: Phaser.ScaleModes; + + /** + * Sets the Scale Mode being used by this Game Object. + * Can be either `ScaleModes.LINEAR` or `ScaleModes.NEAREST`. + * @param value The Scale Mode to be used by this Game Object. + */ + setScaleMode(value: Phaser.ScaleModes): this; + + /** + * The horizontal scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorX: number; + + /** + * The vertical scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + */ + scrollFactorY: number; + + /** + * Sets the scroll factor of this Game Object. + * + * The scroll factor controls the influence of the movement of a Camera upon this Game Object. + * + * When a camera scrolls it will change the location at which this Game Object is rendered on-screen. + * It does not change the Game Objects actual position values. + * + * A value of 1 means it will move exactly in sync with a camera. + * A value of 0 means it will not move at all, even if the camera moves. + * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. + * @param x The horizontal scroll factor of this Game Object. + * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. + */ + setScrollFactor(x: number, y?: number): this; + + /** + * The x position of this Game Object. + */ + x: number; + + /** + * The y position of this Game Object. + */ + y: number; + + /** + * The z position of this Game Object. + * Note: Do not use this value to set the z-index, instead see the `depth` property. + */ + z: number; + + /** + * The w position of this Game Object. + */ + w: number; + + /** + * The horizontal scale of this Game Object. + */ + scaleX: number; + + /** + * The vertical scale of this Game Object. + */ + scaleY: number; + + /** + * The angle of this Game Object as expressed in degrees. + * + * Where 0 is to the right, 90 is down, 180 is left. + * + * If you prefer to work in radians, see the `rotation` property instead. + */ + angle: integer; + + /** + * The angle of this Game Object in radians. + * + * If you prefer to work in degrees, see the `angle` property instead. + */ + rotation: number; + + /** + * Sets the position of this Game Object. + * @param x The x position of this Game Object. Default 0. + * @param y The y position of this Game Object. If not set it will use the `x` value. Default x. + * @param z The z position of this Game Object. Default 0. + * @param w The w position of this Game Object. Default 0. + */ + setPosition(x?: number, y?: number, z?: number, w?: number): this; + + /** + * Sets the position of this Game Object to be a random position within the confines of + * the given area. + * + * If no area is specified a random position between 0 x 0 and the game width x height is used instead. + * + * The position does not factor in the size of this Game Object, meaning that only the origin is + * guaranteed to be within the area. + * @param x The x position of the top-left of the random area. Default 0. + * @param y The y position of the top-left of the random area. Default 0. + * @param width The width of the random area. + * @param height The height of the random area. + */ + setRandomPosition(x?: number, y?: number, width?: number, height?: number): this; + + /** + * Sets the rotation of this Game Object. + * @param radians The rotation of this Game Object, in radians. Default 0. + */ + setRotation(radians?: number): this; + + /** + * Sets the angle of this Game Object. + * @param degrees The rotation of this Game Object, in degrees. Default 0. + */ + setAngle(degrees?: number): this; + + /** + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. + * @param y The vertical scale of this Game Object. If not set it will use the `x` value. Default x. + */ + setScale(x: number, y?: number): this; + + /** + * Sets the x position of this Game Object. + * @param value The x position of this Game Object. Default 0. + */ + setX(value?: number): this; + + /** + * Sets the y position of this Game Object. + * @param value The y position of this Game Object. Default 0. + */ + setY(value?: number): this; + + /** + * Sets the z position of this Game Object. + * @param value The z position of this Game Object. Default 0. + */ + setZ(value?: number): this; + + /** + * Sets the w position of this Game Object. + * @param value The w position of this Game Object. Default 0. + */ + setW(value?: number): this; + + /** + * Gets the local transform matrix for this Game Object. + * @param tempMatrix The matrix to populate with the values from this Game Object. + */ + getLocalTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + + /** + * Gets the world transform matrix for this Game Object, factoring in any parent Containers. + * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. + */ + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -20570,7 +32211,7 @@ declare namespace Phaser { * 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 Sprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Sprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.TextureCrop, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. @@ -20667,6 +32308,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -20689,6 +32331,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -20696,7 +32339,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -20831,12 +32474,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -20947,15 +32594,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -20991,6 +32638,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -21005,6 +32657,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -21019,6 +32676,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -21026,34 +32688,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -21061,6 +32753,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -21077,6 +32770,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -21101,21 +32830,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -21145,6 +32917,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -21268,8 +33045,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -21289,93 +33067,45 @@ declare namespace Phaser { } /** - * A Sprite 3D Game Object. + * A Text Game Object. * - * The Sprite 3D object is an encapsulation of a standard Sprite object, with additional methods to allow - * it to be rendered by a 3D Camera. The Sprite can be positioned anywhere within 3D space. + * Text objects work by creating their own internal hidden Canvas and then renders text to it using + * the standard Canvas `fillText` API. It then creates a texture from this canvas which is rendered + * to your game during the render pass. + * + * Because it uses the Canvas API you can take advantage of all the features this offers, such as + * applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts + * loaded externally, such as Google or TypeKit Web fonts. + * + * **Important:** If the font you wish to use has a space or digit in its name, such as + * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes, either + * when creating the Text object, or when setting the font via `setFont` or `setFontFamily`. I.e.: + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { fontFamily: '"Roboto Condensed"' }); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * this.add.text(0, 0, 'Hello World', { fontFamily: 'Verdana, "Times New Roman", Tahoma, serif' }); + * ``` + * + * You can only display fonts that are currently loaded and available to the browser: therefore fonts must + * be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader, + * or have the fonts ready available in the CSS on the page in which your Phaser game resides. + * + * See {@link http://www.jordanm.co.uk/tinytype this compatibility table} for the available default fonts + * across mobile browsers. + * + * A note on performance: Every time the contents of a Text object changes, i.e. changing the text being + * displayed, or the style of the text, it needs to remake the Text canvas, and if on WebGL, re-upload the + * new texture to the GPU. This can be an expensive operation if used often, or with large quantities of + * Text objects in your game. If you run into performance issues you would be better off using Bitmap Text + * instead, as it benefits from batching and avoids expensive Canvas API calls. */ - class Sprite3D extends Phaser.GameObjects.GameObject { - /** - * - * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. - * @param x The x position of this Game Object. - * @param y The y position of this Game Object. - * @param z The z position of this Game Object. - * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. - */ - constructor(scene: Phaser.Scene, x: number, y: number, z: number, texture: string, frame?: string | integer); - - /** - * [description] - */ - gameObject: Phaser.GameObjects.GameObject; - - /** - * [description] - */ - position: Phaser.Math.Vector4; - - /** - * [description] - */ - size: Phaser.Math.Vector2; - - /** - * [description] - */ - scale: Phaser.Math.Vector2; - - /** - * [description] - */ - adjustScaleX: boolean; - - /** - * [description] - */ - adjustScaleY: boolean; - - /** - * [description] - * @param camera The 3D Camera onto which to project this Sprite. - */ - project(camera: Phaser.Cameras.Sprite3D.Camera): void; - - /** - * [description] - * @param value [description] - */ - setVisible(value: boolean): Phaser.GameObjects.Sprite3D; - - /** - * The visible state of the Game Object. - * - * An invisible Game Object will skip rendering, but will still process update logic. - */ - visible: boolean; - - /** - * The x position of this Game Object. - */ - x: number; - - /** - * The y position of this Game Object. - */ - y: number; - - /** - * The z position of this Game Object. - */ - z: number; - - } - - /** - * [description] - */ - class Text extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class Text extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. @@ -21388,17 +33118,22 @@ declare namespace Phaser { /** * Returns an object containing dimensions of the Text object. - * @param text The Text object to get the size from. - * @param size [description] - * @param lines [description] + * @param text The Text object to calculate the size from. + * @param size The Text metrics to use when calculating the size. + * @param lines The lines of text to calculate the size from. */ - static GetTextSize(text: Phaser.GameObjects.Text, size: number, lines: any[]): object; + static GetTextSize(text: Phaser.GameObjects.Text, size: BitmapTextMetrics, lines: any[]): object; /** * Calculates the ascent, descent and fontSize of a given font style. * @param textStyle The TextStyle object to measure. */ - static MeasureText(textStyle: Phaser.GameObjects.Text.TextStyle): object; + static MeasureText(textStyle: Phaser.GameObjects.TextStyle): object; + + /** + * The renderer in use by this Text object. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; /** * The canvas element that the text is rendered to. @@ -21411,12 +33146,14 @@ declare namespace Phaser { context: CanvasRenderingContext2D; /** - * [description] + * The Text Style object. + * + * Manages the style of this Text object. */ - style: Phaser.GameObjects.Text.TextStyle; + style: Phaser.GameObjects.TextStyle; /** - * [description] + * Whether to automatically round line positions. */ autoRound: boolean; @@ -21427,16 +33164,6 @@ declare namespace Phaser { */ splitRegExp: object; - /** - * [description] - */ - text: string; - - /** - * [description] - */ - resolution: number; - /** * Specify a padding value which is added to the line width and height when calculating the Text size. * Allows you to add extra spacing if the browser is unable to accurately determine the true font dimensions. @@ -21444,27 +33171,32 @@ declare namespace Phaser { padding: Object; /** - * [description] + * The width of this Text object. */ width: number; /** - * [description] + * The height of this Text object. */ height: number; /** - * [description] + * The line spacing value. + * This value is added to the font height to calculate the overall line height. + * Only has an effect if this Text object contains multiple lines of text. + * + * If you update this property directly, instead of using the `setLineSpacing` method, then + * be sure to call `updateText` after, or you won't see the change reflected in the Text object. */ - canvasTexture: HTMLCanvasElement; + lineSpacing: number; /** - * [description] + * Whether the text or its settings have changed and need updating. */ dirty: boolean; /** - * [description] + * Initialize right to left text. */ initRTL(): void; @@ -21481,8 +33213,8 @@ declare namespace Phaser { * trimmed of white space before processing. Throws an error if wordWrapWidth is less than a * single character. * @param text The text to perform word wrap detection against. - * @param context [description] - * @param wordWrapWidth [description] + * @param context The Canvas Rendering Context. + * @param wordWrapWidth The word wrap width. */ advancedWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; @@ -21490,8 +33222,8 @@ declare namespace Phaser { * Greedy wrapping algorithm that will wrap words as the line grows longer than its horizontal * bounds. Spaces are not collapsed and whitespace is not trimmed. * @param text The text to perform word wrap detection against. - * @param context [description] - * @param wordWrapWidth [description] + * @param context The Canvas Rendering Context. + * @param wordWrapWidth The word wrap width. */ basicWordWrap(text: string, context: CanvasRenderingContext2D, wordWrapWidth: number): string; @@ -21503,112 +33235,154 @@ declare namespace Phaser { getWrappedText(text: string): string[]; /** - * [description] + * Set the text to display. + * + * An array of strings will be joined with `\n` line breaks. * @param value The string, or array of strings, to be set as the content of this Text object. */ setText(value: string | string[]): Phaser.GameObjects.Text; /** - * [description] - * @param style [description] + * Set the text style. + * @param style The style settings to set. */ setStyle(style: object): Phaser.GameObjects.Text; /** - * [description] - * @param font [description] + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * + * **Important:** If the font you wish to use has a space or digit in its name, such as + * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes: + * + * ```javascript + * Text.setFont('"Roboto Condensed"'); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * Text.setFont('Verdana, "Times New Roman", Tahoma, serif'); + * ``` + * @param font The font family or font settings to set. */ setFont(font: string): Phaser.GameObjects.Text; /** - * [description] - * @param family [description] + * Set the font family. + * + * **Important:** If the font you wish to use has a space or digit in its name, such as + * 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes: + * + * ```javascript + * Text.setFont('"Roboto Condensed"'); + * ``` + * + * Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all + * quoted properly, too: + * + * ```javascript + * Text.setFont('Verdana, "Times New Roman", Tahoma, serif'); + * ``` + * @param family The font family. */ setFontFamily(family: string): Phaser.GameObjects.Text; /** - * [description] - * @param size [description] + * Set the font size. + * @param size The font size. */ setFontSize(size: number): Phaser.GameObjects.Text; /** - * [description] - * @param style [description] + * Set the font style. + * @param style The font style. */ setFontStyle(style: string): Phaser.GameObjects.Text; /** - * [description] - * @param width [description] - * @param height [description] + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * @param width The fixed width to set. `0` disables fixed width. + * @param height The fixed height to set. `0` disables fixed height. */ setFixedSize(width: number, height: number): Phaser.GameObjects.Text; /** - * [description] - * @param color [description] + * Set the background color. + * @param color The background color. */ setBackgroundColor(color: string): Phaser.GameObjects.Text; /** - * [description] - * @param color [description] + * Set the fill style to be used by the Text object. + * + * This can be any valid CanvasRenderingContext2D fillStyle value, such as + * a color (in hex, rgb, rgba, hsl or named values), a gradient or a pattern. + * + * See the [MDN fillStyle docs](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillStyle) for more details. + * @param color The text fill style. Can be any valid CanvasRenderingContext `fillStyle` value. */ - setFill(color: string): Phaser.GameObjects.Text; + setFill(color: string | any): Phaser.GameObjects.Text; /** - * [description] - * @param color [description] + * Set the text fill color. + * @param color The text fill color. */ setColor(color: string): Phaser.GameObjects.Text; /** - * [description] - * @param color [description] - * @param thickness [description] + * Set the stroke settings. + * @param color The stroke color. + * @param thickness The stroke thickness. */ setStroke(color: string, thickness: number): Phaser.GameObjects.Text; /** - * [description] - * @param x [description] - * @param y [description] - * @param color [description] - * @param blur [description] - * @param shadowStroke [description] - * @param shadowFill [description] + * Set the shadow settings. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + * @param color The shadow color. Default '#000'. + * @param blur The shadow blur radius. Default 0. + * @param shadowStroke Whether to stroke the shadow. Default false. + * @param shadowFill Whether to fill the shadow. Default true. */ - setShadow(x: number, y: number, color: string, blur: number, shadowStroke: boolean, shadowFill: boolean): Phaser.GameObjects.Text; + setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; /** - * [description] - * @param x [description] - * @param y [description] + * Set the shadow offset. + * @param x The horizontal shadow offset. + * @param y The vertical shadow offset. */ setShadowOffset(x: number, y: number): Phaser.GameObjects.Text; /** - * [description] - * @param color [description] + * Set the shadow color. + * @param color The shadow color. */ setShadowColor(color: string): Phaser.GameObjects.Text; /** - * [description] - * @param blur [description] + * Set the shadow blur radius. + * @param blur The shadow blur radius. */ setShadowBlur(blur: number): Phaser.GameObjects.Text; /** - * [description] - * @param enabled [description] + * Enable or disable shadow stroke. + * @param enabled Whether shadow stroke is enabled or not. */ setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; /** - * [description] - * @param enabled [description] + * Enable or disable shadow fill. + * @param enabled Whether shadow fill is enabled or not. */ setShadowFill(enabled: boolean): Phaser.GameObjects.Text; @@ -21632,39 +33406,72 @@ declare namespace Phaser { setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; /** - * [description] - * @param align [description] + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * @param align The text alignment. */ setAlign(align: string): Phaser.GameObjects.Text; /** + * Set the resolution used by this Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method, or by specifying it in the Text style configuration object. + * + * It allows for much clearer text on High DPI devices, at the cost of memory because it uses larger + * internal Canvas textures for the Text. + * + * Therefore, please use with caution, as the more high res Text you have, the more memory it uses. + * @param value The resolution for this Text object to use. + */ + setResolution(value: number): Phaser.GameObjects.Text; + + /** + * Sets the line spacing value. + * + * This value is _added_ to the height of the font when calculating the overall line height. + * This only has an effect if this Text object consists of multiple lines of text. + * @param value The amount to add to the font height to achieve the overall line height. + */ + setLineSpacing(value: number): Phaser.GameObjects.Text; + + /** + * Set the text padding. + * * 'left' can be an object. - * If only 'left' and 'top' are given they are treated as 'x' and 'y' - * @param left [description] - * @param top [description] - * @param right [description] - * @param bottom [description] + * + * If only 'left' and 'top' are given they are treated as 'x' and 'y'. + * @param left The left padding value, or a padding config object. + * @param top The top padding value. + * @param right The right padding value. + * @param bottom The bottom padding value. */ setPadding(left: number | object, top: number, right: number, bottom: number): Phaser.GameObjects.Text; /** - * [description] - * @param max [description] Default 0. + * Set the maximum number of lines to draw. + * @param max The maximum number of lines to draw. Default 0. */ setMaxLines(max?: integer): Phaser.GameObjects.Text; /** - * [description] + * Update the displayed text. */ updateText(): Phaser.GameObjects.Text; /** - * [description] + * Get the current text metrics. */ getTextMetrics(): object; /** - * [description] + * The text string being rendered by this Text Game Object. + */ + text: string; + + /** + * Build a JSON representation of the Text object. */ toJSON(): JSONGameObject; @@ -21734,6 +33541,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -21756,6 +33564,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -21763,7 +33572,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -21771,18 +33580,32 @@ declare namespace Phaser { /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -21790,12 +33613,59 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. */ setDisplaySize(width: number, height: number): this; + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * The depth of this Game Object within the Scene. * @@ -21925,12 +33795,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -22041,15 +33915,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -22085,6 +33959,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -22099,6 +33978,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -22113,26 +33997,74 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ setScrollFactor(x: number, y?: number): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -22162,6 +34094,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -22285,8 +34222,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -22306,20 +34244,489 @@ declare namespace Phaser { } /** - * [description] + * A TextStyle class manages all of the style settings for a Text object. + * + * Text Game Objects create a TextStyle instance automatically, which is + * accessed via the `Text.style` property. You do not normally need to + * instantiate one yourself. */ - class TileSprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { + class TextStyle { + /** + * + * @param text The Text object that this TextStyle is styling. + * @param style The style settings to set. + */ + constructor(text: Phaser.GameObjects.Text, style: object); + + /** + * The Text object that this TextStyle is styling. + */ + parent: Phaser.GameObjects.Text; + + /** + * The font family. + */ + fontFamily: string; + + /** + * The font size. + */ + fontSize: string; + + /** + * The font style. + */ + fontStyle: string; + + /** + * The background color. + */ + backgroundColor: string; + + /** + * The text fill color. + */ + color: string; + + /** + * The text stroke color. + */ + stroke: string; + + /** + * The text stroke thickness. + */ + strokeThickness: number; + + /** + * The horizontal shadow offset. + */ + shadowOffsetX: number; + + /** + * The vertical shadow offset. + */ + shadowOffsetY: number; + + /** + * The shadow color. + */ + shadowColor: string; + + /** + * The shadow blur radius. + */ + shadowBlur: number; + + /** + * Whether shadow stroke is enabled or not. + */ + shadowStroke: boolean; + + /** + * Whether shadow fill is enabled or not. + */ + shadowFill: boolean; + + /** + * The text alignment. + */ + align: string; + + /** + * The maximum number of lines to draw. + */ + maxLines: integer; + + /** + * The fixed width of the text. + * + * `0` means no fixed with. + */ + fixedWidth: number; + + /** + * The fixed height of the text. + * + * `0` means no fixed height. + */ + fixedHeight: number; + + /** + * The resolution the text is rendered to its internal canvas at. + * The default is 0, which means it will use the resolution set in the Game Config. + */ + resolution: number; + + /** + * Whether the text should render right to left. + */ + rtl: boolean; + + /** + * The test string to use when measuring the font. + */ + testString: string; + + /** + * The amount of horizontal padding adding to the width of the text when calculating the font metrics. + */ + baselineX: number; + + /** + * The amount of vertical padding adding to the width of the text when calculating the font metrics. + */ + baselineY: number; + + /** + * Set the text style. + * @param style The style settings to set. + * @param updateText Whether to update the text immediately. Default true. + * @param setDefaults Use the default values is not set, or the local values. Default false. + */ + setStyle(style: object, updateText?: boolean, setDefaults?: boolean): Phaser.GameObjects.Text; + + /** + * Synchronize the font settings to the given Canvas Rendering Context. + * @param canvas The Canvas Element. + * @param context The Canvas Rendering Context. + */ + syncFont(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; + + /** + * Synchronize the text style settings to the given Canvas Rendering Context. + * @param canvas The Canvas Element. + * @param context The Canvas Rendering Context. + */ + syncStyle(canvas: HTMLCanvasElement, context: CanvasRenderingContext2D): void; + + /** + * Synchronize the shadow settings to the given Canvas Rendering Context. + * @param context The Canvas Rendering Context. + * @param enabled Whether shadows are enabled or not. + */ + syncShadow(context: CanvasRenderingContext2D, enabled: boolean): void; + + /** + * Update the style settings for the parent Text object. + * @param recalculateMetrics Whether to recalculate font and text metrics. + */ + update(recalculateMetrics: boolean): Phaser.GameObjects.Text; + + /** + * Set the font. + * + * If a string is given, the font family is set. + * + * If an object is given, the `fontFamily`, `fontSize` and `fontStyle` + * properties of that object are set. + * @param font The font family or font settings to set. + * @param updateText Whether to update the text immediately. Default true. + */ + setFont(font: string | object, updateText?: boolean): Phaser.GameObjects.Text; + + /** + * Set the font family. + * @param family The font family. + */ + setFontFamily(family: string): Phaser.GameObjects.Text; + + /** + * Set the font style. + * @param style The font style. + */ + setFontStyle(style: string): Phaser.GameObjects.Text; + + /** + * Set the font size. + * @param size The font size. + */ + setFontSize(size: number | string): Phaser.GameObjects.Text; + + /** + * Set the test string to use when measuring the font. + * @param string The test string to use when measuring the font. + */ + setTestString(string: string): Phaser.GameObjects.Text; + + /** + * Set a fixed width and height for the text. + * + * Pass in `0` for either of these parameters to disable fixed width or height respectively. + * @param width The fixed width to set. + * @param height The fixed height to set. + */ + setFixedSize(width: number, height: number): Phaser.GameObjects.Text; + + /** + * Set the background color. + * @param color The background color. + */ + setBackgroundColor(color: string): Phaser.GameObjects.Text; + + /** + * Set the text fill color. + * @param color The text fill color. + */ + setFill(color: string): Phaser.GameObjects.Text; + + /** + * Set the text fill color. + * @param color The text fill color. + */ + setColor(color: string): Phaser.GameObjects.Text; + + /** + * Set the resolution used by the Text object. + * + * By default it will be set to match the resolution set in the Game Config, + * but you can override it via this method. It allows for much clearer text on High DPI devices, + * at the cost of memory because it uses larger internal Canvas textures for the Text. + * + * Please use with caution, as the more high res Text you have, the more memory it uses up. + * @param value The resolution for this Text object to use. + */ + setResolution(value: number): Phaser.GameObjects.Text; + + /** + * Set the stroke settings. + * @param color The stroke color. + * @param thickness The stroke thickness. + */ + setStroke(color: string, thickness: number): Phaser.GameObjects.Text; + + /** + * Set the shadow settings. + * + * Calling this method always re-measures the parent Text object, + * so only call it when you actually change the shadow settings. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + * @param color The shadow color. Default '#000'. + * @param blur The shadow blur radius. Default 0. + * @param shadowStroke Whether to stroke the shadow. Default false. + * @param shadowFill Whether to fill the shadow. Default true. + */ + setShadow(x?: number, y?: number, color?: string, blur?: number, shadowStroke?: boolean, shadowFill?: boolean): Phaser.GameObjects.Text; + + /** + * Set the shadow offset. + * @param x The horizontal shadow offset. Default 0. + * @param y The vertical shadow offset. Default 0. + */ + setShadowOffset(x?: number, y?: number): Phaser.GameObjects.Text; + + /** + * Set the shadow color. + * @param color The shadow color. Default '#000'. + */ + setShadowColor(color?: string): Phaser.GameObjects.Text; + + /** + * Set the shadow blur radius. + * @param blur The shadow blur radius. Default 0. + */ + setShadowBlur(blur?: number): Phaser.GameObjects.Text; + + /** + * Enable or disable shadow stroke. + * @param enabled Whether shadow stroke is enabled or not. + */ + setShadowStroke(enabled: boolean): Phaser.GameObjects.Text; + + /** + * Enable or disable shadow fill. + * @param enabled Whether shadow fill is enabled or not. + */ + setShadowFill(enabled: boolean): Phaser.GameObjects.Text; + + /** + * Set the width (in pixels) to use for wrapping lines. + * + * Pass in null to remove wrapping by width. + * @param width The maximum width of a line in pixels. Set to null to remove wrapping. + * @param useAdvancedWrap Whether or not to use the advanced wrapping + * algorithm. If true, spaces are collapsed and whitespace is trimmed from lines. If false, + * spaces and whitespace are left as is. Default false. + */ + setWordWrapWidth(width: number, useAdvancedWrap?: boolean): Phaser.GameObjects.Text; + + /** + * Set a custom callback for wrapping lines. + * + * Pass in null to remove wrapping by callback. + * @param callback A custom function that will be responsible for wrapping the + * text. It will receive two arguments: text (the string to wrap), textObject (this Text + * instance). It should return the wrapped lines either as an array of lines or as a string with + * newline characters in place to indicate where breaks should happen. + * @param scope The scope that will be applied when the callback is invoked. Default null. + */ + setWordWrapCallback(callback: TextStyleWordWrapCallback, scope?: object): Phaser.GameObjects.Text; + + /** + * Set the text alignment. + * + * Expects values like `'left'`, `'right'`, `'center'` or `'justified'`. + * @param align The text alignment. + */ + setAlign(align: string): Phaser.GameObjects.Text; + + /** + * Set the maximum number of lines to draw. + * @param max The maximum number of lines to draw. Default 0. + */ + setMaxLines(max?: integer): Phaser.GameObjects.Text; + + /** + * Get the current text metrics. + */ + getTextMetrics(): BitmapTextMetrics; + + /** + * Build a JSON representation of this Text Style. + */ + toJSON(): object; + + /** + * Destroy this Text Style. + */ + destroy(): void; + + } + + /** + * A TileSprite is a Sprite that has a repeating texture. + * + * The texture can be scrolled and scaled independently of the TileSprite itself. Textures will automatically wrap and + * are designed so that you can create game backdrops using seamless textures as a source. + * + * You shouldn't ever create a TileSprite any larger than your actual canvas size. If you want to create a large repeating background + * that scrolls across the whole map of your game, then you create a TileSprite that fits the canvas size and then use the `tilePosition` + * property to scroll the texture as the player moves. If you create a TileSprite that is thousands of pixels in size then it will + * consume huge amounts of memory and cause performance issues. Remember: use `tilePosition` to scroll your texture and `tileScale` to + * adjust the scale of the texture - don't resize the sprite itself or make it larger than it needs. + * + * An important note about Tile Sprites and NPOT textures: Internally, TileSprite textures use GL_REPEAT to provide + * seamless repeating of the textures. This, combined with the way in which the textures are handled in WebGL, means + * they need to be POT (power-of-two) sizes in order to wrap. If you provide a NPOT (non power-of-two) texture to a + * TileSprite it will generate a POT sized canvas and draw your texture to it, scaled up to the POT size. It's then + * scaled back down again during rendering to the original dimensions. While this works, in that it allows you to use + * any size texture for a Tile Sprite, it does mean that NPOT textures are going to appear anti-aliased when rendered, + * due to the interpolation that took place when it was resized into a POT texture. This is especially visible in + * pixel art graphics. If you notice it and it becomes an issue, the only way to avoid it is to ensure that you + * provide POT textures for Tile Sprites. + */ + class TileSprite extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Crop, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Mask, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * * @param scene The Scene to which this Game Object belongs. A Game Object can only belong to one Scene at a time. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. - * @param width The width of the Game Object. - * @param height The height of the Game Object. - * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. - * @param frame An optional frame from the Texture this Game Object is rendering with. + * @param width The width of the Game Object. If zero it will use the size of the texture frame. + * @param height The height of the Game Object. If zero it will use the size of the texture frame. + * @param textureKey The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. + * @param frameKey An optional frame from the Texture this Game Object is rendering with. */ - constructor(scene: Phaser.Scene, x: number, y: number, width: number, height: number, texture: string, frame?: string | integer); + constructor(scene: Phaser.Scene, x: number, y: number, width: integer, height: integer, textureKey: string, frameKey?: string | integer); + + /** + * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. + * + * Such changes include the texture frame and scroll position of the Tile Sprite. + */ + dirty: boolean; + + /** + * The renderer in use by this Tile Sprite. + */ + renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; + + /** + * The Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + */ + canvas: HTMLCanvasElement; + + /** + * The Context of the Canvas element that the TileSprite renders its fill pattern in to. + * Only used in Canvas mode. + */ + context: CanvasRenderingContext2D; + + /** + * The Texture this Game Object is using to render with. + */ + texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; + + /** + * The Texture Frame this Game Object is using to render with. + */ + frame: Phaser.Textures.Frame; + + /** + * The next power of two value from the width of the Fill Pattern frame. + */ + potWidth: integer; + + /** + * The next power of two value from the height of the Fill Pattern frame. + */ + potHeight: integer; + + /** + * The Canvas that the TileSprites texture is rendered to. + * This is used to create a WebGL texture from. + */ + fillCanvas: HTMLCanvasElement; + + /** + * The Canvas Context used to render the TileSprites texture. + */ + fillContext: CanvasRenderingContext2D; + + /** + * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * In WebGL this is a WebGLTexture. In Canvas it's a Canvas Fill Pattern. + */ + fillPattern: WebGLTexture | CanvasPattern; + + /** + * Sets the texture and frame this Game Object will use to render with. + * + * Textures are referenced by their string-based keys, as stored in the Texture Manager. + * @param key The key of the texture to be used, as stored in the Texture Manager. + * @param frame The name or index of the frame within the Texture. + */ + setTexture(key: string, frame?: string | integer): this; + + /** + * Sets the frame this Game Object will use to render with. + * + * The Frame has to belong to the current Texture being used. + * + * It can be either a string or an index. + * @param frame The name or index of the frame within the Texture. + */ + setFrame(frame: string | integer): this; + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. + * @param x The x position of this sprite's tiling texture. + * @param y The y position of this sprite's tiling texture. + */ + setTilePosition(x?: number, y?: number): this; + + /** + * Sets {@link Phaser.GameObjects.TileSprite#tileScaleX} and {@link Phaser.GameObjects.TileSprite#tileScaleY}. + * @param x The horizontal scale of the tiling texture. If not given it will use the current `tileScaleX` value. + * @param y The vertical scale of the tiling texture. If not given it will use the `x` value. Default x. + */ + setTileScale(x?: number, y?: number): this; + + /** + * Internal destroy handler, called as part of the destroy process. + */ + protected preDestroy(): void; /** * The horizontal scroll position of the Tile Sprite. @@ -22332,63 +34739,14 @@ declare namespace Phaser { tilePositionY: number; /** - * Whether the Tile Sprite has changed in some way, requiring an re-render of its tile texture. - * - * Such changes include the texture frame and scroll position of the Tile Sprite. + * The horizontal scale of the Tile Sprite texture. */ - dirty: boolean; + tileScaleX: number; /** - * The texture that the Tile Sprite is rendered to, which is then rendered to a Scene. + * The vertical scale of the Tile Sprite texture. */ - tileTexture: WebGLTexture; - - /** - * The renderer in use by this Tile Sprite. - */ - renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * The next power of two value from the width of the Frame. - */ - potWidth: integer; - - /** - * The next power of two value from the height of the Frame. - */ - potHeight: integer; - - /** - * [description] - */ - canvasPattern: CanvasPattern; - - /** - * [description] - */ - canvasBuffer: HTMLCanvasElement; - - /** - * [description] - */ - canvasBufferCtx: CanvasRenderingContext2D; - - /** - * Sets {@link Phaser.GameObjects.TileSprite#tilePositionX} and {@link Phaser.GameObjects.TileSprite#tilePositionY}. - * @param x The x position of this sprite's tiling texture. - * @param y The y position of this sprite's tiling texture. - */ - setTilePosition(x?: number, y?: number): Phaser.GameObjects.TileSprite; - - /** - * Render the tile texture if it is dirty, or if the frame has changed. - */ - updateTileTexture(): void; - - /** - * Internal destroy handler, called as part of the destroy process. - */ - protected preDestroy(): void; + tileScaleY: number; /** * Clears all alpha values associated with this Game Object. @@ -22451,6 +34809,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -22473,6 +34832,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -22480,12 +34840,108 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ setBlendMode(value: string | Phaser.BlendModes): this; + /** + * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. + */ + width: number; + + /** + * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. + */ + height: number; + + /** + * The displayed width of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayWidth: number; + + /** + * The displayed height of this Game Object. + * + * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. + */ + displayHeight: number; + + /** + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setSize(width: number, height: number): this; + + /** + * Sets the display size of this Game Object. + * + * Calling this will adjust the scale. + * @param width The width of this Game Object. + * @param height The height of this Game Object. + */ + setDisplaySize(width: number, height: number): this; + + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * The depth of this Game Object within the Scene. * @@ -22615,12 +35071,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -22731,15 +35191,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -22775,6 +35235,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -22789,6 +35254,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -22803,103 +35273,74 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ setScrollFactor(x: number, y?: number): this; /** - * The native (un-scaled) width of this Game Object. + * Fill or additive? */ - width: number; - - /** - * The native (un-scaled) height of this Game Object. - */ - height: number; - - /** - * The displayed width of this Game Object. - * This value takes into account the scale factor. - */ - displayWidth: number; - - /** - * The displayed height of this Game Object. - * This value takes into account the scale factor. - */ - displayHeight: number; - - /** - * Sets the size of this Game Object to be that of the given Frame. - * @param frame The frame to base the size of this Game Object on. - */ - setSizeToFrame(frame: Phaser.Textures.Frame): this; - - /** - * Sets the size of this Game Object. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setSize(width: number, height: number): this; - - /** - * Sets the display size of this Game Object. - * Calling this will adjust the scale. - * @param width The width of this Game Object. - * @param height The height of this Game Object. - */ - setDisplaySize(width: number, height: number): this; - - /** - * The Texture this Game Object is using to render with. - */ - texture: Phaser.Textures.Texture | Phaser.Textures.CanvasTexture; - - /** - * The Texture Frame this Game Object is using to render with. - */ - frame: Phaser.Textures.Frame; - - /** - * Sets the texture and frame this Game Object will use to render with. - * - * Textures are referenced by their string-based keys, as stored in the Texture Manager. - * @param key The key of the texture to be used, as stored in the Texture Manager. - * @param frame The name or index of the frame within the Texture. - */ - setTexture(key: string, frame?: string | integer): this; - - /** - * Sets the frame this Game Object will use to render with. - * - * The Frame has to belong to the current Texture being used. - * - * It can be either a string or an index. - * - * Calling `setFrame` will modify the `width` and `height` properties of your Game Object. - * It will also change the `origin` if the Frame has a custom pivot point, as exported from packages like Texture Packer. - * @param frame The name or index of the frame within the Texture. - * @param updateSize Should this call adjust the size of the Game Object? Default true. - * @param updateOrigin Should this call adjust the origin of the Game Object? Default true. - */ - setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + tintFill: boolean; /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -22929,6 +35370,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -23052,8 +35498,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -23163,7 +35610,7 @@ declare namespace Phaser { class Zone extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Visible { /** * - * @param scene [description] + * @param scene The Scene to which this Game Object belongs. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. * @param width The width of the Game Object. Default 1. @@ -23505,8 +35952,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The horizontal scroll factor of this Game Object. @@ -23519,6 +35967,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -23533,6 +35986,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -23547,6 +36005,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -23860,7 +36323,7 @@ declare namespace Phaser { /** * Check to see if the Ellipse contains all four points of the given Rectangle object. - * @param ellipse [description] + * @param ellipse The Ellipse to check. * @param rect The Rectangle object to check if it's within the Ellipse or not. */ static ContainsRect(ellipse: Phaser.Geom.Ellipse, rect: Phaser.Geom.Rectangle | object): boolean; @@ -24050,40 +36513,46 @@ declare namespace Phaser { namespace Intersects { /** - * [description] - * @param circleA [description] - * @param circleB [description] + * Checks if two Circles intersect. + * @param circleA The first Circle to check for intersection. + * @param circleB The second Circle to check for intersection. */ function CircleToCircle(circleA: Phaser.Geom.Circle, circleB: Phaser.Geom.Circle): boolean; /** - * [description] - * @param circle [description] - * @param rect [description] + * Checks for intersection between a circle and a rectangle. + * @param circle The circle to be checked. + * @param rect The rectangle to be checked. */ function CircleToRectangle(circle: Phaser.Geom.Circle, rect: Phaser.Geom.Rectangle): boolean; /** - * [description] - * @param rectA [description] - * @param rectB [description] - * @param output [description] + * Checks if two Rectangle shapes intersect and returns the area of this intersection as Rectangle object. + * + * If optional `output` parameter is omitted, new Rectangle object is created and returned. If there is intersection, it will contain intersection area. If there is no intersection, it wil be empty Rectangle (all values set to zero). + * + * If Rectangle object is passed as `output` and there is intersection, then intersection area data will be loaded into it and it will be returned. If there is no intersetion, it will be returned without any change. + * @param rectA The first Rectangle object. + * @param rectB The second Rectangle object. + * @param output Optional Rectangle object. If given, the intersection data will be loaded into it (in case of no intersection, it will be left unchanged). Otherwise, new Rectangle object will be created and returned with either intersection data or empty (all values set to zero), if there is no intersection. */ function GetRectangleIntersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, output?: O): O; /** - * [description] - * @param line [description] - * @param circle [description] - * @param nearest [description] + * Checks for intersection between the line segment and circle. + * + * Based on code by [Matt DesLauriers](https://github.com/mattdesl/line-circle-collision/blob/master/LICENSE.md). + * @param line The line segment to check. + * @param circle The circle to check against the line. + * @param nearest An optional Point-like object. If given the closest point on the Line where the circle intersects will be stored in this object. */ - function LineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, nearest?: Phaser.Geom.Point): boolean; + function LineToCircle(line: Phaser.Geom.Line, circle: Phaser.Geom.Circle, nearest?: Phaser.Geom.Point | any): boolean; /** - * [description] - * @param line1 [description] - * @param line2 [description] - * @param out [description] + * Checks if two Lines intersect. If the Lines are identical, they will be treated as parallel and thus non-intersecting. + * @param line1 The first Line to check. + * @param line2 The second Line to check. + * @param out A Point in which to optionally store the point of intersection. */ function LineToLine(line1: Phaser.Geom.Line, line2: Phaser.Geom.Line, out?: Phaser.Geom.Point): boolean; @@ -24097,68 +36566,79 @@ declare namespace Phaser { * The line segment intersects one of the 4 rectangle edges. * * The for the purposes of this function rectangles are considered 'solid'. - * @param line [description] - * @param rect [description] + * @param line The Line to check for intersection. + * @param rect The Rectangle to check for intersection. */ function LineToRectangle(line: Phaser.Geom.Line, rect: Phaser.Geom.Rectangle | object): boolean; /** - * [description] - * @param point [description] - * @param line [description] + * Checks if the a Point falls between the two end-points of a Line, based on the given line thickness. + * + * Assumes that the line end points are circular, not square. + * @param point The point, or point-like object to check. + * @param line The line segment to test for intersection on. + * @param lineThickness The line thickness. Assumes that the line end points are circular. Default 1. */ - function PointToLine(point: Phaser.Geom.Point, line: Phaser.Geom.Line): boolean; + function PointToLine(point: Phaser.Geom.Point | any, line: Phaser.Geom.Line, lineThickness?: number): boolean; /** - * [description] - * @param point [description] - * @param line [description] + * Checks if a Point is located on the given line segment. + * @param point The Point to check for intersection. + * @param line The line segment to check for intersection. */ function PointToLineSegment(point: Phaser.Geom.Point, line: Phaser.Geom.Line): boolean; /** - * [description] - * @param rectA [description] - * @param rectB [description] + * Checks if two Rectangles intersect. + * + * A Rectangle intersects another Rectangle if any part of its bounds is within the other Rectangle's bounds. As such, the two Rectangles are considered "solid". A Rectangle with no width or no height will never intersect another Rectangle. + * @param rectA The first Rectangle to check for intersection. + * @param rectB The second Rectangle to check for intersection. */ function RectangleToRectangle(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; /** - * [description] - * @param rect [description] - * @param triangle [description] + * Checks for intersection between Rectangle shape and Triangle shape. + * @param rect Rectangle object to test. + * @param triangle Triangle object to test. */ function RectangleToTriangle(rect: Phaser.Geom.Rectangle, triangle: Phaser.Geom.Triangle): boolean; /** - * [description] - * @param rect [description] - * @param left [description] - * @param right [description] - * @param top [description] - * @param bottom [description] - * @param tolerance [description] Default 0. + * Check if rectangle intersects with values. + * @param rect The rectangle object + * @param left The x coordinate of the left of the Rectangle. + * @param right The x coordinate of the right of the Rectangle. + * @param top The y coordinate of the top of the Rectangle. + * @param bottom The y coordinate of the bottom of the Rectangle. + * @param tolerance Tolerance allowed in the calculation, expressed in pixels. Default 0. */ function RectangleToValues(rect: Phaser.Geom.Rectangle, left: number, right: number, top: number, bottom: number, tolerance?: number): boolean; /** - * [description] - * @param triangle [description] - * @param circle [description] + * Checks if a Triangle and a Circle intersect. + * + * A Circle intersects a Triangle if its center is located within it or if any of the Triangle's sides intersect the Circle. As such, the Triangle and the Circle are considered "solid" for the intersection. + * @param triangle The Triangle to check for intersection. + * @param circle The Circle to check for intersection. */ function TriangleToCircle(triangle: Phaser.Geom.Triangle, circle: Phaser.Geom.Circle): boolean; /** - * [description] - * @param triangle [description] - * @param line [description] + * Checks if a Triangle and a Line intersect. + * + * The Line intersects the Triangle if it starts inside of it, ends inside of it, or crosses any of the Triangle's sides. Thus, the Triangle is considered "solid". + * @param triangle The Triangle to check with. + * @param line The Line to check with. */ function TriangleToLine(triangle: Phaser.Geom.Triangle, line: Phaser.Geom.Line): boolean; /** - * [description] - * @param triangleA [description] - * @param triangleB [description] + * Checks if two Triangles intersect. + * + * A Triangle intersects another Triangle if any pair of their lines intersects or if any point of one Triangle is within the other Triangle. Thus, the Triangles are considered "solid". + * @param triangleA The first Triangle to check for intersection. + * @param triangleB The second Triangle to check for intersection. */ function TriangleToTriangle(triangleA: Phaser.Geom.Triangle, triangleB: Phaser.Geom.Triangle): boolean; @@ -24178,88 +36658,126 @@ declare namespace Phaser { constructor(x1?: number, y1?: number, x2?: number, y2?: number); /** - * [description] - * @param line [description] + * Calculate the angle of the line in radians. + * @param line The line to calculate the angle of. */ static Angle(line: Phaser.Geom.Line): number; /** * Using Bresenham's line algorithm this will return an array of all coordinates on this line. - * The start and end points are rounded before this runs as the algorithm works on integers. - * @param line [description] - * @param stepRate [description] Default 1. - * @param results [description] + * + * The `start` and `end` points are rounded before this runs as the algorithm works on integers. + * @param line The line. + * @param stepRate The optional step rate for the points on the line. Default 1. + * @param results An optional array to push the resulting coordinates into. */ - static BresenhamPoints(line: Phaser.Geom.Line, stepRate?: integer, results?: any[]): any[]; + static BresenhamPoints(line: Phaser.Geom.Line, stepRate?: integer, results?: any[]): object[]; /** - * [description] - * @param line [description] - * @param x [description] - * @param y [description] + * Center a line on the given coordinates. + * @param line The line to center. + * @param x The horizontal coordinate to center the line on. + * @param y The vertical coordinate to center the line on. */ static CenterOn(line: Phaser.Geom.Line, x: number, y: number): Phaser.Geom.Line; /** - * [description] - * @param source [description] + * Clone the given line. + * @param source The source line to clone. */ static Clone(source: Phaser.Geom.Line): Phaser.Geom.Line; /** - * [description] - * @param source [description] - * @param dest [description] + * Copy the values of one line to a destination line. + * @param source The source line to copy the values from. + * @param dest The destination line to copy the values to. */ static CopyFrom(source: Phaser.Geom.Line, dest: O): O; /** - * [description] - * @param line [description] - * @param toCompare [description] + * Compare two lines for strict equality. + * @param line The first line to compare. + * @param toCompare The second line to compare. */ static Equals(line: Phaser.Geom.Line, toCompare: Phaser.Geom.Line): boolean; /** - * [description] - * @param line [description] - * @param out [description] + * Extends the start and end points of a Line by the given amounts. + * + * The amounts can be positive or negative. Positive points will increase the length of the line, + * while negative ones will decrease it. + * + * If no `right` value is provided it will extend the length of the line equally in both directions. + * + * Pass a value of zero to leave the start or end point unchanged. + * @param line The line instance to extend. + * @param left The amount to extend the start of the line by. + * @param right The amount to extend the end of the line by. If not given it will be set to the `left` value. + */ + static Extend(line: Phaser.Geom.Line, left: number, right?: number): Phaser.Geom.Line; + + /** + * Get the midpoint of the given line. + * @param line The line to get the midpoint of. + * @param out An optional point object to store the midpoint in. */ static GetMidPoint(line: Phaser.Geom.Line, out?: O): O; /** - * [description] - * @param line [description] - * @param out [description] + * Get the nearest point on a line perpendicular to the given point. + * @param line The line to get the nearest point on. + * @param point The point to get the nearest point to. + * @param out An optional point, or point-like object, to store the coordinates of the nearest point on the line. + */ + static GetNearestPoint(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object, out?: O): O; + + /** + * Calculate the normal of the given line. + * + * The normal of a line is a vector that points perpendicular from it. + * @param line The line to calculate the normal of. + * @param out An optional point object to store the normal in. */ static GetNormal(line: Phaser.Geom.Line, out?: O): O; /** - * [description] - * @param line [description] - * @param position A value between 0 and 1, where 0 equals 0 degrees, 0.5 equals 180 degrees and 1 equals 360 around the circle. - * @param out [description] + * Get a point on a line that's a given percentage along its length. + * @param line The line. + * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param out An optional point, or point-like object, to store the coordinates of the point on the line. */ static GetPoint(line: Phaser.Geom.Line, position: number, out?: O): O; /** - * [description] - * @param line [description] - * @param quantity [description] - * @param stepRate [description] - * @param out [description] + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * @param line The line. + * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param out An optional array of Points, or point-like objects, to store the coordinates of the points on the line. */ - static GetPoints(line: Phaser.Geom.Line, quantity: integer, stepRate?: integer, out?: O): O; + static GetPoints(line: Phaser.Geom.Line, quantity: integer, stepRate?: number, out?: O): O; /** - * [description] - * @param line [description] + * Get the shortest distance from a Line to the given Point. + * @param line The line to get the distance from. + * @param point The point to get the shortest distance to. + */ + static GetShortestDistance(line: Phaser.Geom.Line, point: Phaser.Geom.Point | object): O; + + /** + * Calculate the height of the given line. + * @param line The line to calculate the height of. */ static Height(line: Phaser.Geom.Line): number; /** - * [description] - * @param line [description] + * Calculate the length of the given line. + * @param line The line to calculate the length of. */ static Length(line: Phaser.Geom.Line): number; @@ -24284,17 +36802,22 @@ declare namespace Phaser { y2: number; /** - * [description] - * @param position [description] - * @param output [description] + * Get a point on a line that's a given percentage along its length. + * @param position A value between 0 and 1, where 0 is the start, 0.5 is the middle and 1 is the end of the line. + * @param output An optional point, or point-like object, to store the coordinates of the point on the line. */ getPoint(position: number, output?: O): O; /** - * [description] - * @param quantity [description] - * @param stepRate [description] - * @param output [description] + * Get a number of points along a line's length. + * + * Provide a `quantity` to get an exact number of points along the line. + * + * Provide a `stepRate` to ensure a specific distance between each point on the line. Set `quantity` to `0` when + * providing a `stepRate`. + * @param quantity The number of points to place on the line. Set to `0` to use `stepRate` instead. + * @param stepRate The distance between each point on the line. When set, `quantity` is implied and should be set to `0`. + * @param output An optional array of Points, or point-like objects, to store the coordinates of the points on the line. */ getPoints(quantity: integer, stepRate?: integer, output?: O): O; @@ -24320,7 +36843,7 @@ declare namespace Phaser { getPointA(vec2?: O): O; /** - * Returns a Vector2 object that corresponds to the start of this Line. + * Returns a Vector2 object that corresponds to the end of this Line. * @param vec2 A Vector2 object to set the results in. If `undefined` a new Vector2 will be created. */ getPointB(vec2?: O): O; @@ -24346,34 +36869,35 @@ declare namespace Phaser { bottom: number; /** - * [description] - * @param line [description] + * Get the angle of the normal of the given line in radians. + * @param line The line to calculate the angle of the normal of. */ static NormalAngle(line: Phaser.Geom.Line): number; /** * [description] - * @param line [description] + * @param line The Line object to get the normal value from. */ static NormalX(line: Phaser.Geom.Line): number; /** - * [description] - * @param line [description] + * The Y value of the normal of the given line. + * The normal of a line is a vector that points perpendicular from it. + * @param line The line to calculate the normal of. */ static NormalY(line: Phaser.Geom.Line): number; /** - * [description] - * @param line [description] - * @param x [description] - * @param y [description] + * Offset a line by the given amount. + * @param line The line to offset. + * @param x The horizontal offset to add to the line. + * @param y The vertical offset to add to the line. */ static Offset(line: O, x: number, y: number): O; /** - * [description] - * @param line [description] + * Calculate the perpendicular slope of the given line. + * @param line The line to calculate the perpendicular slope of. */ static PerpSlope(line: Phaser.Geom.Line): number; @@ -24385,55 +36909,57 @@ declare namespace Phaser { static Random(line: Phaser.Geom.Line, out?: O): O; /** - * [description] - * @param lineA [description] - * @param lineB [description] + * Calculate the reflected angle between two lines. + * + * This is the outgoing angle based on the angle of Line 1 and the normalAngle of Line 2. + * @param lineA The first line. + * @param lineB The second line. */ static ReflectAngle(lineA: Phaser.Geom.Line, lineB: Phaser.Geom.Line): number; /** - * [description] - * @param line [description] - * @param angle [description] + * Rotate a line around its midpoint by the given angle in radians. + * @param line The line to rotate. + * @param angle The angle of rotation in radians. */ static Rotate(line: O, angle: number): O; /** - * [description] - * @param line [description] - * @param point [description] - * @param angle [description] + * Rotate a line around a point by the given angle in radians. + * @param line The line to rotate. + * @param point The point to rotate the line around. + * @param angle The angle of rotation in radians. */ static RotateAroundPoint(line: O, point: Phaser.Geom.Point | object, angle: number): O; /** - * [description] - * @param line [description] - * @param x [description] - * @param y [description] - * @param angle [description] + * Rotate a line around the given coordinates by the given angle in radians. + * @param line The line to rotate. + * @param x The horizontal coordinate to rotate the line around. + * @param y The vertical coordinate to rotate the line around. + * @param angle The angle of rotation in radians. */ static RotateAroundXY(line: O, x: number, y: number, angle: number): O; /** - * [description] - * @param line [description] - * @param x [description] - * @param y [description] - * @param angle [description] - * @param length [description] + * Set a line to a given position, angle and length. + * @param line The line to set. + * @param x The horizontal start position of the line. + * @param y The vertical start position of the line. + * @param angle The angle of the line in radians. + * @param length The length of the line. */ static SetToAngle(line: O, x: number, y: number, angle: number, length: number): O; /** - * [description] - * @param line [description] + * Calculate the slope of the given line. + * @param line The line to calculate the slope of. */ static Slope(line: Phaser.Geom.Line): number; /** - * [description] - * @param line [description] + * Calculate the width of the given line. + * @param line The line to calculate the width of. */ static Width(line: Phaser.Geom.Line): number; @@ -24451,53 +36977,54 @@ declare namespace Phaser { constructor(x?: number, y?: number); /** - * [description] - * @param point [description] + * Apply `Math.ceil()` to each coordinate of the given Point. + * @param point The Point to ceil. */ static Ceil(point: O): O; /** - * [description] - * @param source [description] + * Clone the given Point. + * @param source The source Point to clone. */ static Clone(source: Phaser.Geom.Point): Phaser.Geom.Point; /** - * [description] - * @param source [description] - * @param dest [description] + * Copy the values of one Point to a destination Point. + * @param source The source Point to copy the values from. + * @param dest The destination Point to copy the values to. */ static CopyFrom(source: Phaser.Geom.Point, dest: O): O; /** - * [description] - * @param point [description] - * @param toCompare [description] + * A comparison of two `Point` objects to see if they are equal. + * @param point The original `Point` to compare against. + * @param toCompare The second `Point` to compare. */ static Equals(point: Phaser.Geom.Point, toCompare: Phaser.Geom.Point): boolean; /** - * [description] - * @param point [description] + * Apply `Math.ceil()` to each coordinate of the given Point. + * @param point The Point to floor. */ static Floor(point: O): O; /** - * [description] + * Get the centroid or geometric center of a plane figure (the arithmetic mean position of all the points in the figure). + * Informally, it is the point at which a cutout of the shape could be perfectly balanced on the tip of a pin. * @param points [description] * @param out [description] */ static GetCentroid(points: Phaser.Geom.Point[], out?: O): O; /** - * [description] - * @param point [description] + * Calculate the magnitude of the point, which equivalent to the length of the line from the origin to this point. + * @param point The point to calculate the magnitude for */ static GetMagnitude(point: Phaser.Geom.Point): number; /** - * [description] - * @param point [description] + * Calculates the square of magnitude of given point.(Can be used for fast magnitude calculation of point) + * @param point Returns square of the magnitude/length of given point. */ static GetMagnitudeSq(point: Phaser.Geom.Point): number; @@ -24510,23 +37037,23 @@ declare namespace Phaser { /** * [description] - * @param pointA [description] - * @param pointB [description] - * @param t [description] Default 0. - * @param out [description] + * @param pointA The starting `Point` for the interpolation. + * @param pointB The target `Point` for the interpolation. + * @param t The amount to interpolate between the two points. Generally, a value between 0 (returns the starting `Point`) and 1 (returns the target `Point`). If omitted, 0 is used. Default 0. + * @param out An optional `Point` object whose `x` and `y` values will be set to the result of the interpolation (can also be any object with `x` and `y` properties). If omitted, a new `Point` created and returned. */ static Interpolate(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, t?: number, out?: O): O; /** - * [description] - * @param point [description] + * Swaps the X and the Y coordinate of a point. + * @param point The Point to modify. */ static Invert(point: O): O; /** - * [description] - * @param point [description] - * @param out [description] + * Inverts a Point's coordinates. + * @param point The Point to invert. + * @param out The Point to return the inverted coordinates in. */ static Negative(point: Phaser.Geom.Point, out?: O): O; @@ -24564,35 +37091,46 @@ declare namespace Phaser { static ProjectUnit(pointA: Phaser.Geom.Point, pointB: Phaser.Geom.Point, out?: O): O; /** - * [description] - * @param point [description] - * @param magnitude [description] + * Changes the magnitude (length) of a two-dimensional vector without changing its direction. + * @param point The Point to treat as the end point of the vector. + * @param magnitude The new magnitude of the vector. */ static SetMagnitude(point: O, magnitude: number): O; } /** - * [description] + * A Polygon object + * + * The polygon is a closed shape consists of a series of connected straight lines defined by list of ordered points. + * Several formats are supported to define the list of points, check the setTo method for details. + * This is a geometry object allowing you to define and inspect the shape. + * It is not a Game Object, in that you cannot add it to the display list, and it has no texture. + * To render a Polygon you should look at the capabilities of the Graphics class. */ class Polygon { /** * - * @param points [description] + * @param points List of points defining the perimeter of this Polygon. Several formats are supported: + * - A string containing paired x y values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` + * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` + * - An array of objects with public x y properties: `[obj1, obj2, ...]` + * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` + * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` */ constructor(points?: Phaser.Geom.Point[]); /** - * [description] - * @param polygon [description] + * Create a new polygon which is a copy of the specified polygon + * @param polygon The polygon to create a clone of */ static Clone(polygon: Phaser.Geom.Polygon): Phaser.Geom.Polygon; /** - * [description] - * @param polygon [description] - * @param x [description] - * @param y [description] + * Checks if a point is within the bounds of a Polygon. + * @param polygon The Polygon to check against. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. */ static Contains(polygon: Phaser.Geom.Polygon, x: number, y: number): boolean; @@ -24604,19 +37142,37 @@ declare namespace Phaser { static ContainsPoint(polygon: Phaser.Geom.Polygon, point: Phaser.Geom.Point): boolean; /** - * [description] - * @param polygon [description] - * @param out [description] + * Calculates the bounding AABB rectangle of a polygon. + * @param polygon The polygon that should be calculated. + * @param out The rectangle or object that has x, y, width, and height properties to store the result. Optional. */ static GetAABB(polygon: Phaser.Geom.Polygon, out?: O): O; /** - * [description] - * @param polygon [description] - * @param output [description] + * Stores all of the points of a Polygon into a flat array of numbers following the sequence [ x,y, x,y, x,y ], + * i.e. each point of the Polygon, in the order it's defined, corresponds to two elements of the resultant + * array for the point's X and Y coordinate. + * @param polygon The Polygon whose points to export. + * @param output An array to which the points' coordinates should be appended. */ static GetNumberArray(polygon: Phaser.Geom.Polygon, output?: O): O; + /** + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * @param polygon The Polygon to get the points from. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. + */ + static GetPoints(polygon: Phaser.Geom.Polygon, quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; + + /** + * Returns the perimeter of the given Polygon. + * @param polygon The Polygon to get the perimeter of. + */ + static Perimeter(polygon: Phaser.Geom.Polygon): number; + /** * The area of this Polygon. */ @@ -24628,9 +37184,9 @@ declare namespace Phaser { points: Phaser.Geom.Point[]; /** - * [description] - * @param x [description] - * @param y [description] + * Check to see if the Polygon contains the given x / y coordinates. + * @param x The x coordinate to check within the polygon. + * @param y The y coordinate to check within the polygon. */ contains(x: number, y: number): boolean; @@ -24639,13 +37195,14 @@ declare namespace Phaser { * * The points can be set from a variety of formats: * + * - A string containing paired values separated by a single space: `'40 0 40 20 100 20 100 80 40 80 40 100 0 50'` * - An array of Point objects: `[new Phaser.Point(x1, y1), ...]` * - An array of objects with public x/y properties: `[obj1, obj2, ...]` * - An array of paired numbers that represent point coordinates: `[x1,y1, x2,y2, ...]` * - An array of arrays with two elements representing x/y coordinates: `[[x1, y1], [x2, y2], ...]` * * `setTo` may also be called without any arguments to remove all points. - * @param points [description] + * @param points Points defining the perimeter of this polygon. Please check function description above for the different supported formats. */ setTo(points: any[]): Phaser.Geom.Polygon; @@ -24655,11 +37212,26 @@ declare namespace Phaser { calculateArea(): number; /** - * [description] - * @param polygon [description] + * Returns an array of Point objects containing the coordinates of the points around the perimeter of the Polygon, + * based on the given quantity or stepRate values. + * @param quantity The amount of points to return. If a falsey value the quantity will be derived from the `stepRate` instead. + * @param stepRate Sets the quantity by getting the perimeter of the Polygon and dividing it by the stepRate. + * @param output An array to insert the points in to. If not provided a new array will be created. + */ + getPoints(quantity: integer, stepRate?: number, output?: any[]): Phaser.Geom.Point[]; + + /** + * Reverses the order of the points of a Polygon. + * @param polygon The Polygon to modify. */ static Reverse(polygon: O): O; + /** + * Takes a Polygon object and applies Chaikin's smoothing algorithm on its points. + * @param polygon The polygon to be smoothed. The polygon will be modified in-place and returned. + */ + static Smooth(polygon: O): O; + } /** @@ -24668,131 +37240,140 @@ declare namespace Phaser { class Rectangle { /** * - * @param x [description] Default 0. - * @param y [description] Default 0. - * @param width [description] Default 0. - * @param height [description] Default 0. + * @param x The X coordinate of the top left corner of the Rectangle. Default 0. + * @param y The Y coordinate of the top left corner of the Rectangle. Default 0. + * @param width The width of the Rectangle. Default 0. + * @param height The height of the Rectangle. Default 0. */ constructor(x?: number, y?: number, width?: number, height?: number); /** - * [description] - * @param rect [description] + * Calculates the area of the given Rectangle object. + * @param rect The rectangle to calculate the area of. */ static Area(rect: Phaser.Geom.Rectangle): number; /** - * [description] - * @param rect [description] + * Rounds a Rectangle's position up to the smallest integer greater than or equal to each current coordinate. + * @param rect The Rectangle to adjust. */ static Ceil(rect: O): O; /** - * [description] - * @param rect [description] + * Rounds a Rectangle's position and size up to the smallest integer greater than or equal to each respective value. + * @param rect The Rectangle to modify. */ static CeilAll(rect: O): O; /** - * [description] - * @param rect [description] - * @param x [description] - * @param y [description] + * Moves the top-left corner of a Rectangle so that its center is at the given coordinates. + * @param rect The Rectangle to be centered. + * @param x The X coordinate of the Rectangle's center. + * @param y The Y coordinate of the Rectangle's center. */ static CenterOn(rect: O, x: number, y: number): O; /** - * [description] - * @param source [description] + * Creates a new Rectangle which is identical to the given one. + * @param source The Rectangle to clone. */ static Clone(source: Phaser.Geom.Rectangle): Phaser.Geom.Rectangle; /** - * [description] - * @param rect [description] - * @param x [description] - * @param y [description] + * Checks if a given point is inside a Rectangle's bounds. + * @param rect The Rectangle to check. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. */ static Contains(rect: Phaser.Geom.Rectangle, x: number, y: number): boolean; /** - * [description] - * @param rect [description] - * @param point [description] + * Determines whether the specified point is contained within the rectangular region defined by this Rectangle object. + * @param rect The Rectangle object. + * @param point The point object to be checked. Can be a Phaser Point object or any object with x and y values. */ static ContainsPoint(rect: Phaser.Geom.Rectangle, point: Phaser.Geom.Point): boolean; /** - * [description] - * @param rectA [description] - * @param rectB [description] + * Tests if one rectangle fully contains another. + * @param rectA The first rectangle. + * @param rectB The second rectangle. */ static ContainsRect(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; /** - * [description] - * @param source [description] - * @param dest [description] + * Copy the values of one Rectangle to a destination Rectangle. + * @param source The source Rectangle to copy the values from. + * @param dest The destination Rectangle to copy the values to. */ static CopyFrom(source: Phaser.Geom.Rectangle, dest: O): O; /** - * [description] - * @param rect [description] - * @param out [description] + * Create an array of points for each corner of a Rectangle + * If an array is specified, each point object will be added to the end of the array, otherwise a new array will be created. + * @param rect The Rectangle object to be decomposed. + * @param out If provided, each point will be added to this array. */ static Decompose(rect: Phaser.Geom.Rectangle, out?: any[]): any[]; /** - * [description] - * @param rect [description] - * @param toCompare [description] + * Compares the `x`, `y`, `width` and `height` properties of two rectangles. + * @param rect Rectangle A + * @param toCompare Rectangle B */ static Equals(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; /** - * [description] - * @param target [description] - * @param source [description] + * Adjusts the target rectangle, changing its width, height and position, + * so that it fits inside the area of the source rectangle, while maintaining its original + * aspect ratio. + * + * Unlike the `FitOutside` function, there may be some space inside the source area not covered. + * @param target The target rectangle to adjust. + * @param source The source rectangle to envlope the target in. */ static FitInside(target: O, source: Phaser.Geom.Rectangle): O; /** - * [description] - * @param target [description] - * @param source [description] + * Adjusts the target rectangle, changing its width, height and position, + * so that it fully covers the area of the source rectangle, while maintaining its original + * aspect ratio. + * + * Unlike the `FitInside` function, the target rectangle may extend further out than the source. + * @param target The target rectangle to adjust. + * @param source The source rectangle to envlope the target in. */ static FitOutside(target: O, source: Phaser.Geom.Rectangle): O; /** - * [description] - * @param rect [description] + * Rounds down (floors) the top left X and Y co-ordinates of the given Rectangle to the largest integer less than or equal to them + * @param rect The rectangle to floor the top left X and Y co-ordinates of */ static Floor(rect: O): O; /** - * [description] - * @param rect [description] + * Rounds a Rectangle's position and size down to the largest integer less than or equal to each current coordinate or dimension. + * @param rect The Rectangle to adjust. */ static FloorAll(rect: O): O; /** - * [description] - * @param points [description] - * @param out [description] + * Constructs new Rectangle or repositions and resizes an existing Rectangle so that all of the given points are on or within its bounds. + * @param points An array of points (either arrays with two elements corresponding to the X and Y coordinate or an object with public `x` and `y` properties) which should be surrounded by the Rectangle. + * @param out Optional Rectangle to adjust. */ static FromPoints(points: any[], out?: O): O; /** - * [description] - * @param rect [description] + * Calculates the width/height ratio of a rectangle. + * @param rect The rectangle. */ static GetAspectRatio(rect: Phaser.Geom.Rectangle): number; /** - * [description] - * @param rect [description] - * @param out [description] + * Returns the center of a Rectangle as a Point. + * @param rect The Rectangle to get the center of. + * @param out Optional point-like object to update with the center coordinates. */ static GetCenter(rect: Phaser.Geom.Rectangle, out?: O): O; @@ -24805,11 +37386,11 @@ declare namespace Phaser { static GetPoint(rectangle: Phaser.Geom.Rectangle, position: number, out?: O): O; /** - * [description] - * @param rectangle [description] - * @param step [description] - * @param quantity [description] - * @param out [description] + * Return an array of points from the perimeter of the rectangle, each spaced out based on the quantity or step required. + * @param rectangle The Rectangle object to get the points from. + * @param step Step between points. Used to calculate the number of points to return when quantity is falsy. Ignored if quantity is positive. + * @param quantity The number of evenly spaced points from the rectangles perimeter to return. If falsy, step param will be used to calculate the number of points. + * @param out An optional array to store the points in. */ static GetPoints(rectangle: Phaser.Geom.Rectangle, step: number, quantity: integer, out?: O): O; @@ -24821,13 +37402,25 @@ declare namespace Phaser { static GetSize(rect: Phaser.Geom.Rectangle, out?: O): O; /** - * [description] - * @param rect [description] - * @param x [description] - * @param y [description] + * Increases the size of a Rectangle by a specified amount. + * + * The center of the Rectangle stays the same. The amounts are added to each side, so the actual increase in width or height is two times bigger than the respective argument. + * @param rect The Rectangle to inflate. + * @param x How many pixels the left and the right side should be moved by horizontally. + * @param y How many pixels the top and the bottom side should be moved by vertically. */ static Inflate(rect: O, x: number, y: number): O; + /** + * Takes two Rectangles and first checks to see if they intersect. + * If they intersect it will return the area of intersection in the `out` Rectangle. + * If they do not intersect, the `out` Rectangle will have a width and height of zero. + * @param rectA The first Rectangle to get the intersection from. + * @param rectB The second Rectangle to get the intersection from. + * @param out A Rectangle to store the intersection results in. + */ + static Intersection(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: Phaser.Geom.Rectangle): O; + /** * [description] * @param rect [description] @@ -24838,52 +37431,53 @@ declare namespace Phaser { static MarchingAnts(rect: Phaser.Geom.Rectangle, step: number, quantity: integer, out?: O): O; /** - * [description] - * @param target [description] - * @param points [description] + * Merges a Rectangle with a list of points by repositioning and/or resizing it such that all points are located on or within its bounds. + * @param target The Rectangle which should be merged. + * @param points An array of Points (or any object with public `x` and `y` properties) which should be merged with the Rectangle. */ static MergePoints(target: O, points: Phaser.Geom.Point[]): O; /** - * [description] - * @param target [description] - * @param source [description] + * Merges the source rectangle into the target rectangle and returns the target. + * Neither rectangle should have a negative width or height. + * @param target Target rectangle. Will be modified to include source rectangle. + * @param source Rectangle that will be merged into target rectangle. */ static MergeRect(target: O, source: Phaser.Geom.Rectangle): O; /** - * [description] - * @param target [description] - * @param x [description] - * @param y [description] + * Merges a Rectangle with a point by repositioning and/or resizing it so that the point is on or within its bounds. + * @param target The Rectangle which should be merged and modified. + * @param x The X coordinate of the point which should be merged. + * @param y The Y coordinate of the point which should be merged. */ static MergeXY(target: O, x: number, y: number): O; /** - * [description] - * @param rect [description] - * @param x [description] - * @param y [description] + * Nudges (translates) the top left corner of a Rectangle by a given offset. + * @param rect The Rectangle to adjust. + * @param x The distance to move the Rectangle horizontally. + * @param y The distance to move the Rectangle vertically. */ static Offset(rect: O, x: number, y: number): O; /** - * [description] - * @param rect [description] - * @param point [description] + * Nudges (translates) the top-left corner of a Rectangle by the coordinates of a point (translation vector). + * @param rect The Rectangle to adjust. + * @param point The point whose coordinates should be used as an offset. */ - static OffsetPoint(rect: O, point: Phaser.Geom.Point): O; + static OffsetPoint(rect: O, point: Phaser.Geom.Point | Phaser.Math.Vector2): O; /** - * [description] - * @param rectA [description] - * @param rectB [description] + * Checks if two Rectangles overlap. If a Rectangle is within another Rectangle, the two will be considered overlapping. Thus, the Rectangles are treated as "solid". + * @param rectA The first Rectangle to check. + * @param rectB The second Rectangle to check. */ static Overlaps(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle): boolean; /** - * [description] - * @param rect [description] + * Calculates the perimeter of a Rectangle. + * @param rect The Rectangle to use. */ static Perimeter(rect: Phaser.Geom.Rectangle): number; @@ -24896,9 +37490,9 @@ declare namespace Phaser { static PerimeterPoint(rectangle: Phaser.Geom.Rectangle, angle: integer, out?: O): O; /** - * [description] - * @param rect [description] - * @param out [description] + * Returns a random point within a Rectangle. + * @param rect The Rectangle to return a point from. + * @param out The object to update with the point's coordinates. */ static Random(rect: Phaser.Geom.Rectangle, out: O): O; @@ -24912,83 +37506,87 @@ declare namespace Phaser { static RandomOutside(outer: Phaser.Geom.Rectangle, inner: Phaser.Geom.Rectangle, out?: O): O; /** - * [description] + * The X coordinate of the top left corner of the Rectangle. */ x: number; /** - * [description] + * The Y coordinate of the top left corner of the Rectangle. */ y: number; /** - * [description] + * The width of the Rectangle, i.e. the distance between its left side (defined by `x`) and its right side. */ width: number; /** - * [description] + * The height of the Rectangle, i.e. the distance between its top side (defined by `y`) and its bottom side. */ height: number; /** - * [description] - * @param x [description] - * @param y [description] + * Checks if the given point is inside the Rectangle's bounds. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. */ contains(x: number, y: number): boolean; /** - * [description] - * @param position [description] - * @param output [description] + * Calculates the coordinates of a point at a certain `position` on the Rectangle's perimeter. + * + * The `position` is a fraction between 0 and 1 which defines how far into the perimeter the point is. + * + * A value of 0 or 1 returns the point at the top left corner of the rectangle, while a value of 0.5 returns the point at the bottom right corner of the rectangle. Values between 0 and 0.5 are on the top or the right side and values between 0.5 and 1 are on the bottom or the left side. + * @param position The normalized distance into the Rectangle's perimeter to return. + * @param output An object to update with the `x` and `y` coordinates of the point. */ getPoint(position: number, output?: O): O; /** - * [description] - * @param quantity [description] - * @param stepRate [description] - * @param output [description] + * Returns an array of points from the perimeter of the Rectangle, each spaced out based on the quantity or step required. + * @param quantity The number of points to return. Set to `false` or 0 to return an arbitrary number of points (`perimeter / stepRate`) evenly spaced around the Rectangle based on the `stepRate`. + * @param stepRate If `quantity` is 0, determines the normalized distance between each returned point. + * @param output An array to which to append the points. */ getPoints(quantity: integer, stepRate?: number, output?: O): O; /** - * [description] - * @param point [description] + * Returns a random point within the Rectangle's bounds. + * @param point The object in which to store the `x` and `y` coordinates of the point. */ getRandomPoint(point?: O): O; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] + * Sets the position, width, and height of the Rectangle. + * @param x The X coordinate of the top left corner of the Rectangle. + * @param y The Y coordinate of the top left corner of the Rectangle. + * @param width The width of the Rectangle. + * @param height The height of the Rectangle. */ setTo(x: number, y: number, width: number, height: number): Phaser.Geom.Rectangle; /** - * [description] + * Resets the position, width, and height of the Rectangle to 0. */ setEmpty(): Phaser.Geom.Rectangle; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the position of the Rectangle. + * @param x The X coordinate of the top left corner of the Rectangle. + * @param y The Y coordinate of the top left corner of the Rectangle. Default x. */ setPosition(x: number, y?: number): Phaser.Geom.Rectangle; /** - * [description] - * @param width [description] - * @param height [description] Default width. + * Sets the width and height of the Rectangle. + * @param width The width to set the Rectangle to. + * @param height The height to set the Rectangle to. Default width. */ setSize(width: number, height?: number): Phaser.Geom.Rectangle; /** - * [description] + * Determines if the Rectangle is empty. A Rectangle is empty if its width or height is less than or equal to 0. */ isEmpty(): boolean; @@ -25017,48 +37615,59 @@ declare namespace Phaser { getLineD(line?: O): O; /** - * [description] + * The x coordinate of the left of the Rectangle. + * Changing the left property of a Rectangle object has no effect on the y and height properties. However it does affect the width property, whereas changing the x value does not affect the width property. */ left: number; /** - * [description] + * The sum of the x and width properties. + * Changing the right property of a Rectangle object has no effect on the x, y and height properties, however it does affect the width property. */ right: number; /** - * [description] + * The y coordinate of the top of the Rectangle. Changing the top property of a Rectangle object has no effect on the x and width properties. + * However it does affect the height property, whereas changing the y value does not affect the height property. */ top: number; /** - * [description] + * The sum of the y and height properties. + * Changing the bottom property of a Rectangle object has no effect on the x, y and width properties, but does change the height property. */ bottom: number; /** - * [description] + * The x coordinate of the center of the Rectangle. */ centerX: number; /** - * [description] + * The y coordinate of the center of the Rectangle. */ centerY: number; /** - * [description] - * @param rect [description] - * @param x [description] - * @param y [description] + * Determines if the two objects (either Rectangles or Rectangle-like) have the same width and height values under strict equality. + * @param rect The first Rectangle object. + * @param toCompare The second Rectangle object. + */ + static SameDimensions(rect: Phaser.Geom.Rectangle, toCompare: Phaser.Geom.Rectangle): boolean; + + /** + * Scales the width and height of this Rectangle by the given amounts. + * @param rect The `Rectangle` object that will be scaled by the specified amount(s). + * @param x The factor by which to scale the rectangle horizontally. + * @param y The amount by which to scale the rectangle vertically. If this is not specified, the rectangle will be scaled by the factor `x` in both directions. */ static Scale(rect: O, x: number, y: number): O; /** - * [description] - * @param rectA [description] - * @param rectB [description] - * @param out [description] + * Creates a new Rectangle or repositions and/or resizes an existing Rectangle so that it encompasses the two given Rectangles, i.e. calculates their union. + * @param rectA The first Rectangle to use. + * @param rectB The second Rectangle to use. + * @param out The Rectangle to store the union in. */ static Union(rectA: Phaser.Geom.Rectangle, rectB: Phaser.Geom.Rectangle, out?: O): O; @@ -25072,26 +37681,27 @@ declare namespace Phaser { class Triangle { /** * - * @param x1 [description] Default 0. - * @param y1 [description] Default 0. - * @param x2 [description] Default 0. - * @param y2 [description] Default 0. - * @param x3 [description] Default 0. - * @param y3 [description] Default 0. + * @param x1 `x` coordinate of the first point. Default 0. + * @param y1 `y` coordinate of the first point. Default 0. + * @param x2 `x` coordinate of the second point. Default 0. + * @param y2 `y` coordinate of the second point. Default 0. + * @param x3 `x` coordinate of the third point. Default 0. + * @param y3 `y` coordinate of the third point. Default 0. */ constructor(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number); /** - * [description] - * @param triangle [description] + * Returns the area of a Triangle. + * @param triangle The Triangle to use. */ static Area(triangle: Phaser.Geom.Triangle): number; /** - * [description] - * @param x [description] - * @param y [description] - * @param length [description] + * Builds an equilateral triangle. In the equilateral triangle, all the sides are the same length (congruent) and all the angles are the same size (congruent). + * The x/y specifies the top-middle of the triangle (x1/y1) and length is the length of each side. + * @param x x coordinate of the top point of the triangle. + * @param y y coordinate of the top point of the triangle. + * @param length Length of each side of the triangle. */ static BuildEquilateral(x: number, y: number, length: number): Phaser.Geom.Triangle; @@ -25106,27 +37716,29 @@ declare namespace Phaser { static BuildFromPolygon(data: any[], holes?: any[], scaleX?: number, scaleY?: number, out?: O): O; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] + * Builds a right triangle, i.e. one which has a 90-degree angle and two acute angles. + * @param x The X coordinate of the right angle, which will also be the first X coordinate of the constructed Triangle. + * @param y The Y coordinate of the right angle, which will also be the first Y coordinate of the constructed Triangle. + * @param width The length of the side which is to the left or to the right of the right angle. + * @param height The length of the side which is above or below the right angle. */ static BuildRight(x: number, y: number, width: number, height: number): Phaser.Geom.Triangle; /** - * [description] - * @param triangle [description] - * @param x [description] - * @param y [description] - * @param centerFunc [description] + * Positions the Triangle so that it is centered on the given coordinates. + * @param triangle The triangle to be positioned. + * @param x The horizontal coordinate to center on. + * @param y The vertical coordinate to center on. + * @param centerFunc The function used to center the triangle. Defaults to Centroid centering. */ static CenterOn(triangle: O, x: number, y: number, centerFunc?: CenterFunction): O; /** - * [description] - * @param triangle [description] - * @param out [description] + * Calculates the position of a Triangle's centroid, which is also its center of mass (center of gravity). + * + * The centroid is the point in a Triangle at which its three medians (the lines drawn from the vertices to the bisectors of the opposite sides) meet. It divides each one in a 2:1 ratio. + * @param triangle The Triangle to use. + * @param out An object to store the coordinates in. */ static Centroid(triangle: Phaser.Geom.Triangle, out?: O): O; @@ -25142,97 +37754,98 @@ declare namespace Phaser { static CircumCenter(triangle: Phaser.Geom.Triangle, out?: O): O; /** - * [description] - * @param triangle [description] - * @param out [description] + * Finds the circumscribed circle (circumcircle) of a Triangle object. The circumcircle is the circle which touches all of the triangle's vertices. + * @param triangle The Triangle to use as input. + * @param out An optional Circle to store the result in. */ static CircumCircle(triangle: Phaser.Geom.Triangle, out?: O): O; /** - * [description] - * @param source [description] + * Clones a Triangle object. + * @param source The Triangle to clone. */ static Clone(source: Phaser.Geom.Triangle): Phaser.Geom.Triangle; /** - * [description] - * @param triangle [description] - * @param x [description] - * @param y [description] + * Checks if a point (as a pair of coordinates) is inside a Triangle's bounds. + * @param triangle The Triangle to check. + * @param x The X coordinate of the point to check. + * @param y The Y coordinate of the point to check. */ static Contains(triangle: Phaser.Geom.Triangle, x: number, y: number): boolean; /** - * [description] - * @param triangle [description] - * @param points [description] - * @param returnFirst [description] - * @param out [description] + * Filters an array of point-like objects to only those contained within a triangle. + * If `returnFirst` is true, will return an array containing only the first point in the provided array that is within the triangle (or an empty array if there are no such points). + * @param triangle The triangle that the points are being checked in. + * @param points An array of point-like objects (objects that have an `x` and `y` property) + * @param returnFirst If `true`, return an array containing only the first point found that is within the triangle. Default false. + * @param out If provided, the points that are within the triangle will be appended to this array instead of being added to a new array. If `returnFirst` is true, only the first point found within the triangle will be appended. This array will also be returned by this function. */ static ContainsArray(triangle: Phaser.Geom.Triangle, points: Phaser.Geom.Point[], returnFirst?: boolean, out?: any[]): Phaser.Geom.Point[]; /** - * [description] - * @param triangle [description] - * @param point [description] + * Tests if a triangle contains a point. + * @param triangle The triangle. + * @param point The point to test, or any point-like object with public `x` and `y` properties. */ - static ContainsPoint(triangle: Phaser.Geom.Triangle, point: Phaser.Geom.Point): boolean; + static ContainsPoint(triangle: Phaser.Geom.Triangle, point: Phaser.Geom.Point | Phaser.Math.Vector2 | any): boolean; /** - * [description] - * @param source [description] - * @param dest [description] + * Copy the values of one Triangle to a destination Triangle. + * @param source The source Triangle to copy the values from. + * @param dest The destination Triangle to copy the values to. */ static CopyFrom(source: Phaser.Geom.Triangle, dest: O): O; /** - * [description] - * @param triangle [description] - * @param out [description] + * Decomposes a Triangle into an array of its points. + * @param triangle The Triangle to decompose. + * @param out An array to store the points into. */ static Decompose(triangle: Phaser.Geom.Triangle, out?: any[]): any[]; /** - * [description] - * @param triangle [description] - * @param toCompare [description] + * Returns true if two triangles have the same coordinates. + * @param triangle The first triangle to check. + * @param toCompare The second triangle to check. */ static Equals(triangle: Phaser.Geom.Triangle, toCompare: Phaser.Geom.Triangle): boolean; /** - * [description] - * @param triangle [description] - * @param position [description] - * @param out [description] + * Returns a Point from around the perimeter of a Triangle. + * @param triangle The Triangle to get the point on its perimeter from. + * @param position The position along the perimeter of the triangle. A value between 0 and 1. + * @param out An option Point, or Point-like object to store the value in. If not given a new Point will be created. */ static GetPoint(triangle: Phaser.Geom.Triangle, position: number, out?: O): O; /** - * [description] - * @param triangle [description] - * @param quantity [description] - * @param stepRate [description] - * @param out [description] + * Returns an array of evenly spaced points on the perimeter of a Triangle. + * @param triangle The Triangle to get the points from. + * @param quantity The number of evenly spaced points to return. Set to 0 to return an arbitrary number of points based on the `stepRate`. + * @param stepRate If `quantity` is 0, the distance between each returned point. + * @param out An array to which the points should be appended. */ static GetPoints(triangle: Phaser.Geom.Triangle, quantity: integer, stepRate: number, out?: O): O; /** - * [description] - * @param triangle [description] - * @param out [description] + * Calculates the position of the incenter of a Triangle object. This is the point where its three angle bisectors meet and it's also the center of the incircle, which is the circle inscribed in the triangle. + * @param triangle The Triangle to find the incenter of. + * @param out An optional Point in which to store the coordinates. */ static InCenter(triangle: Phaser.Geom.Triangle, out?: O): O; /** - * [description] - * @param triangle [description] - * @param x [description] - * @param y [description] + * Moves each point (vertex) of a Triangle by a given offset, thus moving the entire Triangle by that offset. + * @param triangle The Triangle to move. + * @param x The horizontal offset (distance) by which to move each point. Can be positive or negative. + * @param y The vertical offset (distance) by which to move each point. Can be positive or negative. */ static Offset(triangle: O, x: number, y: number): O; /** - * [description] + * Gets the length of the perimeter of the given triangle. * @param triangle [description] */ static Perimeter(triangle: Phaser.Geom.Triangle): number; @@ -25245,95 +37858,95 @@ declare namespace Phaser { static Random(triangle: Phaser.Geom.Triangle, out?: O): O; /** - * [description] - * @param triangle [description] - * @param angle [description] + * Rotates a Triangle about its incenter, which is the point at which its three angle bisectors meet. + * @param triangle The Triangle to rotate. + * @param angle The angle by which to rotate the Triangle, in radians. */ static Rotate(triangle: O, angle: number): O; /** - * [description] - * @param triangle [description] - * @param point [description] - * @param angle [description] + * Rotates a Triangle at a certain angle about a given Point or object with public `x` and `y` properties. + * @param triangle The Triangle to rotate. + * @param point The Point to rotate the Triangle about. + * @param angle The angle by which to rotate the Triangle, in radians. */ static RotateAroundPoint(triangle: O, point: Phaser.Geom.Point, angle: number): O; /** - * [description] - * @param triangle [description] - * @param x [description] - * @param y [description] - * @param angle [description] + * Rotates an entire Triangle at a given angle about a specific point. + * @param triangle The Triangle to rotate. + * @param x The X coordinate of the point to rotate the Triangle about. + * @param y The Y coordinate of the point to rotate the Triangle about. + * @param angle The angle by which to rotate the Triangle, in radians. */ static RotateAroundXY(triangle: O, x: number, y: number, angle: number): O; /** - * [description] + * `x` coordinate of the first point. */ x1: number; /** - * [description] + * `y` coordinate of the first point. */ y1: number; /** - * [description] + * `x` coordinate of the second point. */ x2: number; /** - * [description] + * `y` coordinate of the second point. */ y2: number; /** - * [description] + * `x` coordinate of the third point. */ x3: number; /** - * [description] + * `y` coordinate of the third point. */ y3: number; /** - * [description] - * @param x [description] - * @param y [description] + * Checks whether a given points lies within the triangle. + * @param x The x coordinate of the point to check. + * @param y The y coordinate of the point to check. */ contains(x: number, y: number): boolean; /** - * [description] - * @param position [description] - * @param output [description] + * Returns a specific point on the triangle. + * @param position Position as float within `0` and `1`. `0` equals the first point. + * @param output Optional Point, or point-like object, that the calculated point will be written to. */ getPoint(position: number, output?: O): O; /** - * [description] - * @param quantity [description] - * @param stepRate [description] - * @param output [description] + * Calculates a list of evenly distributed points on the triangle. It is either possible to pass an amount of points to be generated (`quantity`) or the distance between two points (`stepRate`). + * @param quantity Number of points to be generated. Can be falsey when `stepRate` should be used. All points have the same distance along the triangle. + * @param stepRate Distance between two points. Will only be used when `quantity` is falsey. + * @param output Optional Array for writing the calculated points into. Otherwise a new array will be created. */ getPoints(quantity: integer, stepRate?: number, output?: O): O; /** - * [description] - * @param point [description] + * Returns a random point along the triangle. + * @param point Optional `Point` that should be modified. Otherwise a new one will be created. */ getRandomPoint(point?: O): O; /** - * [description] - * @param x1 [description] Default 0. - * @param y1 [description] Default 0. - * @param x2 [description] Default 0. - * @param y2 [description] Default 0. - * @param x3 [description] Default 0. - * @param y3 [description] Default 0. + * Sets all three points of the triangle. Leaving out any coordinate sets it to be `0`. + * @param x1 `x` coordinate of the first point. Default 0. + * @param y1 `y` coordinate of the first point. Default 0. + * @param x2 `x` coordinate of the second point. Default 0. + * @param y2 `y` coordinate of the second point. Default 0. + * @param x3 `x` coordinate of the third point. Default 0. + * @param y3 `y` coordinate of the third point. Default 0. */ setTo(x1?: number, y1?: number, x2?: number, y2?: number, x3?: number, y3?: number): Phaser.Geom.Triangle; @@ -25356,22 +37969,22 @@ declare namespace Phaser { getLineC(line?: O): O; /** - * [description] + * Left most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. */ left: number; /** - * [description] + * Right most X coordinate of the triangle. Setting it moves the triangle on the X axis accordingly. */ right: number; /** - * [description] + * Top most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. */ top: number; /** - * [description] + * Bottom most Y coordinate of the triangle. Setting it moves the triangle on the Y axis accordingly. */ bottom: number; @@ -25410,6 +38023,11 @@ declare namespace Phaser { */ var TOUCH_END: integer; + /** + * A touch pointer has been been cancelled by the browser. + */ + var TOUCH_CANCEL: integer; + /** * The pointer lock has changed. */ @@ -25503,6 +38121,657 @@ declare namespace Phaser { */ function CreatePixelPerfectHandler(textureManager: Phaser.Textures.TextureManager, alphaTolerance: integer): Function; + /** + * A Phaser Input Event Data object. + * + * This object is passed to the registered event listeners and allows you to stop any further propagation. + */ + type EventData = { + /** + * The cancelled state of this Event. + */ + cancelled?: boolean; + /** + * Call this method to stop this event from passing any further down the event chain. + */ + stopPropagation: Function; + }; + + namespace Events { + /** + * The Input Plugin Boot Event. + * + * This internal event is dispatched by the Input Plugin when it boots, signalling to all of its systems to create themselves. + */ + const BOOT: any; + + /** + * The Input Plugin Destroy Event. + * + * This internal event is dispatched by the Input Plugin when it is destroyed, signalling to all of its systems to destroy themselves. + */ + const DESTROY: any; + + /** + * The Pointer Drag End Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer stops dragging a Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('dragend', listener)`. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_END]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_END} event instead. + */ + const DRAG_END: any; + + /** + * The Pointer Drag Enter Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object into a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragenter', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_ENTER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_ENTER} event instead. + */ + const DRAG_ENTER: any; + + /** + * The Pointer Drag Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves while dragging a Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('drag', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG} event instead. + */ + const DRAG: any; + + /** + * The Pointer Drag Leave Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object out of a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('dragleave', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_LEAVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_LEAVE} event instead. + */ + const DRAG_LEAVE: any; + + /** + * The Pointer Drag Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drags a Game Object over a Drag Target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from within a Scene using: `this.input.on('dragover', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_OVER} event instead. + */ + const DRAG_OVER: any; + + /** + * The Pointer Drag Start Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer starts to drag any Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('dragstart', listener)`. + * + * A Pointer can only drag a single Game Object at once. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DRAG_START]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DRAG_START} event instead. + */ + const DRAG_START: any; + + /** + * The Pointer Drop Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer drops a Game Object on a Drag Target. + * + * Listen to this event from within a Scene using: `this.input.on('drop', listener)`. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_DROP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DROP} event instead. + */ + const DROP: any; + + /** + * The Game Object Down Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down on _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectdown', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_DOWN: any; + + /** + * The Game Object Drag End Event. + * + * This event is dispatched by an interactive Game Object if a pointer stops dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragend', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive](Phaser.GameObjects.GameObject#setInteractive) for more details. + */ + const GAMEOBJECT_DRAG_END: any; + + /** + * The Game Object Drag Enter Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it into a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragenter', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG_ENTER: any; + + /** + * The Game Object Drag Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves while dragging it. + * + * Listen to this event from a Game Object using: `gameObject.on('drag', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG: any; + + /** + * The Game Object Drag Leave Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it out of a drag target. + * + * Listen to this event from a Game Object using: `gameObject.on('dragleave', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG_LEAVE: any; + + /** + * The Game Object Drag Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer drags it over a drag target. + * + * When the Game Object first enters the drag target it will emit a `dragenter` event. If it then moves while within + * the drag target, it will emit this event instead. + * + * Listen to this event from a Game Object using: `gameObject.on('dragover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DRAG_OVER: any; + + /** + * The Game Object Drag Start Event. + * + * This event is dispatched by an interactive Game Object if a pointer starts to drag it. + * + * Listen to this event from a Game Object using: `gameObject.on('dragstart', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * There are lots of useful drag related properties that are set within the Game Object when dragging occurs. + * For example, `gameObject.input.dragStartX`, `dragStartY` and so on. + */ + const GAMEOBJECT_DRAG_START: any; + + /** + * The Game Object Drop Event. + * + * This event is dispatched by an interactive Game Object if a pointer drops it on a Drag Target. + * + * Listen to this event from a Game Object using: `gameObject.on('drop', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive and enabled for drag. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + */ + const GAMEOBJECT_DROP: any; + + /** + * The Game Object Move Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved across _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectmove', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_MOVE: any; + + /** + * The Game Object Out Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectout', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_OUT: any; + + /** + * The Game Object Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectover', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_OVER: any; + + /** + * The Game Object Pointer Down Event. + * + * This event is dispatched by an interactive Game Object if a pointer is pressed down on it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerdown', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_DOWN: any; + + /** + * The Game Object Pointer Move Event. + * + * This event is dispatched by an interactive Game Object if a pointer is moved while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointermove', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_MOVE: any; + + /** + * The Game Object Pointer Out Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves out of it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerout', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_OUT: any; + + /** + * The Game Object Pointer Over Event. + * + * This event is dispatched by an interactive Game Object if a pointer moves over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerover', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_OVER: any; + + /** + * The Game Object Pointer Up Event. + * + * This event is dispatched by an interactive Game Object if a pointer is released while over it. + * + * Listen to this event from a Game Object using: `gameObject.on('pointerup', listener)`. + * Note that the scope of the listener is automatically set to be the Game Object instance itself. + * + * To receive this event, the Game Object must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_POINTER_UP: any; + + /** + * The Game Object Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released while over _any_ interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('gameobjectup', listener)`. + * + * To receive this event, the Game Objects must have been set as interactive. + * See [GameObject.setInteractive]{@link Phaser.GameObjects.GameObject#setInteractive} for more details. + * + * To listen for this event from a _specific_ Game Object, use the [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} event instead. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const GAMEOBJECT_UP: any; + + /** + * The Input Plugin Game Out Event. + * + * This event is dispatched by the Input Plugin if the active pointer leaves the game canvas and is now + * outside of it, elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameout', listener)`. + */ + const GAME_OUT: any; + + /** + * The Input Plugin Game Over Event. + * + * This event is dispatched by the Input Plugin if the active pointer enters the game canvas and is now + * over of it, having previously been elsewhere on the web page. + * + * Listen to this event from within a Scene using: `this.input.on('gameover', listener)`. + */ + const GAME_OVER: any; + + /** + * The Input Manager Boot Event. + * + * This internal event is dispatched by the Input Manager when it boots. + */ + const MANAGER_BOOT: any; + + /** + * The Input Manager Process Event. + * + * This internal event is dispatched by the Input Manager when not using the legacy queue system, + * and it wants the Input Plugins to update themselves. + */ + const MANAGER_PROCESS: any; + + /** + * The Input Manager Update Event. + * + * This internal event is dispatched by the Input Manager as part of its update step. + */ + const MANAGER_UPDATE: any; + + /** + * The Input Manager Pointer Lock Change Event. + * + * This event is dispatched by the Input Manager when it is processing a native Pointer Lock Change DOM Event. + */ + const POINTERLOCK_CHANGE: any; + + /** + * The Pointer Down Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdown', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_DOWN: any; + + /** + * The Pointer Down Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is pressed down anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerdownoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_DOWN} + * 2. [GAMEOBJECT_DOWN]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_DOWN} + * 3. [POINTER_DOWN]{@linkcode Phaser.Input.Events#event:POINTER_DOWN} or [POINTER_DOWN_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_DOWN_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_DOWN_OUTSIDE: any; + + /** + * The Pointer Move Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is moved anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointermove', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_MOVE} + * 2. [GAMEOBJECT_MOVE]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_MOVE} + * 3. [POINTER_MOVE]{@linkcode Phaser.Input.Events#event:POINTER_MOVE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_MOVE: any; + + /** + * The Pointer Out Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves out of any interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OUT} + * 2. [GAMEOBJECT_OUT]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OUT} + * 3. [POINTER_OUT]{@linkcode Phaser.Input.Events#event:POINTER_OUT} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_OUT: any; + + /** + * The Pointer Over Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer moves over any interactive Game Object. + * + * Listen to this event from within a Scene using: `this.input.on('pointerover', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_OVER} + * 2. [GAMEOBJECT_OVER]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_OVER} + * 3. [POINTER_OVER]{@linkcode Phaser.Input.Events#event:POINTER_OVER} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_OVER: any; + + /** + * The Pointer Up Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere. + * + * Listen to this event from within a Scene using: `this.input.on('pointerup', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_UP: any; + + /** + * The Pointer Up Outside Input Event. + * + * This event is dispatched by the Input Plugin belonging to a Scene if a pointer is released anywhere outside of the game canvas. + * + * Listen to this event from within a Scene using: `this.input.on('pointerupoutside', listener)`. + * + * The event hierarchy is as follows: + * + * 1. [GAMEOBJECT_POINTER_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_POINTER_UP} + * 2. [GAMEOBJECT_UP]{@linkcode Phaser.Input.Events#event:GAMEOBJECT_UP} + * 3. [POINTER_UP]{@linkcode Phaser.Input.Events#event:POINTER_UP} or [POINTER_UP_OUTSIDE]{@linkcode Phaser.Input.Events#event:POINTER_UP_OUTSIDE} + * + * With the top event being dispatched first and then flowing down the list. Note that higher-up event handlers can stop + * the propagation of this event. + */ + const POINTER_UP_OUTSIDE: any; + + /** + * The Input Plugin Pre-Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `preUpdate` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + */ + const PRE_UPDATE: any; + + /** + * The Input Plugin Shutdown Event. + * + * This internal event is dispatched by the Input Plugin when it shuts down, signalling to all of its systems to shut themselves down. + */ + const SHUTDOWN: any; + + /** + * The Input Plugin Start Event. + * + * This internal event is dispatched by the Input Plugin when it has finished setting-up, + * signalling to all of its internal systems to start. + */ + const START: any; + + /** + * The Input Plugin Update Event. + * + * This internal event is dispatched by the Input Plugin at the start of its `update` method. + * This hook is designed specifically for input plugins, but can also be listened to from user-land code. + */ + const UPDATE: any; + + } + namespace Gamepad { /** * Contains information about a specific Gamepad Axis. @@ -25624,6 +38893,82 @@ declare namespace Phaser { } + namespace Events { + /** + * The Gamepad Button Down Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been pressed on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('down', listener)`. + * + * You can also listen for a DOWN event from a Gamepad instance. See the [GAMEPAD_BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_DOWN} event for details. + */ + const BUTTON_DOWN: any; + + /** + * The Gamepad Button Up Event. + * + * This event is dispatched by the Gamepad Plugin when a button has been released on any active Gamepad. + * + * Listen to this event from within a Scene using: `this.input.gamepad.on('up', listener)`. + * + * You can also listen for an UP event from a Gamepad instance. See the [GAMEPAD_BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:GAMEPAD_BUTTON_UP} event for details. + */ + const BUTTON_UP: any; + + /** + * The Gamepad Connected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been connected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('connected', listener)`. + * + * Note that the browser may require you to press a button on a gamepad before it will allow you to access it, + * this is for security reasons. However, it may also trust the page already, in which case you won't get the + * 'connected' event and instead should check `GamepadPlugin.total` to see if it thinks there are any gamepads + * already connected. + */ + const CONNECTED: any; + + /** + * The Gamepad Disconnected Event. + * + * This event is dispatched by the Gamepad Plugin when a Gamepad has been disconnected. + * + * Listen to this event from within a Scene using: `this.input.gamepad.once('disconnected', listener)`. + */ + const DISCONNECTED: any; + + /** + * The Gamepad Button Down Event. + * + * This event is dispatched by a Gamepad instance when a button has been pressed on it. + * + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('down', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for a DOWN event from the Gamepad Plugin. See the [BUTTON_DOWN]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_DOWN} event for details. + */ + const GAMEPAD_BUTTON_DOWN: any; + + /** + * The Gamepad Button Up Event. + * + * This event is dispatched by a Gamepad instance when a button has been released on it. + * + * Listen to this event from a Gamepad instance. Once way to get this is from the `pad1`, `pad2`, etc properties on the Gamepad Plugin: + * `this.input.gamepad.pad1.on('up', listener)`. + * + * Note that you will not receive any Gamepad button events until the browser considers the Gamepad as being 'connected'. + * + * You can also listen for an UP event from the Gamepad Plugin. See the [BUTTON_UP]{@linkcode Phaser.Input.Gamepad.Events#event:BUTTON_UP} event for details. + */ + const GAMEPAD_BUTTON_UP: any; + + } + /** * A single Gamepad. * @@ -26021,15 +39366,21 @@ declare namespace Phaser { */ readonly game: Phaser.Game; + /** + * A reference to the global Game Scale Manager. + * Used for all bounds checks and pointer scaling. + */ + scaleManager: Phaser.Scale.ScaleManager; + /** * The Canvas that is used for all DOM event input listeners. */ canvas: HTMLCanvasElement; /** - * The Input Configuration object, as set in the Game Config. + * The Game Configuration object, as set during the game boot. */ - config: object; + config: Phaser.Core.Config; /** * If set, the Input Manager will run its update loop every frame. @@ -26046,6 +39397,12 @@ declare namespace Phaser { */ queue: any[]; + /** + * Are any mouse or touch pointers currently over the game canvas? + * This is updated automatically by the canvas over and out handlers. + */ + readonly isOver: boolean; + /** * The default CSS cursor to be used when interacting with your game. * @@ -26053,6 +39410,11 @@ declare namespace Phaser { */ defaultCursor: string; + /** + * A reference to the Keyboard Manager class, if enabled via the `input.keyboard` Game Config property. + */ + keyboard: Phaser.Input.Keyboard.KeyboardManager; + /** * A reference to the Mouse Manager class, if enabled via the `input.mouse` Game Config property. */ @@ -26102,11 +39464,6 @@ declare namespace Phaser { */ dirty: boolean; - /** - * The Scale factor being applied to input coordinates. - */ - scale: Object; - /** * If the top-most Scene in the Scene List receives an input it will stop input from * propagating any lower down the scene list, i.e. if you have a UI Scene at the top @@ -26122,9 +39479,23 @@ declare namespace Phaser { ignoreEvents: boolean; /** - * The bounds of the Input Manager, used for pointer hit test calculations. + * Use the internal event queue or not? + * + * Set this via the Game Config with the `inputQueue` property. + * + * Phaser 3.15.1 and earlier used a event queue by default. + * + * This was changed in version 3.16 to use an immediate-mode system. + * The previous queue based version remains and is left under this flag for backwards + * compatibility. This flag, along with the legacy system, will be removed in a future version. */ - bounds: Phaser.Geom.Rectangle; + useQueue: boolean; + + /** + * The time this Input Manager was last updated. + * This value is populated by the Game Step each frame. + */ + readonly time: number; /** * The Boot handler is called by Phaser.Game when it first starts up. @@ -26132,17 +39503,6 @@ declare namespace Phaser { */ protected boot(): void; - /** - * Updates the Input Manager bounds rectangle to match the bounding client rectangle of the - * canvas element being used to track input events. - */ - updateBounds(): void; - - /** - * Resizes the Input Manager internal values, including the bounds and scale factor. - */ - resize(): void; - /** * Tells the Input system to set a custom cursor. * @@ -26181,6 +39541,19 @@ declare namespace Phaser { addPointer(quantity?: integer): Phaser.Input.Pointer[]; /** + * Internal method that gets a list of all the active Input Plugins in the game + * and updates each of them in turn, in reverse order (top to bottom), to allow + * for DOM top-level event handling simulation. + * @param time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). + * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. + */ + updateInputPlugins(time: number, delta: number): void; + + /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. * By setting the `isOnce` argument you can control if the callback is called once, * or every time the DOM event occurs. @@ -26207,6 +39580,10 @@ declare namespace Phaser { addUpCallback(callback: Function, isOnce?: boolean): this; /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. * By setting the `isOnce` argument you can control if the callback is called once, * or every time the DOM event occurs. @@ -26233,6 +39610,10 @@ declare namespace Phaser { addDownCallback(callback: Function, isOnce?: boolean): this; /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. * By setting the `isOnce` argument you can control if the callback is called once, * or every time the DOM event occurs. @@ -26301,40 +39682,11 @@ declare namespace Phaser { /** * Transforms the pageX and pageY values of a Pointer into the scaled coordinate space of the Input Manager. * @param pointer The Pointer to transform the values for. + * @param pageX The Page X value. + * @param pageY The Page Y value. + * @param wasMove Are we transforming the Pointer from a move event, or an up / down event? */ - transformPointer(pointer: Phaser.Input.Pointer): number; - - /** - * Transforms the pageX value into the scaled coordinate space of the Input Manager. - * @param pageX The DOM pageX value. - */ - transformX(pageX: number): number; - - /** - * Transforms the pageY value into the scaled coordinate space of the Input Manager. - * @param pageY The DOM pageY value. - */ - transformY(pageY: number): number; - - /** - * Returns the left offset of the Input bounds. - */ - getOffsetX(): number; - - /** - * Returns the top offset of the Input bounds. - */ - getOffsetY(): number; - - /** - * Returns the horizontal Input Scale value. - */ - getScaleX(): number; - - /** - * Returns the vertical Input Scale value. - */ - getScaleY(): number; + transformPointer(pointer: Phaser.Input.Pointer, pageX: number, pageY: number, wasMove: boolean): void; /** * Destroys the Input Manager and all of its systems. @@ -26515,6 +39867,37 @@ declare namespace Phaser { */ hitTestPointer(pointer: Phaser.Input.Pointer): Phaser.GameObjects.GameObject[]; + /** + * Returns the drag state of the given Pointer for this Input Plugin. + * + * The state will be one of the following: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * @param pointer The Pointer to get the drag state for. + */ + getDragState(pointer: Phaser.Input.Pointer): integer; + + /** + * Sets the drag state of the given Pointer for this Input Plugin. + * + * The state must be one of the following values: + * + * 0 = Not dragging anything + * 1 = Primary button down and objects below, so collect a draglist + * 2 = Pointer being checked if meets drag criteria + * 3 = Pointer meets criteria, notify the draglist + * 4 = Pointer actively dragging the draglist and has moved + * 5 = Pointer actively dragging but has been released, notify draglist + * @param pointer The Pointer to set the drag state for. + * @param state The drag state value. An integer between 0 and 5. + */ + setDragState(pointer: Phaser.Input.Pointer, state: integer): void; + /** * Sets the draggable state of the given array of Game Objects. * @@ -26688,6 +40071,10 @@ declare namespace Phaser { stopPropagation(): Phaser.Input.InputPlugin; /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * * Adds a callback to be invoked whenever the native DOM `mouseup` or `touchend` events are received. * By setting the `isOnce` argument you can control if the callback is called once, * or every time the DOM event occurs. @@ -26714,6 +40101,10 @@ declare namespace Phaser { addUpCallback(callback: Function, isOnce?: boolean): this; /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * * Adds a callback to be invoked whenever the native DOM `mousedown` or `touchstart` events are received. * By setting the `isOnce` argument you can control if the callback is called once, * or every time the DOM event occurs. @@ -26740,6 +40131,10 @@ declare namespace Phaser { addDownCallback(callback: Function, isOnce?: boolean): this; /** + * **Note:** As of Phaser 3.16 this method is no longer required _unless_ you have set `input.queue = true` + * in your game config, to force it to use the legacy event queue system. This method is deprecated and + * will be removed in a future version. + * * Adds a callback to be invoked whenever the native DOM `mousemove` or `touchmove` events are received. * By setting the `isOnce` argument you can control if the callback is called once, * or every time the DOM event occurs. @@ -26814,6 +40209,11 @@ declare namespace Phaser { */ readonly y: number; + /** + * Are any mouse or touch pointers currently over the game canvas? + */ + readonly isOver: boolean; + /** * The mouse has its own unique Pointer object, which you can reference directly if making a _desktop specific game_. * If you are supporting both desktop and touch devices then do not use this property, instead use `activePointer` @@ -26929,6 +40329,32 @@ declare namespace Phaser { alphaTolerance?: integer; }; + namespace InputPluginCache { + /** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + */ + var register: Function; + + /** + * Returns the input plugin object from the cache based on the given key. + */ + var getCore: Function; + + /** + * Installs all of the registered Input Plugins into the given target. + */ + var install: Function; + + /** + * Removes an input plugin based on the given key. + */ + var remove: Function; + + } + namespace Keyboard { /** * A KeyCombo will listen for a specific string of keys from the Keyboard, and when it receives them @@ -26940,11 +40366,11 @@ declare namespace Phaser { * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -27043,6 +40469,309 @@ declare namespace Phaser { } + namespace Events { + /** + * The Global Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keydown', listener)`. + * + * You can also listen for a specific key being pressed. See [Keyboard.Events.KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + */ + const ANY_KEY_DOWN: any; + + /** + * The Global Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Listen to this event from within a Scene using: `this.input.keyboard.on('keyup', listener)`. + * + * You can also listen for a specific key being released. See [Keyboard.Events.KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + */ + const ANY_KEY_UP: any; + + /** + * The Key Combo Match Event. + * + * This event is dispatched by the Keyboard Plugin when a [Key Combo]{@link Phaser.Input.Keyboard.KeyCombo} is matched. + * + * Listen for this event from the Key Plugin after a combo has been created: + * + * ```javascript + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); + * + * this.input.keyboard.on('keycombomatch', function (event) { + * console.log('Konami Code entered!'); + * }); + * ``` + */ + const COMBO_MATCH: any; + + /** + * The Key Down Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is pressed. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('down', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + */ + const DOWN: any; + + /** + * The Key Down Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is pressed down. + * + * Unlike the `ANY_KEY_DOWN` event, this one has a special dynamic event name. For example, to listen for the `A` key being pressed + * use the following from within a Scene: `this.input.keyboard.on('keydown-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keydown-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_DOWN} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.DOWN]{@linkcode Phaser.Input.Keyboard.Events#event:DOWN} for details. + * + * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. + * Read [this article on ghosting]{@link http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/} for details. + * + * Also, please be aware that some browser extensions can disable or override Phaser keyboard handling. + * For example, the Chrome extension vimium is known to disable Phaser from using the D key, while EverNote disables the backtick key. + * There are others. So, please check your extensions if you find you have specific keys that don't work. + */ + const KEY_DOWN: any; + + /** + * The Key Up Event. + * + * This event is dispatched by the Keyboard Plugin when any key on the keyboard is released. + * + * Unlike the `ANY_KEY_UP` event, this one has a special dynamic event name. For example, to listen for the `A` key being released + * use the following from within a Scene: `this.input.keyboard.on('keyup-A', listener)`. You can replace the `-A` part of the event + * name with any valid [Key Code string]{@link Phaser.Input.Keyboard.KeyCodes}. For example, this will listen for the space bar: + * `this.input.keyboard.on('keyup-SPACE', listener)`. + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + * + * Finally, you can create Key objects, which you can also listen for events from. See [Keyboard.Events.UP]{@linkcode Phaser.Input.Keyboard.Events#event:UP} for details. + */ + const KEY_UP: any; + + /** + * The Key Up Event. + * + * This event is dispatched by a [Key]{@link Phaser.Input.Keyboard.Key} object when it is released. + * + * Listen for this event from the Key object instance directly: + * + * ```javascript + * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); + * + * spaceBar.on('up', listener) + * ``` + * + * You can also create a generic 'global' listener. See [Keyboard.Events.ANY_KEY_UP]{@linkcode Phaser.Input.Keyboard.Events#event:ANY_KEY_UP} for details. + */ + const UP: any; + + } + + /** + * The Keyboard Manager is a helper class that belongs to the global Input Manager. + * + * Its role is to listen for native DOM Keyboard Events and then store them for further processing by the Keyboard Plugin. + * + * You do not need to create this class directly, the Input Manager will create an instance of it automatically if keyboard + * input has been enabled in the Game Config. + */ + class KeyboardManager { + /** + * + * @param inputManager A reference to the Input Manager. + */ + constructor(inputManager: Phaser.Input.InputManager); + + /** + * A reference to the Input Manager. + */ + manager: Phaser.Input.InputManager; + + /** + * A flag that controls if the non-modified keys, matching those stored in the `captures` array, + * have `preventDefault` called on them or not. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle this property at run-time. + */ + preventDefault: boolean; + + /** + * An array of Key Code values that will automatically have `preventDefault` called on them, + * as long as the `KeyboardManager.preventDefault` boolean is set to `true`. + * + * By default the array is empty. + * + * The key must be non-modified when pressed in order to be captured. + * + * A non-modified key is one that doesn't have a modifier key held down with it. The modifier keys are + * shift, control, alt and the meta key (Command on a Mac, the Windows Key on Windows). + * Therefore, if the user presses shift + r, it won't prevent this combination, because of the modifier. + * However, if the user presses just the r key on its own, it will have its event prevented. + * + * If you wish to stop capturing the keys, for example switching out to a DOM based element, then + * you can toggle the `KeyboardManager.preventDefault` boolean at run-time. + * + * If you need more specific control, you can create Key objects and set the flag on each of those instead. + * + * This array can be populated via the Game Config by setting the `input.keyboard.capture` array, or you + * can call the `addCapture` method. See also `removeCapture` and `clearCaptures`. + */ + captures: integer[]; + + /** + * A boolean that controls if the Keyboard Manager is enabled or not. + * Can be toggled on the fly. + */ + enabled: boolean; + + /** + * The Keyboard Event target, as defined in the Game Config. + * Typically the window in which the game is rendering, but can be any interactive DOM element. + */ + target: any; + + /** + * The Key Down Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + */ + onKeyDown: Function; + + /** + * The Key Up Event handler. + * This function is sent the native DOM KeyEvent. + * Initially empty and bound in the `startListeners` method. + */ + onKeyUp: Function; + + /** + * Starts the Keyboard Event listeners running. + * This is called automatically and does not need to be manually invoked. + */ + startListeners(): void; + + /** + * Stops the Key Event listeners. + * This is called automatically and does not need to be manually invoked. + */ + stopListeners(): void; + + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard event for specific keys so it doesn't bubble up to the the browser + * and cause the default browser behavior. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are active captures after calling this method, the `preventDefault` property is set to `true`. + * @param keycode The Key Codes to enable capture for, preventing them reaching the browser. + */ + addCapture(keycode: string | integer | integer[] | any[]): void; + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass in a single key code value, or an array of key codes, or a string: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or a string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * + * If there are no captures left after calling this method, the `preventDefault` property is set to `false`. + * @param keycode The Key Codes to disable capture for, allowing them reaching the browser again. + */ + removeCapture(keycode: string | integer | integer[] | any[]): void; + + /** + * Removes all keyboard captures and sets the `preventDefault` property to `false`. + */ + clearCaptures(): void; + + /** + * Destroys this Keyboard Manager instance. + */ + destroy(): void; + + } + /** * The Keyboard Plugin is an input plugin that belongs to the Scene-owned Input system. * @@ -27059,7 +40788,7 @@ declare namespace Phaser { * Or, to listen for a specific key: * * ```javascript - * this.input.keyboard.on('keydown_A', callback, context); + * this.input.keyboard.on('keydown-A', callback, context); * ``` * * You can also create Key objects, which you can then poll in your game loop: @@ -27068,6 +40797,10 @@ declare namespace Phaser { * var spaceBar = this.input.keyboard.addKey(Phaser.Input.Keyboard.KeyCodes.SPACE); * ``` * + * If you have multiple parallel Scenes, each trying to get keyboard input, be sure to disable capture on them to stop them from + * stealing input from another Scene in the list. You can do this with `this.input.keyboard.enabled = false` within the + * Scene to stop all input, or `this.input.keyboard.preventDefault = false` to stop a Scene halting input on another Scene. + * * _Note_: Many keyboards are unable to process certain combinations of keys due to hardware limitations known as ghosting. * See http://www.html5gamedevs.com/topic/4876-impossible-to-use-more-than-2-keyboard-input-buttons-at-the-same-time/ for more details. * @@ -27082,6 +40815,11 @@ declare namespace Phaser { */ constructor(sceneInputPlugin: Phaser.Input.InputPlugin); + /** + * A reference to the core game, so we can listen for visibility events. + */ + game: Phaser.Game; + /** * A reference to the Scene that this Input Plugin is responsible for. */ @@ -27098,17 +40836,16 @@ declare namespace Phaser { sceneInputPlugin: Phaser.Input.InputPlugin; /** - * A boolean that controls if the Keyboard Plugin is enabled or not. + * A reference to the global Keyboard Manager. + */ + manager: Phaser.Input.InputPlugin; + + /** + * A boolean that controls if this Keyboard Plugin is enabled or not. * Can be toggled on the fly. */ enabled: boolean; - /** - * The Keyboard Event target, as defined in the Scene or Game Config. - * Typically the browser window, but can be any interactive DOM element. - */ - target: any; - /** * An array of Key objects to process. */ @@ -27124,6 +40861,96 @@ declare namespace Phaser { */ isActive(): boolean; + /** + * By default when a key is pressed Phaser will not stop the event from propagating up to the browser. + * There are some keys this can be annoying for, like the arrow keys or space bar, which make the browser window scroll. + * + * This `addCapture` method enables consuming keyboard events for specific keys, so they don't bubble up the browser + * and cause the default behaviors. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to say prevent + * the SPACE BAR from triggering a page scroll, then it will prevent it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.addCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.addCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.addCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * @param keycode The Key Codes to enable event capture for. + */ + addCapture(keycode: string | integer | integer[] | any[]): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Removes an existing key capture. + * + * Please note that keyboard captures are global. This means that if you call this method from within a Scene, to remove + * the capture of a key, then it will remove it for any Scene in your game, not just the calling one. + * + * You can pass a single key code value: + * + * ```javascript + * this.input.keyboard.removeCapture(62); + * ``` + * + * An array of key codes: + * + * ```javascript + * this.input.keyboard.removeCapture([ 62, 63, 64 ]); + * ``` + * + * Or, a comma-delimited string: + * + * ```javascript + * this.input.keyboard.removeCapture('W,S,A,D'); + * ``` + * + * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. + * + * You can also provide an array mixing both strings and key code integers. + * @param keycode The Key Codes to disable event capture for. + */ + removeCapture(keycode: string | integer | integer[] | any[]): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Returns an array that contains all of the keyboard captures currently enabled. + */ + getCaptures(): integer[]; + + /** + * Allows Phaser to prevent any key captures you may have defined from bubbling up the browser. + * You can use this to re-enable event capturing if you had paused it via `disableGlobalCapture`. + */ + enableGlobalCapture(): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Disables Phaser from preventing any key captures you may have defined, without actually removing them. + * You can use this to temporarily disable event capturing if, for example, you swap to a DOM element. + */ + disableGlobalCapture(): Phaser.Input.Keyboard.KeyboardPlugin; + + /** + * Removes all keyboard captures. + * + * Note that this is a global change. It will clear all event captures across your game, not just for this specific Scene. + */ + clearCaptures(): Phaser.Input.Keyboard.KeyboardPlugin; + /** * Creates and returns an object containing 4 hotkeys for Up, Down, Left and Right, and also Space Bar and shift. */ @@ -27150,8 +40977,10 @@ declare namespace Phaser { * * To use non-alpha numeric keys, use a string, such as 'UP', 'SPACE' or 'LEFT'. * @param keys An object containing Key Codes, or a comma-separated string. + * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. + * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. */ - addKeys(keys: object | string): object; + addKeys(keys: object | string, enableCapture?: boolean, emitOnRepeat?: boolean): object; /** * Adds a Key object to this Keyboard Plugin. @@ -27160,8 +40989,10 @@ declare namespace Phaser { * * If a Key object is given, and one already exists matching the same key code, the existing one is replaced with the new one. * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. + * @param enableCapture Automatically call `preventDefault` on the native DOM browser event for the key codes being added. Default true. + * @param emitOnRepeat Controls if the Key will continuously emit a 'down' event while being held down (true), or emit the event just once (false, the default). Default false. */ - addKey(key: Phaser.Input.Keyboard.Key | string | integer): Phaser.Input.Keyboard.Key; + addKey(key: Phaser.Input.Keyboard.Key | string | integer, enableCapture?: boolean, emitOnRepeat?: boolean): Phaser.Input.Keyboard.Key; /** * Removes a Key object from this Keyboard Plugin. @@ -27169,7 +41000,7 @@ declare namespace Phaser { * The given argument can be either a Key object, a string, such as `A` or `SPACE`, or a key code value. * @param key Either a Key object, a string, such as `A` or `SPACE`, or a key code value. */ - removeKey(key: Phaser.Input.Keyboard.Key | string | integer): void; + removeKey(key: Phaser.Input.Keyboard.Key | string | integer): Phaser.Input.Keyboard.KeyboardPlugin; /** * Creates a new KeyCombo. @@ -27183,11 +41014,11 @@ declare namespace Phaser { * An array of either integers (key codes) or strings, or a mixture of both * An array of objects (such as Key objects) with a public 'keyCode' property * - * For example, to listen for the Konami code (up, up, up, down, down, down, left, left, left, right, right, right) + * For example, to listen for the Konami code (up, up, down, down, left, right, left, right, b, a, enter) * you could pass the following array of key codes: * * ```javascript - * this.input.keyboard.createCombo([ 38, 38, 38, 40, 40, 40, 37, 37, 37, 39, 39, 39 ], { resetOnMatch: true }); + * this.input.keyboard.createCombo([ 38, 38, 40, 40, 37, 39, 37, 39, 66, 65, 13 ], { resetOnMatch: true }); * * this.input.keyboard.on('keycombomatch', function (event) { * console.log('Konami Code entered!'); @@ -27204,8 +41035,59 @@ declare namespace Phaser { */ createCombo(keys: string | integer[] | object[], config?: KeyComboConfig): Phaser.Input.Keyboard.KeyCombo; + /** + * Checks if the given Key object is currently being held down. + * + * The difference between this method and checking the `Key.isDown` property directly is that you can provide + * a duration to this method. For example, if you wanted a key press to fire a bullet, but you only wanted + * it to be able to fire every 100ms, then you can call this method with a `duration` of 100 and it + * will only return `true` every 100ms. + * + * If the Keyboard Plugin has been disabled, this method will always return `false`. + * @param key A Key object. + * @param duration The duration which must have elapsed before this Key is considered as being down. Default 0. + */ + checkDown(key: Phaser.Input.Keyboard.Key, duration?: number): boolean; + + /** + * Resets all Key objects created by _this_ Keyboard Plugin back to their default un-pressed states. + * This can only reset keys created via the `addKey`, `addKeys` or `createCursorKeys` methods. + * If you have created a Key object directly you'll need to reset it yourself. + * + * This method is called automatically when the Keyboard Plugin shuts down, but can be + * invoked directly at any time you require. + */ + resetKeys(): Phaser.Input.Keyboard.KeyboardPlugin; + } + type CursorKeys = { + /** + * A Key object mapping to the UP arrow key. + */ + up?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the DOWN arrow key. + */ + down?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the LEFT arrow key. + */ + left?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the RIGHT arrow key. + */ + right?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the SPACE BAR key. + */ + space?: Phaser.Input.Keyboard.Key; + /** + * A Key object mapping to the SHIFT key. + */ + shift?: Phaser.Input.Keyboard.Key; + }; + /** * Returns `true` if the Key was pressed down within the `duration` value given, or `false` if it either isn't down, * or was pressed down longer ago than then given duration. @@ -27240,7 +41122,7 @@ declare namespace Phaser { * A generic Key object which can be passed to the Process functions (and so on) * keycode must be an integer */ - class Key { + class Key extends Phaser.Events.EventEmitter { /** * * @param keyCode The keycode of this key. @@ -27257,11 +41139,6 @@ declare namespace Phaser { */ originalEvent: KeyboardEvent; - /** - * Should this Key prevent event propagation? - */ - preventDefault: boolean; - /** * Can this Key be processed? */ @@ -27292,6 +41169,12 @@ declare namespace Phaser { */ shiftKey: boolean; + /** + * The down state of the Meta key, if pressed at the same time as this key. + * On a Mac the Meta Key is the Command key. On Windows keyboards, it's the Windows key. + */ + metaKey: boolean; + /** * The location of the modifier key. 0 for standard (or unknown), 1 for left, 2 for right, 3 for numpad. */ @@ -27303,9 +41186,7 @@ declare namespace Phaser { timeDown: number; /** - * The number of milliseconds this key has been held down for. - * If the key is down this value holds the duration of that key press and is constantly updated. - * If the key is up it holds the duration of the previous down session. + * The number of milliseconds this key was held down for in the previous down - up sequence. */ duration: number; @@ -27314,15 +41195,49 @@ declare namespace Phaser { */ timeUp: number; + /** + * When a key is held down should it continuously fire the `down` event each time it repeats? + * + * By default it will emit the `down` event just once, but if you wish to receive the event + * for each repeat as well, enable this property. + */ + emitOnRepeat: boolean; + /** * If a key is held down this holds down the number of times the key has 'repeated'. */ repeats: number; + /** + * Controls if this Key will continuously emit a `down` event while being held down (true), + * or emit the event just once, on first press, and then skip future events (false). + * @param value Emit `down` events on repeated key down actions, or just once? + */ + setEmitOnRepeat(value: boolean): Phaser.Input.Keyboard.Key; + + /** + * Processes the Key Down action for this Key. + * Called automatically by the Keyboard Plugin. + * @param event The native DOM Keyboard event. + */ + onDown(event: KeyboardEvent): void; + + /** + * Processes the Key Up action for this Key. + * Called automatically by the Keyboard Plugin. + * @param event The native DOM Keyboard event. + */ + onUp(event: KeyboardEvent): void; + /** * Resets this Key object back to its default un-pressed state. */ - static reset(): Phaser.Input.Keyboard.Key; + reset(): Phaser.Input.Keyboard.Key; + + /** + * Removes any bound event handlers and removes local references. + */ + destroy(): void; } @@ -27420,6 +41335,12 @@ declare namespace Phaser { BACKTICK, OPEN_BRACKET, CLOSED_BRACKET, + SEMICOLON_FIREFOX, + COLON, + COMMA_FIREFOX_WINDOWS, + COMMA_FIREFOX, + BRACKET_RIGHT_FIREFOX, + BRACKET_LEFT_FIREFOX, } /** @@ -27474,6 +41395,48 @@ declare namespace Phaser { */ locked: boolean; + /** + * The Mouse Move Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseMove: Function; + + /** + * The Mouse Down Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseDown: Function; + + /** + * The Mouse Up Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseUp: Function; + + /** + * The Mouse Over Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseOver: Function; + + /** + * The Mouse Out Event handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + onMouseOut: Function; + + /** + * Internal pointerLockChange handler. + * This function is sent the native DOM MouseEvent. + * Initially empty and bound in the `startListeners` method. + */ + pointerLockChange: Function; + /** * Attempts to disable the context menu from appearing if you right-click on the browser. * @@ -27498,12 +41461,6 @@ declare namespace Phaser { */ requestPointerLock(): void; - /** - * Internal pointerLockChange handler. - * @param event The native event from the browser. - */ - pointerLockChange(event: MouseEvent): void; - /** * If the browser supports pointer lock, this will request that the pointer lock is released. If * the browser successfully enters a locked state, a 'POINTER_LOCK_CHANGE_EVENT' will be @@ -27511,24 +41468,6 @@ declare namespace Phaser { */ releasePointerLock(): void; - /** - * The Mouse Move Event Handler. - * @param event The native DOM Mouse Move Event. - */ - onMouseMove(event: MouseEvent): void; - - /** - * The Mouse Down Event Handler. - * @param event The native DOM Mouse Down Event. - */ - onMouseDown(event: MouseEvent): void; - - /** - * The Mouse Up Event Handler. - * @param event The native DOM Mouse Up Event. - */ - onMouseUp(event: MouseEvent): void; - /** * Starts the Mouse Event listeners running. * This is called automatically and does not need to be manually invoked. @@ -27587,6 +41526,16 @@ declare namespace Phaser { */ event: TouchEvent | MouseEvent; + /** + * The DOM element the Pointer was pressed down on, taken from the DOM event. + */ + readonly downElement: any; + + /** + * The DOM element the Pointer was released on, taken from the DOM event. + */ + readonly upElement: any; + /** * The camera the Pointer interacted with during its last update. * @@ -27611,7 +41560,75 @@ declare namespace Phaser { /** * The position of the Pointer in screen space. */ - position: Phaser.Math.Vector2; + readonly position: Phaser.Math.Vector2; + + /** + * The previous position of the Pointer in screen space. + * + * The old x and y values are stored in here during the InputManager.transformPointer call. + * + * Use the properties `velocity`, `angle` and `distance` to create your own gesture recognition. + */ + readonly prevPosition: Phaser.Math.Vector2; + + /** + * The current velocity of the Pointer, based on its current and previous positions. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + */ + readonly velocity: Phaser.Math.Vector2; + + /** + * The current angle the Pointer is moving, in radians, based on its previous and current position. + * + * The angle is based on the old position facing to the current position. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + */ + readonly angle: number; + + /** + * The distance the Pointer has moved, based on its previous and current position. + * + * This value is smoothed out each frame, according to the `motionFactor` property. + * + * This property is updated whenever the Pointer moves, regardless of any button states. In other words, + * it changes based on movement alone - a button doesn't have to be pressed first. + * + * If you need the total distance travelled since the primary buttons was pressed down, + * then use the `Pointer.getDistance` method. + */ + readonly distance: number; + + /** + * The smoothing factor to apply to the Pointer position. + * + * Due to their nature, pointer positions are inherently noisy. While this is fine for lots of games, if you need cleaner positions + * then you can set this value to apply an automatic smoothing to the positions as they are recorded. + * + * The default value of zero means 'no smoothing'. + * Set to a small value, such as 0.2, to apply an average level of smoothing between positions. You can do this by changing this + * value directly, or by setting the `input.smoothFactor` property in the Game Config. + * + * Positions are only smoothed when the pointer moves. If the primary button on this Pointer enters an Up or Down state, then the position + * is always precise, and not smoothed. + */ + smoothFactor: number; + + /** + * The factor applied to the motion smoothing each frame. + * + * This value is passed to the Smooth Step Interpolation that is used to calculate the velocity, + * angle and distance of the Pointer. It's applied every frame, until the midPoint reaches the current + * position of the Pointer. 0.2 provides a good average but can be increased if you need a + * quicker update and are working in a high performance environment. Never set this value to + * zero. + */ + motionFactor: number; /** * The x position of this Pointer, translated into the coordinate space of the most recent Camera it interacted with. @@ -27623,6 +41640,11 @@ declare namespace Phaser { */ worldY: number; + /** + * Time when this Pointer was most recently moved (regardless of the state of its buttons, if any) + */ + moveTime: number; + /** * X coordinate of the Pointer when Button 1 (left button), or Touch, was pressed, used for dragging objects. */ @@ -27658,15 +41680,6 @@ declare namespace Phaser { */ primaryDown: boolean; - /** - * The Drag State of the Pointer: - * - * 0 = Not dragging anything - * 1 = Being checked if dragging - * 2 = Dragging something - */ - dragState: number; - /** * Is _any_ button on this pointer considered as being down? */ @@ -27697,6 +41710,13 @@ declare namespace Phaser { */ wasTouch: boolean; + /** + * Did this Pointer get canceled by a touchcancel event? + * + * Note: "canceled" is the American-English spelling of "cancelled". Please don't submit PRs correcting it! + */ + wasCanceled: boolean; + /** * If the mouse is locked, the horizontal relative movement of the Pointer in pixels since last frame. */ @@ -27724,6 +41744,11 @@ declare namespace Phaser { */ active: boolean; + /** + * Time when this Pointer was most recently updated by the Game step. + */ + time: number; + /** * Takes a Camera and returns a Vector2 containing the translated position of this Pointer * within that Camera. This can be used to convert this Pointers position into camera space. @@ -27762,6 +41787,85 @@ declare namespace Phaser { */ forwardButtonDown(): boolean; + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded distance, based on where + * the Pointer was when the button was released. + * + * If you wish to get the distance being travelled currently, based on the velocity of the Pointer, + * then see the `Pointer.distance` property. + */ + getDistance(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * horizontal distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded horizontal distance, based on where + * the Pointer was when the button was released. + */ + getDistanceX(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * vertical distance between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded vertical distance, based on where + * the Pointer was when the button was released. + */ + getDistanceY(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * duration since the Pointer's was pressed down. + * + * If no button is held down, it will return the last recorded duration, based on the time + * the Pointer button was released. + */ + getDuration(): number; + + /** + * If the Pointer has a button pressed down at the time this method is called, it will return the + * angle between the Pointer's `downX` and `downY` values and the current position. + * + * If no button is held down, it will return the last recorded angle, based on where + * the Pointer was when the button was released. + * + * The angle is based on the old position facing to the current position. + * + * If you wish to get the current angle, based on the velocity of the Pointer, then + * see the `Pointer.angle` property. + */ + getAngle(): number; + + /** + * Takes the previous and current Pointer positions and then generates an array of interpolated values between + * the two. The array will be populated up to the size of the `steps` argument. + * + * ```javaScript + * var points = pointer.getInterpolatedPosition(4); + * + * // points[0] = { x: 0, y: 0 } + * // points[1] = { x: 2, y: 1 } + * // points[2] = { x: 3, y: 2 } + * // points[3] = { x: 6, y: 3 } + * ``` + * + * Use this if you need to get smoothed values between the previous and current pointer positions. DOM pointer + * events can often fire faster than the main browser loop, and this will help you avoid janky movement + * especially if you have an object following a Pointer. + * + * Note that if you provide an output array it will only be populated up to the number of steps provided. + * It will not clear any previous data that may have existed beyond the range of the steps count. + * + * Internally it uses the Smooth Step interpolation calculation. + * @param steps The number of interpolation steps to use. Default 10. + * @param out An array to store the results in. If not provided a new one will be created. + */ + getInterpolatedPosition(steps?: integer, out?: any[]): any[]; + /** * Destroys this Pointer instance and resets its external references. */ @@ -27821,26 +41925,47 @@ declare namespace Phaser { target: any; /** - * The Touch Start Event Handler. - * @param event The native DOM Touch Start Event. + * The Touch Start event handler function. + * Initially empty and bound in the `startListeners` method. */ - onTouchStart(event: TouchEvent): void; + onTouchStart: Function; /** - * The Touch Move Event Handler. - * @param event The native DOM Touch Move Event. + * The Touch Move event handler function. + * Initially empty and bound in the `startListeners` method. */ - onTouchMove(event: TouchEvent): void; + onTouchMove: Function; /** - * The Touch End Event Handler. - * @param event The native DOM Touch End Event. + * The Touch End event handler function. + * Initially empty and bound in the `startListeners` method. */ - onTouchEnd(event: TouchEvent): void; + onTouchEnd: Function; /** - * Starts the Touch Event listeners running. - * This is called automatically and does not need to be manually invoked. + * The Touch Cancel event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchCancel: Function; + + /** + * The Touch Over event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchOver: Function; + + /** + * The Touch Out event handler function. + * Initially empty and bound in the `startListeners` method. + */ + onTouchOut: Function; + + /** + * Starts the Touch Event listeners running as long as an input target is set. + * + * This method is called automatically if Touch Input is enabled in the game config, + * which it is by default. However, you can call it manually should you need to + * delay input capturing until later in the game. */ startListeners(): void; @@ -27937,6 +42062,139 @@ declare namespace Phaser { */ var FILE_POPULATED: integer; + namespace Events { + /** + * The Loader Plugin Add File Event. + * + * This event is dispatched when a new file is successfully added to the Loader and placed into the load queue. + * + * Listen to it from a Scene using: `this.load.on('addfile', listener)`. + * + * If you add lots of files to a Loader from a `preload` method, it will dispatch this event for each one of them. + */ + const ADD: any; + + /** + * The Loader Plugin Complete Event. + * + * This event is dispatched when the Loader has fully processed everything in the load queue. + * By this point every loaded file will now be in its associated cache and ready for use. + * + * Listen to it from a Scene using: `this.load.on('complete', listener)`. + */ + const COMPLETE: any; + + /** + * The File Load Complete Event. + * + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * Listen to it from a Scene using: `this.load.on('filecomplete', listener)`. + * + * You can also listen for the completion of a specific file. See the [FILE_KEY_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_KEY_COMPLETE} event. + */ + const FILE_COMPLETE: any; + + /** + * The File Load Complete Event. + * + * This event is dispatched by the Loader Plugin when any file in the queue finishes loading. + * + * It uses a special dynamic event name constructed from the key and type of the file. + * + * For example, if you have loaded an `image` with a key of `monster`, you can listen for it + * using the following: + * + * ```javascript + * this.load.on('filecomplete-image-monster', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a texture `atlas` with a key of `Level1`: + * + * ```javascript + * this.load.on('filecomplete-atlas-Level1', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * Or, if you have loaded a sprite sheet with a key of `Explosion` and a prefix of `GAMEOVER`: + * + * ```javascript + * this.load.on('filecomplete-spritesheet-GAMEOVERExplosion', function (key, type, data) { + * // Your handler code + * }); + * ``` + * + * You can also listen for the generic completion of files. See the [FILE_COMPLETE]{@linkcode Phaser.Loader.Events#event:FILE_COMPLETE} event. + */ + const FILE_KEY_COMPLETE: any; + + /** + * The File Load Error Event. + * + * This event is dispatched by the Loader Plugin when a file fails to load. + * + * Listen to it from a Scene using: `this.load.on('loaderror', listener)`. + */ + const FILE_LOAD_ERROR: any; + + /** + * The File Load Event. + * + * This event is dispatched by the Loader Plugin when a file finishes loading, + * but _before_ it is processed and added to the internal Phaser caches. + * + * Listen to it from a Scene using: `this.load.on('load', listener)`. + */ + const FILE_LOAD: any; + + /** + * The File Load Progress Event. + * + * This event is dispatched by the Loader Plugin during the load of a file, if the browser receives a DOM ProgressEvent and + * the `lengthComputable` event property is true. Depending on the size of the file and browser in use, this may, or may not happen. + * + * Listen to it from a Scene using: `this.load.on('fileprogress', listener)`. + */ + const FILE_PROGRESS: any; + + /** + * The Loader Plugin Post Process Event. + * + * This event is dispatched by the Loader Plugin when the Loader has finished loading everything in the load queue. + * It is dispatched before the internal lists are cleared and each File is destroyed. + * + * Use this hook to perform any last minute processing of files that can only happen once the + * Loader has completed, but prior to it emitting the `complete` event. + * + * Listen to it from a Scene using: `this.load.on('postprocess', listener)`. + */ + const POST_PROCESS: any; + + /** + * The Loader Plugin Progress Event. + * + * This event is dispatched when the Loader updates its load progress, typically as a result of a file having completed loading. + * + * Listen to it from a Scene using: `this.load.on('progress', listener)`. + */ + const PROGRESS: any; + + /** + * The Loader Plugin Start Event. + * + * This event is dispatched when the Loader starts running. At this point load progress is zero. + * + * This event is dispatched even if there aren't any files in the load queue. + * + * Listen to it from a Scene using: `this.load.on('start', listener)`. + */ + const START: any; + + } + /** * The base File class used by all File Types that the Loader can support. * You shouldn't create an instance of a File directly, but should extend it with your own class, setting a custom type and processing methods. @@ -28070,9 +42328,10 @@ declare namespace Phaser { /** * Called if the file errors while loading, is sent a DOM ProgressEvent. + * @param xhr The XMLHttpRequest that caused this onload event. * @param event The DOM ProgressEvent that resulted from this error. */ - onError(event: ProgressEvent): void; + onError(xhr: XMLHttpRequest, event: ProgressEvent): void; /** * Called during the file load progress. Is sent a DOM ProgressEvent. @@ -28357,7 +42616,7 @@ declare namespace Phaser { /** * The absolute or relative URL to load the audio file from. */ - audioURL?: string; + audioURL?: Object; /** * The audio configuration options. */ @@ -28386,7 +42645,18 @@ declare namespace Phaser { * @param audioXhrSettings An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param jsonXhrSettings An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: string, audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: XHRSettingsObject); + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.AudioSpriteFileConfig, jsonURL: string, audioURL?: Object, audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: XHRSettingsObject); + + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; } @@ -28586,6 +42856,50 @@ declare namespace Phaser { } type HTMLFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Text Cache. + */ + key: string; + /** + * The absolute or relative URL to load the file from. + */ + url?: string; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * A single HTML File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. + */ + class HTMLFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.txt`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.HTMLFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + } + + type HTMLTextureFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Texture Manager. */ @@ -28615,11 +42929,11 @@ declare namespace Phaser { /** * A single HTML File suitable for loading by the Loader. * - * These are created when you use the Phaser.Loader.LoaderPlugin#html method and are not typically created directly. + * These are created when you use the Phaser.Loader.LoaderPlugin#htmlTexture method and are not typically created directly. * - * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#html. + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#htmlTexture. */ - class HTMLFile extends Phaser.Loader.File { + class HTMLTextureFile extends Phaser.Loader.File { /** * * @param loader A reference to the Loader that is responsible for this file. @@ -28629,7 +42943,7 @@ declare namespace Phaser { * @param height The height of the texture the HTML will be rendered to. * @param xhrSettings Extra XHR Settings specifically for this file. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.HTMLFileConfig, url?: string, width?: integer, height?: integer, xhrSettings?: XHRSettingsObject); + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.HTMLTextureFileConfig, url?: string, width?: integer, height?: integer, xhrSettings?: XHRSettingsObject); /** * Called automatically by Loader.nextFile. @@ -28829,6 +43143,17 @@ declare namespace Phaser { */ constructor(loader: Phaser.Loader.LoaderPlugin, key: string, atlasURL?: string, path?: string, baseURL?: string, atlasXhrSettings?: XHRSettingsObject, textureXhrSettings?: XHRSettingsObject); + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + } type PackFileConfig = { @@ -28934,6 +43259,55 @@ declare namespace Phaser { } + type SceneFileConfig = { + /** + * The key of the file. Must be unique within both the Loader and the Text Cache. + */ + key: string; + /** + * The absolute or relative URL to load the file from. + */ + url?: string; + /** + * The default file extension to use if no url is provided. + */ + extension?: string; + /** + * Extra XHR Settings specifically for this file. + */ + xhrSettings?: XHRSettingsObject; + }; + + /** + * An external Scene JavaScript File suitable for loading by the Loader. + * + * These are created when you use the Phaser.Loader.LoaderPlugin#sceneFile method and are not typically created directly. + * + * For documentation about what all the arguments and configuration options mean please see Phaser.Loader.LoaderPlugin#sceneFile. + */ + class SceneFile extends Phaser.Loader.File { + /** + * + * @param loader A reference to the Loader that is responsible for this file. + * @param key The key to use for this file, or a file configuration object. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings Extra XHR Settings specifically for this file. + */ + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.SceneFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + + /** + * Called automatically by Loader.nextFile. + * This method controls what extra work this File does with its loaded data. + */ + onProcess(): void; + + /** + * Adds this file to its target cache upon successful loading and processing. + */ + addToCache(): void; + + } + type ScenePluginFileConfig = { /** * The key of the file. Must be unique within the Loader. @@ -29084,6 +43458,21 @@ declare namespace Phaser { } + type SVGSizeConfig = { + /** + * An optional width. The SVG will be resized to this size before being rendered to a texture. + */ + width?: integer; + /** + * An optional height. The SVG will be resized to this size before being rendered to a texture. + */ + height?: integer; + /** + * An optional scale. If given it overrides the width / height properties. The SVG is scaled by the scale factor before being rendered to a texture. + */ + scale?: number; + }; + type SVGFileConfig = { /** * The key of the file. Must be unique within both the Loader and the Texture Manager. @@ -29101,6 +43490,10 @@ declare namespace Phaser { * Extra XHR Settings specifically for this file. */ xhrSettings?: XHRSettingsObject; + /** + * The svg size configuration object. + */ + svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig; }; /** @@ -29116,9 +43509,10 @@ declare namespace Phaser { * @param loader A reference to the Loader that is responsible for this file. * @param key The key to use for this file, or a file configuration object. * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param svgConfig The svg size configuration object. * @param xhrSettings Extra XHR Settings specifically for this file. */ - constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.SVGFileConfig, url?: string, xhrSettings?: XHRSettingsObject); + constructor(loader: Phaser.Loader.LoaderPlugin, key: string | Phaser.Loader.FileTypes.SVGFileConfig, url?: string, svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig, xhrSettings?: XHRSettingsObject); /** * Called automatically by Loader.nextFile. @@ -29419,6 +43813,32 @@ declare namespace Phaser { } + namespace FileTypesManager { + /** + * Static method called when a LoaderPlugin is created. + * + * Loops through the local types object and injects all of them as + * properties into the LoaderPlugin instance. + * @param loader The LoaderPlugin to install the types into. + */ + function install(loader: Phaser.Loader.LoaderPlugin): void; + + /** + * Static method called directly by the File Types. + * + * The key is a reference to the function used to load the files via the Loader, i.e. `image`. + * @param key The key that will be used as the method name in the LoaderPlugin. + * @param factoryFunction The function that will be called when LoaderPlugin.key is invoked. + */ + function register(key: string, factoryFunction: Function): void; + + /** + * Removed all associated file types. + */ + function destroy(): void; + + } + /** * Given a File and a baseURL value this returns the URL the File will use to download from. * @param file The File object. @@ -29892,7 +44312,7 @@ declare namespace Phaser { * @param audioXhrSettings An XHR Settings configuration object for the audio file. Used in replacement of the Loaders default XHR Settings. * @param jsonXhrSettings An XHR Settings configuration object for the json file. Used in replacement of the Loaders default XHR Settings. */ - audioSprite(key: string | Phaser.Loader.FileTypes.AudioSpriteFileConfig | Phaser.Loader.FileTypes.AudioSpriteFileConfig[], jsonURL: string, audioURL?: string, audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + audioSprite(key: string | Phaser.Loader.FileTypes.AudioSpriteFileConfig | Phaser.Loader.FileTypes.AudioSpriteFileConfig[], jsonURL: string, audioURL?: string | string[], audioConfig?: any, audioXhrSettings?: XHRSettingsObject, jsonXhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; /** * Adds a Binary file, or array of Binary files, to the current load queue. @@ -30116,14 +44536,77 @@ declare namespace Phaser { glsl(key: string | Phaser.Loader.FileTypes.GLSLFileConfig | Phaser.Loader.FileTypes.GLSLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; /** - * Adds an HTML File, or array of HTML Files, to the current load queue. + * Adds an HTML file, or array of HTML files, to the current load queue. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: * * ```javascript * function preload () * { - * this.load.html('instructions', 'content/intro.html', 256, 512); + * this.load.html('story', 'files/LoginForm.html'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global HTML Cache upon a successful load. + * The key should be unique both in terms of files being loaded and files already present in the HTML Cache. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the HTML Cache first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.html({ + * key: 'login', + * url: 'files/LoginForm.html' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. + * + * Once the file has finished loading you can access it from its Cache using its key: + * + * ```javascript + * this.load.html('login', 'files/LoginForm.html'); + * // and later in your game ... + * var data = this.cache.html.get('login'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `LEVEL1.` and the key was `Story` the final key will be `LEVEL1.Story` and + * this is what you would use to retrieve the html from the HTML Cache. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.html". It will always add `.html` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the HTML File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * @param key The key to use for this file, or a file configuration object, or array of them. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + html(key: string | Phaser.Loader.FileTypes.HTMLFileConfig | Phaser.Loader.FileTypes.HTMLFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + + /** + * Adds an HTML File, or array of HTML Files, to the current load queue. When the files are loaded they + * will be rendered to textures and stored in the Texture Manager. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); * } * ``` * @@ -30143,7 +44626,7 @@ declare namespace Phaser { * Instead of passing arguments you can pass a configuration object, such as: * * ```javascript - * this.load.html({ + * this.load.htmlTexture({ * key: 'instructions', * url: 'content/intro.html', * width: 256, @@ -30151,12 +44634,12 @@ declare namespace Phaser { * }); * ``` * - * See the documentation for `Phaser.Loader.FileTypes.HTMLFileConfig` for more details. + * See the documentation for `Phaser.Loader.FileTypes.HTMLTextureFileConfig` for more details. * * Once the file has finished loading you can use it as a texture for a Game Object by referencing its key: * * ```javascript - * this.load.html('instructions', 'content/intro.html', 256, 512); + * this.load.htmlTexture('instructions', 'content/intro.html', 256, 512); * // and later in your game ... * this.add.image(x, y, 'instructions'); * ``` @@ -30180,15 +44663,15 @@ declare namespace Phaser { * limitations on what HTML can be inside an SVG. You can find out more details in this * [Mozilla MDN entry](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Drawing_DOM_objects_into_a_canvas). * - * Note: The ability to load this type of file will only be available if the Image File type has been built into Phaser. + * Note: The ability to load this type of file will only be available if the HTMLTextureFile File type has been built into Phaser. * It is available in the default build but can be excluded from custom builds. * @param key The key to use for this file, or a file configuration object, or array of them. - * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.png`, i.e. if `key` was "alien" then the URL will be "alien.png". + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.html`, i.e. if `key` was "alien" then the URL will be "alien.html". * @param width The width of the texture the HTML will be rendered to. Default 512. * @param height The height of the texture the HTML will be rendered to. Default 512. * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. */ - html(key: string | Phaser.Loader.FileTypes.ImageFileConfig | Phaser.Loader.FileTypes.ImageFileConfig[], url?: string, width?: integer, height?: integer, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + htmlTexture(key: string | Phaser.Loader.FileTypes.HTMLTextureFileConfig | Phaser.Loader.FileTypes.HTMLTextureFileConfig[], url?: string, width?: integer, height?: integer, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; /** * Adds an Image, or array of Images, to the current load queue. @@ -30597,12 +45080,102 @@ declare namespace Phaser { * It is available in the default build but can be excluded from custom builds. * @param key The key to use for this file, or a file configuration object, or array of them. * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". Or, a plugin function. - * @param start The plugin mapping configuration object. + * @param start Automatically start the plugin after loading? * @param mapping If this plugin is to be injected into the Scene, this is the property key used. * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. */ plugin(key: string | Phaser.Loader.FileTypes.PluginFileConfig | Phaser.Loader.FileTypes.PluginFileConfig[], url?: string | Function, start?: boolean, mapping?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + /** + * Adds an external Scene file, or array of Scene files, to the current load queue. + * + * You can call this method from within your Scene's `preload`, along with any other files you wish to load: + * + * ```javascript + * function preload () + * { + * this.load.sceneFile('Level1', 'src/Level1.js'); + * } + * ``` + * + * The file is **not** loaded right away. It is added to a queue ready to be loaded either when the loader starts, + * or if it's already running, when the next free load slot becomes available. This happens automatically if you + * are calling this from within the Scene's `preload` method, or a related callback. Because the file is queued + * it means you cannot use the file immediately after calling this method, but must wait for the file to complete. + * The typical flow for a Phaser Scene is that you load assets in the Scene's `preload` method and then when the + * Scene's `create` method is called you are guaranteed that all of those assets are ready for use and have been + * loaded. + * + * The key must be a unique String. It is used to add the file to the global Scene Manager upon a successful load. + * + * For a Scene File it's vitally important that the key matches the class name in the JavaScript file. + * + * For example here is the source file: + * + * ```javascript + * class ExternalScene extends Phaser.Scene { + * + * constructor () + * { + * super('myScene'); + * } + * + * } + * ``` + * + * Because the class is called `ExternalScene` that is the exact same key you must use when loading it: + * + * ```javascript + * function preload () + * { + * this.load.sceneFile('ExternalScene', 'src/yourScene.js'); + * } + * ``` + * + * The key that is used within the Scene Manager can either be set to the same, or you can override it in the Scene + * constructor, as we've done in the example above, where the Scene key was changed to `myScene`. + * + * The key should be unique both in terms of files being loaded and Scenes already present in the Scene Manager. + * Loading a file using a key that is already taken will result in a warning. If you wish to replace an existing file + * then remove it from the Scene Manager first, before loading a new one. + * + * Instead of passing arguments you can pass a configuration object, such as: + * + * ```javascript + * this.load.sceneFile({ + * key: 'Level1', + * url: 'src/Level1.js' + * }); + * ``` + * + * See the documentation for `Phaser.Loader.FileTypes.SceneFileConfig` for more details. + * + * Once the file has finished loading it will be added to the Scene Manager. + * + * ```javascript + * this.load.sceneFile('Level1', 'src/Level1.js'); + * // and later in your game ... + * this.scene.start('Level1'); + * ``` + * + * If you have specified a prefix in the loader, via `Loader.setPrefix` then this value will be prepended to this files + * key. For example, if the prefix was `WORLD1.` and the key was `Story` the final key will be `WORLD1.Story` and + * this is what you would use to retrieve the text from the Scene Manager. + * + * The URL can be relative or absolute. If the URL is relative the `Loader.baseURL` and `Loader.path` values will be prepended to it. + * + * If the URL isn't specified the Loader will take the key and create a filename from that. For example if the key is "story" + * and no URL is given then the Loader will set the URL to be "story.js". It will always add `.js` as the extension, although + * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. + * + * Note: The ability to load this type of file will only be available if the Scene File type has been built into Phaser. + * It is available in the default build but can be excluded from custom builds. + * @param key The key to use for this file, or a file configuration object, or array of them. + * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.js`, i.e. if `key` was "alien" then the URL will be "alien.js". + * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. + */ + sceneFile(key: string | Phaser.Loader.FileTypes.SceneFileConfig | Phaser.Loader.FileTypes.SceneFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + /** * Adds a Scene Plugin Script file, or array of plugin files, to the current load queue. * @@ -30813,7 +45386,8 @@ declare namespace Phaser { spritesheet(key: string | Phaser.Loader.FileTypes.SpriteSheetFileConfig | Phaser.Loader.FileTypes.SpriteSheetFileConfig[], url?: string, frameConfig?: Phaser.Loader.FileTypes.ImageFrameConfig, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; /** - * Adds an SVG File, or array of SVG Files, to the current load queue. + * Adds an SVG File, or array of SVG Files, to the current load queue. When the files are loaded they + * will be rendered to bitmap textures and stored in the Texture Manager. * * You can call this method from within your Scene's `preload`, along with any other files you wish to load: * @@ -30866,13 +45440,62 @@ declare namespace Phaser { * and no URL is given then the Loader will set the URL to be "alien.html". It will always add `.html` as the extension, although * this can be overridden if using an object instead of method arguments. If you do not desire this action then provide a URL. * + * You can optionally pass an SVG Resize Configuration object when you load an SVG file. By default the SVG will be rendered to a texture + * at the same size defined in the SVG file attributes. However, this isn't always desirable. You may wish to resize the SVG (either down + * or up) to improve texture clarity, or reduce texture memory consumption. You can either specify an exact width and height to resize + * the SVG to: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { width: 300, height: 600 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * width: 300, + * height: 600 + * } + * }); + * ``` + * + * Alternatively, you can just provide a scale factor instead: + * + * ```javascript + * function preload () + * { + * this.load.svg('morty', 'images/Morty.svg', { scale: 2.5 }); + * } + * ``` + * + * Or when using a configuration object: + * + * ```javascript + * this.load.svg({ + * key: 'morty', + * url: 'images/Morty.svg', + * svgConfig: { + * scale: 2.5 + * } + * }); + * ``` + * + * If scale, width and height values are all given, the scale has priority and the width and height values are ignored. + * * Note: The ability to load this type of file will only be available if the SVG File type has been built into Phaser. * It is available in the default build but can be excluded from custom builds. * @param key The key to use for this file, or a file configuration object, or array of them. * @param url The absolute or relative URL to load this file from. If undefined or `null` it will be set to `.svg`, i.e. if `key` was "alien" then the URL will be "alien.svg". + * @param svgConfig The svg size configuration object. * @param xhrSettings An XHR Settings configuration object. Used in replacement of the Loaders default XHR Settings. */ - svg(key: string | Phaser.Loader.FileTypes.SVGFileConfig | Phaser.Loader.FileTypes.SVGFileConfig[], url?: string, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; + svg(key: string | Phaser.Loader.FileTypes.SVGFileConfig | Phaser.Loader.FileTypes.SVGFileConfig[], url?: string, svgConfig?: Phaser.Loader.FileTypes.SVGSizeConfig, xhrSettings?: XHRSettingsObject): Phaser.Loader.LoaderPlugin; /** * Adds a Text file, or array of Text files, to the current load queue. @@ -30882,7 +45505,7 @@ declare namespace Phaser { * ```javascript * function preload () * { - * this.load.text('story', files/IntroStory.txt'); + * this.load.text('story', 'files/IntroStory.txt'); * } * ``` * @@ -30913,7 +45536,7 @@ declare namespace Phaser { * Once the file has finished loading you can access it from its Cache using its key: * * ```javascript - * this.load.image('story', 'files/IntroStory.txt'); + * this.load.text('story', 'files/IntroStory.txt'); * // and later in your game ... * var data = this.cache.text.get('story'); * ``` @@ -30944,7 +45567,7 @@ declare namespace Phaser { * ```javascript * function preload () * { - * this.load.tilemapCSV('level1', maps/Level1.csv'); + * this.load.tilemapCSV('level1', 'maps/Level1.csv'); * } * ``` * @@ -31008,7 +45631,7 @@ declare namespace Phaser { * ```javascript * function preload () * { - * this.load.tilemapImpact('level1', maps/Level1.json'); + * this.load.tilemapImpact('level1', 'maps/Level1.json'); * } * ``` * @@ -31072,7 +45695,7 @@ declare namespace Phaser { * ```javascript * function preload () * { - * this.load.tilemapTiledJSON('level1', maps/Level1.json'); + * this.load.tilemapTiledJSON('level1', 'maps/Level1.json'); * } * ``` * @@ -31288,22 +45911,27 @@ declare namespace Phaser { /** * The Scene which owns this Loader instance. */ - protected scene: Phaser.Scene; + scene: Phaser.Scene; /** * A reference to the Scene Systems. */ - protected systems: Phaser.Scenes.Systems; + systems: Phaser.Scenes.Systems; /** * A reference to the global Cache Manager. */ - protected cacheManager: Phaser.Cache.CacheManager; + cacheManager: Phaser.Cache.CacheManager; /** * A reference to the global Texture Manager. */ - protected textureManager: Phaser.Textures.TextureManager; + textureManager: Phaser.Textures.TextureManager; + + /** + * A reference to the global Scene Manager. + */ + protected sceneManager: Phaser.Scenes.SceneManager; /** * An optional prefix that is automatically prepended to the start of every file key. @@ -31637,17 +46265,6 @@ declare namespace Phaser { */ constructor(loader: Phaser.Loader.LoaderPlugin, type: string, key: string, files: Phaser.Loader.File[]); - /** - * Called by each File when it finishes loading. - * @param file The File that has completed processing. - */ - onFileComplete(file: Phaser.Loader.File): void; - - /** - * Adds this file to its target cache upon successful loading and processing. - */ - addToCache(): void; - /** * A reference to the Loader that is going to load this file. */ @@ -31699,6 +46316,12 @@ declare namespace Phaser { */ addToMultiFile(files: Phaser.Loader.File): Phaser.Loader.MultiFile; + /** + * Called by each File when it finishes loading. + * @param file The File that has completed processing. + */ + onFileComplete(file: Phaser.Loader.File): void; + /** * Called by each File that fails to load. * @param file The File that has failed to load. @@ -31770,6 +46393,22 @@ declare namespace Phaser { */ function BetweenY(x1: number, y1: number, x2: number, y2: number): number; + /** + * Takes an angle in Phasers default clockwise format and converts it so that + * 0 is North, 90 is West, 180 is South and 270 is East, + * therefore running counter-clockwise instead of clockwise. + * + * You can pass in the angle from a Game Object using: + * + * ```javascript + * var converted = CounterClockwise(gameobject.rotation); + * ``` + * + * All values for this function are in radians. + * @param angle The angle to convert, in radians. + */ + function CounterClockwise(angle: number): number; + /** * Normalize an angle to the [0, 2pi] range. * @param angle The angle to normalize, in radians. @@ -31900,6 +46539,7 @@ declare namespace Phaser { /** * An instance of the Random Number Generator. + * This is not set until the Game boots. */ var RND: Phaser.Math.RandomDataGenerator; @@ -32040,7 +46680,7 @@ declare namespace Phaser { * Elastic ease-in. * @param v The value to be tweened. * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period [description] Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. */ function In(v: number, amplitude?: number, period?: number): number; @@ -32048,7 +46688,7 @@ declare namespace Phaser { * Elastic ease-in/out. * @param v The value to be tweened. * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period [description] Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. */ function InOut(v: number, amplitude?: number, period?: number): number; @@ -32056,7 +46696,7 @@ declare namespace Phaser { * Elastic ease-out. * @param v The value to be tweened. * @param amplitude The amplitude of the elastic ease. Default 0.1. - * @param period [description] Default 0.1. + * @param period Sets how tight the sine-wave is, where smaller values are tighter waves, which result in more cycles. Default 0.1. */ function Out(v: number, amplitude?: number, period?: number): number; @@ -32567,6 +47207,14 @@ declare namespace Phaser { */ translate(v: Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix4; + /** + * Translate this Matrix using the given values. + * @param x The x component. + * @param y The y component. + * @param z The z component. + */ + translateXYZ(x: number, y: number, z: number): Phaser.Math.Matrix4; + /** * Apply a scale transformation to this Matrix. * @@ -32575,6 +47223,14 @@ declare namespace Phaser { */ scale(v: Phaser.Math.Vector3 | Phaser.Math.Vector4): Phaser.Math.Matrix4; + /** + * Apply a scale transformation to this Matrix. + * @param x The x component. + * @param y The y component. + * @param z The z component. + */ + scaleXYZ(x: number, y: number, z: number): Phaser.Math.Matrix4; + /** * Derive a rotation matrix around the given axis. * @param axis The rotation axis. @@ -32925,14 +47581,23 @@ declare namespace Phaser { function RadToDeg(radians: number): integer; /** - * A seeded random data generator. + * A seeded Random Data Generator. + * + * Access via `Phaser.Math.RND` which is an instance of this class pre-defined + * by Phaser. Or, create your own instance to use as you require. + * + * The `Math.RND` generator is seeded by the Game Config property value `seed`. + * If no such config property exists, a random number is used. + * + * If you create your own instance of this class you should provide a seed for it. + * If no seed is given it will use a 'random' one based on Date.now. */ class RandomDataGenerator { /** * - * @param seeds The seeds. + * @param seeds The seeds to use for the random number generator. */ - constructor(seeds?: string[]); + constructor(seeds?: string | string[]); /** * Signs to choose from. @@ -33100,12 +47765,12 @@ declare namespace Phaser { function RotateAround(point: Phaser.Geom.Point | object, x: number, y: number, angle: number): Phaser.Geom.Point; /** - * [description] + * Rotate a `point` around `x` and `y` by the given `angle` and `distance`. * @param point The point to be rotated. * @param x The horizontal coordinate to rotate around. * @param y The vertical coordinate to rotate around. * @param angle The angle of rotation in radians. - * @param distance [description] + * @param distance The distance from (x, y) to place the point at. */ function RotateAroundDistance(point: Phaser.Geom.Point | object, x: number, y: number, angle: number, distance: number): Phaser.Geom.Point; @@ -33178,8 +47843,9 @@ declare namespace Phaser { * @param value The value to snap. * @param gap The interval gap of the grid. * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. */ - function Ceil(value: number, gap: number, start?: number): number; + function Ceil(value: number, gap: number, start?: number, divide?: boolean): number; /** * Snap a value to nearest grid slice, using floor. @@ -33189,8 +47855,9 @@ declare namespace Phaser { * @param value The value to snap. * @param gap The interval gap of the grid. * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. */ - function Floor(value: number, gap: number, start?: number): number; + function Floor(value: number, gap: number, start?: number, divide?: boolean): number; /** * Snap a value to nearest grid slice, using rounding. @@ -33199,8 +47866,9 @@ declare namespace Phaser { * @param value The value to snap. * @param gap The interval gap of the grid. * @param start Optional starting offset for gap. Default 0. + * @param divide If `true` it will divide the snapped value by the gap before returning. Default false. */ - function To(value: number, gap: number, start?: number): number; + function To(value: number, gap: number, start?: number, divide?: boolean): number; } @@ -33226,10 +47894,10 @@ declare namespace Phaser { class Vector2 { /** * - * @param x The x component. + * @param x The x component, or an object with `x` and `y` properties. * @param y The y component. */ - constructor(x?: number, y?: number); + constructor(x?: number | Vector2Like, y?: number); /** * The x component of this Vector. @@ -33338,7 +48006,7 @@ declare namespace Phaser { distance(src: Phaser.Math.Vector2): number; /** - * Calculate the distance between this Vector, and the given Vector, squared. + * Calculate the distance between this Vector and the given Vector, squared. * @param src The Vector to calculate the distance to. */ distanceSq(src: Phaser.Math.Vector2): number; @@ -33372,8 +48040,8 @@ declare namespace Phaser { dot(src: Phaser.Math.Vector2): number; /** - * [description] - * @param src [description] + * Calculate the cross product of this Vector and the given Vector. + * @param src The Vector2 to cross with this Vector2. */ cross(src: Phaser.Math.Vector2): number; @@ -33405,8 +48073,45 @@ declare namespace Phaser { /** * A static zero Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. */ - static ZERO(): void; + static readonly ZERO: Phaser.Math.Vector2; + + /** + * A static right Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly RIGHT: Phaser.Math.Vector2; + + /** + * A static left Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly LEFT: Phaser.Math.Vector2; + + /** + * A static up Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly UP: Phaser.Math.Vector2; + + /** + * A static down Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly DOWN: Phaser.Math.Vector2; + + /** + * A static one Vector2 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ONE: Phaser.Math.Vector2; } @@ -33452,9 +48157,9 @@ declare namespace Phaser { clone(): Phaser.Math.Vector3; /** - * [description] - * @param a [description] - * @param b [description] + * Calculate the cross (vector) product of two given Vectors. + * @param a The first Vector to multiply. + * @param b The second Vector to multiply. */ crossVectors(a: Phaser.Math.Vector3, b: Phaser.Math.Vector3): Phaser.Math.Vector3; @@ -33526,7 +48231,7 @@ declare namespace Phaser { distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; /** - * Calculate the distance between this Vector, and the given Vector, squared. + * Calculate the distance between this Vector and the given Vector, squared. * @param v The Vector to calculate the distance to. */ distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3): number; @@ -33555,8 +48260,8 @@ declare namespace Phaser { dot(v: Phaser.Math.Vector3): number; /** - * [description] - * @param v [description] + * Calculate the cross (vector) product of this Vector (which will be modified) and the given Vector. + * @param v The Vector to cross product with. */ cross(v: Phaser.Math.Vector3): Phaser.Math.Vector3; @@ -33582,7 +48287,7 @@ declare namespace Phaser { transformMat4(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; /** - * [description] + * Transforms the coordinates of this Vector3 with the given Matrix4. * @param mat The Matrix4 to transform this Vector3 with. */ transformCoordinates(mat: Phaser.Math.Matrix4): Phaser.Math.Vector3; @@ -33619,6 +48324,62 @@ declare namespace Phaser { */ reset(): Phaser.Math.Vector3; + /** + * A static zero Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ZERO: Phaser.Math.Vector3; + + /** + * A static right Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly RIGHT: Phaser.Math.Vector3; + + /** + * A static left Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly LEFT: Phaser.Math.Vector3; + + /** + * A static up Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly UP: Phaser.Math.Vector3; + + /** + * A static down Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly DOWN: Phaser.Math.Vector3; + + /** + * A static forward Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly FORWARD: Phaser.Math.Vector3; + + /** + * A static back Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly BACK: Phaser.Math.Vector3; + + /** + * A static one Vector3 for use by reference. + * + * This constant is meant for comparison operations and should not be modified directly. + */ + static readonly ONE: Phaser.Math.Vector3; + } /** @@ -33671,7 +48432,7 @@ declare namespace Phaser { * Check whether this Vector is equal to a given Vector. * * Performs a strict quality check against each Vector's components. - * @param v [description] + * @param v The vector to check equality with. */ equals(v: Phaser.Math.Vector4): boolean; @@ -33752,12 +48513,12 @@ declare namespace Phaser { /** * Calculate the distance between this Vector and the given Vector. - * @param v [description] + * @param v The Vector to calculate the distance to. */ distance(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; /** - * Calculate the distance between this Vector, and the given Vector, squared. + * Calculate the distance between this Vector and the given Vector, squared. * @param v The Vector to calculate the distance to. */ distanceSq(v: Phaser.Math.Vector2 | Phaser.Math.Vector3 | Phaser.Math.Vector4): number; @@ -33807,12 +48568,10 @@ declare namespace Phaser { namespace Physics { namespace Arcade { /** - * An Arcade Physics Image Game Object. + * An Arcade Physics Image is an Image with an Arcade Physics body and related components. + * The body can be dynamic or static. * - * 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. + * The main difference between an Arcade Image and an Arcade Sprite is that you cannot animate an Arcade Image. */ class Image extends Phaser.GameObjects.Image implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** @@ -33825,6 +48584,11 @@ declare namespace Phaser { */ constructor(scene: Phaser.Scene, x: number, y: number, texture: string, frame?: string | integer); + /** + * This Game Object's Physics Body. + */ + body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; + /** * Clears all alpha values associated with this Game Object. * @@ -33886,6 +48650,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -33908,6 +48673,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -33915,7 +48681,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -34050,12 +48816,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -34166,15 +48936,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -34210,6 +48980,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -34224,6 +48999,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -34238,6 +49018,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -34245,34 +49030,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -34280,6 +49095,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -34296,6 +49112,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -34320,21 +49172,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -34364,6 +49259,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -34487,8 +49387,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -34506,140 +49407,195 @@ declare namespace Phaser { setVisible(value: boolean): this; /** - * [description] + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. * @param x The horizontal acceleration * @param y The vertical acceleration Default x. */ setAcceleration(x: number, y?: number): this; /** - * [description] + * Sets the body's horizontal acceleration. * @param value The horizontal acceleration */ setAccelerationX(value: number): this; /** - * [description] + * Sets the body's vertical acceleration. * @param value The vertical acceleration */ setAccelerationY(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular velocity of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular velocity. */ setAngularVelocity(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular acceleration of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular acceleration. */ setAngularAcceleration(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. + * @param value The amount of drag. */ setAngularDrag(value: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the bounce values of this body. + * + * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. + * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. + * @param x The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. + * @param y The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x. */ setBounce(x: number, y?: number): this; /** - * [description] - * @param value [description] + * Sets the horizontal bounce value for this body. + * @param value The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. */ setBounceX(value: number): this; /** - * [description] - * @param value [description] + * Sets the vertical bounce value for this body. + * @param value The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. */ setBounceY(value: number): this; /** - * [description] - * @param value [description] + * Sets if this body should collide with the world bounds or not. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. */ setCollideWorldBounds(value: boolean): this; /** - * [description] - * @param showBody [description] - * @param showVelocity [description] - * @param bodyColor [description] + * Sets the debug values of this body. + * + * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. + * Note that there is a performance cost in drawing debug displays. It should never be used in production. + * @param showBody Set to `true` to have this body render its outline to the debug display. + * @param showVelocity Set to `true` to have this body render a velocity marker to the debug display. + * @param bodyColor The color of the body outline when rendered to the debug display. */ setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): this; /** - * [description] - * @param value [description] + * Sets the color of the body outline when it renders to the debug display. + * @param value The color of the body outline when rendered to the debug display. */ setDebugBodyColor(value: number): this; /** - * [description] + * Set to `true` to have this body render its outline to the debug display. */ debugShowBody: boolean; /** - * [description] + * Set to `true` to have this body render a velocity marker to the debug display. */ debugShowVelocity: boolean; /** - * [description] + * The color of the body outline when it renders to the debug display. */ debugBodyColor: number; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param x The amount of horizontal drag to apply. + * @param y The amount of vertical drag to apply. Default x. */ setDrag(x: number, y?: number): this; /** - * [description] - * @param value [description] + * Sets the body's horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of horizontal drag to apply. */ setDragX(value: number): this; /** - * [description] - * @param value [description] + * Sets the body's vertical drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of vertical drag to apply. */ setDragY(value: number): this; /** - * [description] + * If this Body is using `drag` for deceleration this function controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. * @param value `true` to use damping for deceleration, or `false` to use linear deceleration. */ setDamping(value: boolean): this; /** - * [description] - * @param reset [description] - * @param x [description] - * @param y [description] - * @param enableGameObject [description] - * @param showGameObject [description] + * Enables this Game Object's Body. + * @param reset Also reset the Body and place it at (x, y). + * @param x The horizontal position to place the Game Object and Body. + * @param y The horizontal position to place the Game Object and Body. + * @param enableGameObject Also activate this Game Object. + * @param showGameObject Also show this Game Object. */ enableBody(reset: boolean, x: number, y: number, enableGameObject: boolean, showGameObject: boolean): this; /** - * [description] - * @param disableGameObject [description] Default false. - * @param hideGameObject [description] Default false. + * Stops and disables this Game Object's Body. + * @param disableGameObject Also deactivate this Game Object. Default false. + * @param hideGameObject Also hide this Game Object. Default false. */ disableBody(disableGameObject?: boolean, hideGameObject?: boolean): this; /** - * Syncs the Bodies position and size with its parent Game Object. + * Syncs the Body's position and size with its parent Game Object. * You don't need to call this for Dynamic Bodies, as it happens automatically. * But for Static bodies it's a useful way of modifying the position of a Static Body * in the Physics World, based on its Game Object. @@ -34647,178 +49603,178 @@ declare namespace Phaser { refreshBody(): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of horizontal friction to apply. + * @param y The amount of vertical friction to apply. Default x. */ setFriction(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. */ setFrictionX(x: number): this; /** - * [description] - * @param y [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. */ - setFrictionY(y: number): this; + setFrictionY(x: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * @param x The gravitational force to be applied to the X-axis. + * @param y The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. Default x. */ setGravity(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param x The gravitational force to be applied to the X-axis. */ setGravityX(x: number): this; /** - * [description] - * @param y [description] + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param y The gravitational force to be applied to the Y-axis. */ setGravityY(y: number): this; /** - * [description] - * @param value [description] Default true. + * Sets Whether this Body can be moved by collisions with another Body. + * @param value Sets if this body can be moved by collisions with another Body. Default true. */ setImmovable(value?: boolean): this; /** - * [description] - * @param value [description] + * Sets the mass of the physics body + * @param value New value for the mass of the body. */ setMass(value: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. + * @param x The amount to offset the body from the parent Game Object along the x-axis. + * @param y The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. Default x. */ setOffset(x: number, y?: number): this; /** - * [description] - * @param radius [description] - * @param offsetX [description] - * @param offsetY [description] + * Sets this physics body to use a circle for collision instead of a rectangle. + * @param radius The radius of the physics body, in pixels. + * @param offsetX The amount to offset the body from the parent Game Object along the x-axis. + * @param offsetY The amount to offset the body from the parent Game Object along the y-axis. */ setCircle(radius: number, offsetX?: number, offsetY?: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the velocity of the Body. + * @param x The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. + * @param y The vertical velocity of the body. Positive values move the body down, while negative values move it up. Default x. */ setVelocity(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Sets the horizontal component of the body's velocity. + * + * Positive values move the body to the right, while negative values move it to the left. + * @param x The new horizontal velocity. */ setVelocityX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical component of the body's velocity. + * + * Positive values move the body down, while negative values move it up. + * @param y The new vertical velocity of the body. */ setVelocityY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the maximum velocity of the body. + * @param x The new maximum horizontal velocity. + * @param y The new maximum vertical velocity. Default x. */ setMaxVelocity(x: number, y?: number): this; } /** - * [description] + * The Arcade Physics Plugin belongs to a Scene and sets up and manages the Scene's physics simulation. + * It also holds some useful methods for moving and rotating Arcade Physics Bodies. + * + * You can access it from within a Scene using `this.physics`. */ class ArcadePhysics { /** * - * @param scene [description] + * @param scene The Scene that this Plugin belongs to. */ constructor(scene: Phaser.Scene); /** - * [description] + * The Scene that this Plugin belongs to. */ scene: Phaser.Scene; /** - * [description] + * The Scene's Systems. */ systems: Phaser.Scenes.Systems; /** - * [description] + * A configuration object. Union of the `physics.arcade.*` properties of the GameConfig and SceneConfig objects. */ config: object; /** - * [description] + * The physics simulation. */ world: Phaser.Physics.Arcade.World; /** - * [description] + * An object holding the Arcade Physics factory methods. */ add: Phaser.Physics.Arcade.Factory; /** - * [description] + * Creates the physics configuration for the current Scene. */ getConfig(): object; /** - * Checks for overlaps between two Game Objects. The objects can be any Game Object that have an Arcade Physics Body. - * - * Unlike {@link #collide} the objects are NOT automatically separated or have any physics applied, they merely test for overlap results. - * - * Both the first and second parameter can be arrays of objects, of differing types. - * If two arrays are passed, the contents of the first parameter will be tested against all contents of the 2nd parameter. - * - * ##### Tilemaps - * - * Any overlapping tiles, including blank/null tiles, will give a positive result. Tiles marked via {@link Phaser.Tilemap#setCollision} (and similar methods) have no special status, and callbacks added via {@link Phaser.Tilemap#setTileIndexCallback} or {@link Phaser.Tilemap#setTileLocationCallback} are not invoked. So calling this method without any callbacks isn't very useful. - * - * If you're interested only in whether an object overlaps a certain tile or class of tiles, filter the tiles with `processCallback` and then use the result returned by this method. Blank/null tiles can be excluded by their {@link Phaser.Tile#index index} (-1). - * - * If you want to take action on certain overlaps, examine the tiles in `collideCallback` and then handle as you like. - * @param object1 The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param object2 The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param overlapCallback An optional callback function that is called if the objects overlap. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. Default null. - * @param processCallback A callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. Default null. + * Tests if Game Objects overlap. See {@link Phaser.Physics.Arcade.World#overlap} + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `collideCallback` will only be called if this callback returns `true`. * @param callbackContext The context in which to run the callbacks. */ - overlap(object1: Phaser.GameObjects.GameObject | any[], object2: Phaser.GameObjects.GameObject | any[], overlapCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; + overlap(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; /** - * [description] - * @param object1 The first object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param object2 The second object or array of objects to check. Can be any Game Object that has an Arcade Physics Body. - * @param collideCallback An optional callback function that is called if the objects collide. The two objects will be passed to this function in the same order in which you specified them, unless you are checking Group vs. Sprite, in which case Sprite will always be the first parameter. Default null. - * @param processCallback A callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. Default null. + * Tests if Game Objects overlap and separates them (if possible). See {@link Phaser.Physics.Arcade.World#collide}. + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. * @param callbackContext The context in which to run the callbacks. */ - collide(object1: Phaser.GameObjects.GameObject | any[], object2: Phaser.GameObjects.GameObject | any[], collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; + collide(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; /** - * [description] + * Pauses the simulation. */ pause(): Phaser.Physics.Arcade.World; /** - * [description] + * Resumes the simulation (if paused). */ resume(): Phaser.Physics.Arcade.World; @@ -34927,15 +49883,11 @@ declare namespace Phaser { } /** - * An Arcade Physics Sprite Game Object. + * An Arcade Physics Sprite is a Sprite with an Arcade Physics body and related components. + * The body can be dynamic or static. * - * 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. + * The main difference between an Arcade Sprite and an Arcade Image is that you cannot animate an Arcade Image. + * If you do not require animation then you can safely use Arcade Images instead of Arcade Sprites. */ class Sprite extends Phaser.GameObjects.Sprite implements Phaser.Physics.Arcade.Components.Acceleration, Phaser.Physics.Arcade.Components.Angular, Phaser.Physics.Arcade.Components.Bounce, Phaser.Physics.Arcade.Components.Debug, Phaser.Physics.Arcade.Components.Drag, Phaser.Physics.Arcade.Components.Enable, Phaser.Physics.Arcade.Components.Friction, Phaser.Physics.Arcade.Components.Gravity, Phaser.Physics.Arcade.Components.Immovable, Phaser.Physics.Arcade.Components.Mass, Phaser.Physics.Arcade.Components.Size, Phaser.Physics.Arcade.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** @@ -34949,9 +49901,9 @@ declare namespace Phaser { constructor(scene: Phaser.Scene, x: number, y: number, texture: string, frame?: string | integer); /** - * If this Game Object is enabled for physics then this property will contain a reference to a Physics Body. + * This Game Object's Physics Body. */ - body: Phaser.Physics.Arcade.Body; + body: Phaser.Physics.Arcade.Body | Phaser.Physics.Arcade.StaticBody; /** * Clears all alpha values associated with this Game Object. @@ -35014,6 +49966,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -35036,6 +49989,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -35043,7 +49997,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -35178,12 +50132,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -35294,15 +50252,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -35338,6 +50296,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -35352,6 +50315,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -35366,6 +50334,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -35373,34 +50346,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -35408,6 +50411,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -35424,6 +50428,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -35448,21 +50488,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -35492,6 +50575,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -35615,8 +50703,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -35634,140 +50723,195 @@ declare namespace Phaser { setVisible(value: boolean): this; /** - * [description] + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. * @param x The horizontal acceleration * @param y The vertical acceleration Default x. */ setAcceleration(x: number, y?: number): this; /** - * [description] + * Sets the body's horizontal acceleration. * @param value The horizontal acceleration */ setAccelerationX(value: number): this; /** - * [description] + * Sets the body's vertical acceleration. * @param value The vertical acceleration */ setAccelerationY(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular velocity of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular velocity. */ setAngularVelocity(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular acceleration of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular acceleration. */ setAngularAcceleration(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. + * @param value The amount of drag. */ setAngularDrag(value: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the bounce values of this body. + * + * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. + * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. + * @param x The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. + * @param y The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x. */ setBounce(x: number, y?: number): this; /** - * [description] - * @param value [description] + * Sets the horizontal bounce value for this body. + * @param value The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. */ setBounceX(value: number): this; /** - * [description] - * @param value [description] + * Sets the vertical bounce value for this body. + * @param value The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. */ setBounceY(value: number): this; /** - * [description] - * @param value [description] + * Sets if this body should collide with the world bounds or not. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. */ setCollideWorldBounds(value: boolean): this; /** - * [description] - * @param showBody [description] - * @param showVelocity [description] - * @param bodyColor [description] + * Sets the debug values of this body. + * + * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. + * Note that there is a performance cost in drawing debug displays. It should never be used in production. + * @param showBody Set to `true` to have this body render its outline to the debug display. + * @param showVelocity Set to `true` to have this body render a velocity marker to the debug display. + * @param bodyColor The color of the body outline when rendered to the debug display. */ setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): this; /** - * [description] - * @param value [description] + * Sets the color of the body outline when it renders to the debug display. + * @param value The color of the body outline when rendered to the debug display. */ setDebugBodyColor(value: number): this; /** - * [description] + * Set to `true` to have this body render its outline to the debug display. */ debugShowBody: boolean; /** - * [description] + * Set to `true` to have this body render a velocity marker to the debug display. */ debugShowVelocity: boolean; /** - * [description] + * The color of the body outline when it renders to the debug display. */ debugBodyColor: number; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param x The amount of horizontal drag to apply. + * @param y The amount of vertical drag to apply. Default x. */ setDrag(x: number, y?: number): this; /** - * [description] - * @param value [description] + * Sets the body's horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of horizontal drag to apply. */ setDragX(value: number): this; /** - * [description] - * @param value [description] + * Sets the body's vertical drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of vertical drag to apply. */ setDragY(value: number): this; /** - * [description] + * If this Body is using `drag` for deceleration this function controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. * @param value `true` to use damping for deceleration, or `false` to use linear deceleration. */ setDamping(value: boolean): this; /** - * [description] - * @param reset [description] - * @param x [description] - * @param y [description] - * @param enableGameObject [description] - * @param showGameObject [description] + * Enables this Game Object's Body. + * @param reset Also reset the Body and place it at (x, y). + * @param x The horizontal position to place the Game Object and Body. + * @param y The horizontal position to place the Game Object and Body. + * @param enableGameObject Also activate this Game Object. + * @param showGameObject Also show this Game Object. */ enableBody(reset: boolean, x: number, y: number, enableGameObject: boolean, showGameObject: boolean): this; /** - * [description] - * @param disableGameObject [description] Default false. - * @param hideGameObject [description] Default false. + * Stops and disables this Game Object's Body. + * @param disableGameObject Also deactivate this Game Object. Default false. + * @param hideGameObject Also hide this Game Object. Default false. */ disableBody(disableGameObject?: boolean, hideGameObject?: boolean): this; /** - * Syncs the Bodies position and size with its parent Game Object. + * Syncs the Body's position and size with its parent Game Object. * You don't need to call this for Dynamic Bodies, as it happens automatically. * But for Static bodies it's a useful way of modifying the position of a Static Body * in the Physics World, based on its Game Object. @@ -35775,93 +50919,103 @@ declare namespace Phaser { refreshBody(): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of horizontal friction to apply. + * @param y The amount of vertical friction to apply. Default x. */ setFriction(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. */ setFrictionX(x: number): this; /** - * [description] - * @param y [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. */ - setFrictionY(y: number): this; + setFrictionY(x: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * @param x The gravitational force to be applied to the X-axis. + * @param y The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. Default x. */ setGravity(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param x The gravitational force to be applied to the X-axis. */ setGravityX(x: number): this; /** - * [description] - * @param y [description] + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param y The gravitational force to be applied to the Y-axis. */ setGravityY(y: number): this; /** - * [description] - * @param value [description] Default true. + * Sets Whether this Body can be moved by collisions with another Body. + * @param value Sets if this body can be moved by collisions with another Body. Default true. */ setImmovable(value?: boolean): this; /** - * [description] - * @param value [description] + * Sets the mass of the physics body + * @param value New value for the mass of the body. */ setMass(value: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. + * @param x The amount to offset the body from the parent Game Object along the x-axis. + * @param y The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. Default x. */ setOffset(x: number, y?: number): this; /** - * [description] - * @param radius [description] - * @param offsetX [description] - * @param offsetY [description] + * Sets this physics body to use a circle for collision instead of a rectangle. + * @param radius The radius of the physics body, in pixels. + * @param offsetX The amount to offset the body from the parent Game Object along the x-axis. + * @param offsetY The amount to offset the body from the parent Game Object along the y-axis. */ setCircle(radius: number, offsetX?: number, offsetY?: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the velocity of the Body. + * @param x The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. + * @param y The vertical velocity of the body. Positive values move the body down, while negative values move it up. Default x. */ setVelocity(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Sets the horizontal component of the body's velocity. + * + * Positive values move the body to the right, while negative values move it to the left. + * @param x The new horizontal velocity. */ setVelocityX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical component of the body's velocity. + * + * Positive values move the body down, while negative values move it up. + * @param y The new vertical velocity of the body. */ setVelocityY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the maximum velocity of the body. + * @param x The new maximum horizontal velocity. + * @param y The new maximum vertical velocity. Default x. */ setMaxVelocity(x: number, y?: number): this; @@ -35869,6 +51023,8 @@ declare namespace Phaser { /** * A Dynamic Arcade Body. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticBody}. */ class Body { /** @@ -35919,8 +51075,8 @@ declare namespace Phaser { isCircle: boolean; /** - * The unscaled radius of this Body's boundary (if circular), as set by setCircle, in source pixels. - * The true radius (if circular) is equal to halfWidth. + * If this Body is circular, this is the unscaled radius of the Body's boundary, as set by setCircle(), in source pixels. + * The true radius is equal to `halfWidth`. */ radius: number; @@ -35940,12 +51096,12 @@ declare namespace Phaser { prev: Phaser.Math.Vector2; /** - * Whether this Body's rotation is affected by its angular acceleration and velocity. + * Whether this Body's `rotation` is affected by its angular acceleration and angular velocity. */ allowRotation: boolean; /** - * This body's rotation, in degrees, based on its angular acceleration and velocity. + * This body's rotation, in degrees, based on its angular acceleration and angular velocity. * The Body's rotation controls the `angle` of its Game Object. * It doesn't rotate the Body's boundary, which is always an axis-aligned rectangle or a circle. */ @@ -35957,47 +51113,52 @@ declare namespace Phaser { preRotation: number; /** - * The width of the Body's boundary. If circular, this is also the Body's diameter. + * The width of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. */ width: number; /** - * The height of the Body's boundary. If circular, this is also the Body's diameter. + * The height of the Body's boundary, in pixels. + * If the Body is circular, this is also the Body's diameter. */ height: number; /** - * The unscaled width of the Body, in source pixels. The default is the width of the Body's Game Object's texture frame. + * The unscaled width of the Body, in source pixels, as set by setSize(). + * The default is the width of the Body's Game Object's texture frame. */ sourceWidth: number; /** - * The unscaled height of the Body, in source pixels. The default is the height of the Body's Game Object's texture frame. + * The unscaled height of the Body, in source pixels, as set by setSize(). + * The default is the height of the Body's Game Object's texture frame. */ sourceHeight: number; /** - * Half the Body's width. + * Half the Body's width, in pixels. */ halfWidth: number; /** - * Half the Body's height. + * Half the Body's height, in pixels. */ halfHeight: number; /** - * The center of the Body's boundary. The midpoint of its `position` (top-left corner) and its bottom-right corner. + * The center of the Body's boundary. + * The midpoint of its `position` (top-left corner) and its bottom-right corner. */ center: Phaser.Math.Vector2; /** - * The Body's change in position, in pixels per second. + * The Body's velocity, in pixels per second. */ velocity: Phaser.Math.Vector2; /** - * The Body's calculated change in position, in pixels, at the last step. + * The Body's calculated velocity, in pixels per second, at the last step. */ readonly newVelocity: Phaser.Math.Vector2; @@ -36012,17 +51173,25 @@ declare namespace Phaser { acceleration: Phaser.Math.Vector2; /** - * Whether this Body's velocity is affected by its drag vector. + * Whether this Body's velocity is affected by its `drag`. */ allowDrag: boolean; /** * Absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. */ - drag: Phaser.Math.Vector2; + drag: Phaser.Math.Vector2 | number; /** - * Whether this Body's position is affected by its gravity vector. + * Whether this Body's position is affected by gravity (local or world). */ allowGravity: boolean; @@ -36039,7 +51208,7 @@ declare namespace Phaser { /** * Rebound following a collision with the world boundary, relative to 1. - * If empty, `bounce` is used instead. + * If null, `bounce` is used instead. */ worldBounce: Phaser.Math.Vector2; @@ -36059,15 +51228,25 @@ declare namespace Phaser { onOverlap: boolean; /** - * The Body's absolute maximum velocity. - * - * This limits the Body's rate of movement but not its `velocity` values (which can still exceed `maxVelocity`). + * The Body's absolute maximum velocity, in pixels per second. + * The horizontal and vertical components are applied separately. */ maxVelocity: Phaser.Math.Vector2; /** - * If this Body is `immovable` and in motion, this the proportion of this Body's movement received by the riding body on each axis, relative to 1. - * The default value (1, 0) moves the riding body horizontally in equal proportion and vertically not at all. + * The maximum speed this Body is allowed to reach. + * + * If not negative it limits the scalar value of speed. + * + * Any negative value means no maximum is being applied. + */ + maxSpeed: number; + + /** + * If this Body is `immovable` and in motion, `friction` is the proportion of this Body's motion received by the riding Body on each axis, relative to 1. + * The default value (1, 0) moves the riding Body horizontally in equal proportion to this Body and vertically not at all. + * The horizontal component (x) is applied only when two colliding Bodies are separated vertically. + * The vertical component (y) is applied only when two colliding Bodies are separated horizontally. */ friction: Phaser.Math.Vector2; @@ -36085,17 +51264,19 @@ declare namespace Phaser { useDamping: boolean; /** - * The rate of change of this Body's rotation, in degrees per second. + * The rate of change of this Body's `rotation`, in degrees per second. */ angularVelocity: number; /** - * The rate of change of this Body's angular velocity, in degrees per second squared. + * The Body's angular acceleration (change in angular velocity), in degrees per second squared. */ angularAcceleration: number; /** * Loss of angular velocity due to angular movement, in degrees per second. + * + * Angular drag is applied only when angular acceleration is zero. */ angularDrag: number; @@ -36111,22 +51292,23 @@ declare namespace Phaser { mass: number; /** - * The angle of this Body's velocity vector, in degrees. + * The calculated angle of this Body's velocity vector, in degrees, during the last step. */ angle: number; /** - * The magnitude of the Body's velocity, as calculated during the last update. + * The calculated magnitude of the Body's velocity, in pixels per second, during the last step. */ speed: number; /** - * The calculated direction of the Body's velocity. + * The direction of the Body's velocity, as calculated during the last step. + * If the Body is moving on both axes (diagonally), this describes motion on the vertical axis only. */ facing: integer; /** - * Whether this object can be moved by collisions with another body. + * Whether this Body can be moved by collisions with another Body. */ immovable: boolean; @@ -36136,12 +51318,14 @@ declare namespace Phaser { moves: boolean; /** - * A flag disabling the default horizontal separation of colliding bodies. Pass your own `processHandler` to the collider. + * A flag disabling the default horizontal separation of colliding bodies. + * Pass your own `collideCallback` to the collider. */ customSeparateX: boolean; /** - * A flag disabling the default vertical separation of colliding bodies. Pass your own `processHandler` to the collider. + * A flag disabling the default vertical separation of colliding bodies. + * Pass your own `collideCallback` to the collider. */ customSeparateY: boolean; @@ -36161,7 +51345,7 @@ declare namespace Phaser { overlapR: number; /** - * Whether this Body is overlapped with another and both have zero velocity. + * Whether this Body is overlapped with another and both are not moving. */ embedded: boolean; @@ -36172,7 +51356,7 @@ declare namespace Phaser { /** * Whether this Body is checked for collisions and for which directions. - * You can set `checkCollision.none = false` to disable collision checks. + * You can set `checkCollision.none = true` to disable collision checks. */ checkCollision: ArcadeBodyCollision; @@ -36212,18 +51396,19 @@ declare namespace Phaser { readonly physicsType: integer; /** - * Updates this Body's transform, dimensions, and position from its Game Object. + * Updates the Body's `transform`, `width`, `height`, and `center` from its Game Object. + * The Body's `position` isn't changed. */ updateBounds(): void; /** - * Updates the Body's `center` from its `position` and dimensions. + * Updates the Body's `center` from its `position`, `width`, and `height`. */ updateCenter(): void; /** * Updates the Body. - * @param delta The delta time, in ms, elapsed since the last frame. + * @param delta The delta time, in seconds, elapsed since the last frame. */ update(delta: number): void; @@ -36247,12 +51432,13 @@ declare namespace Phaser { /** * Sizes and positions this Body's boundary, as a rectangle. - * Modifies the Body's `offset` if `center` is true (the default). - * @param width The width of the Body, in source pixels. - * @param height The height of the Body, in source pixels. - * @param center Modify the Body's `offset`, placing the Body's center on its Game Object's center. Default true. + * Modifies the Body `offset` if `center` is true (the default). + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * @param width The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param height The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param center Modify the Body's `offset`, placing the Body's center on its Game Object's center. Only works if the Game Object has the `getCenter` method. Default true. */ - setSize(width: number, height: number, center?: boolean): Phaser.Physics.Arcade.Body; + setSize(width?: integer, height?: integer, center?: boolean): Phaser.Physics.Arcade.Body; /** * Sizes and positions this Body's boundary, as a circle. @@ -36378,6 +51564,12 @@ declare namespace Phaser { */ setMaxVelocity(x: number, y?: number): Phaser.Physics.Arcade.Body; + /** + * Sets the maximum speed the Body can move. + * @param value The maximum speed value, in pixels per second. Set to a negative value to disable. + */ + setMaxSpeed(value: number): Phaser.Physics.Arcade.Body; + /** * Sets the Body's bounce. * @param x The horizontal bounce, relative to 1. @@ -36521,6 +51713,12 @@ declare namespace Phaser { */ setImmovable(value?: boolean): Phaser.Physics.Arcade.Body; + /** + * Sets the Body's `enable` property. + * @param value The value to assign to `enable`. Default true. + */ + setEnable(value?: boolean): Phaser.Physics.Arcade.Body; + /** * The Body's horizontal position (left edge). */ @@ -36554,13 +51752,14 @@ declare namespace Phaser { } /** - * [description] + * An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects + * every step. If a collision, or overlap, occurs it will invoke the given callbacks. */ class Collider { /** * - * @param world [description] - * @param overlapOnly [description] + * @param world The Arcade physics World that will manage the collisions. + * @param overlapOnly Whether to check for collisions or overlap. * @param object1 The first object to check for collision. * @param object2 The second object to check for collision. * @param collideCallback The callback to invoke when the two objects collide. @@ -36570,63 +51769,65 @@ declare namespace Phaser { constructor(world: Phaser.Physics.Arcade.World, overlapOnly: boolean, object1: ArcadeColliderType, object2: ArcadeColliderType, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any); /** - * [description] + * The world in which the bodies will collide. */ world: Phaser.Physics.Arcade.World; /** - * [description] + * The name of the collider (unused by Phaser). */ name: string; /** - * [description] + * Whether the collider is active. */ active: boolean; /** - * [description] + * Whether to check for collisions or overlaps. */ overlapOnly: boolean; /** - * [description] + * The first object to check for collision. */ object1: ArcadeColliderType; /** - * [description] + * The second object to check for collision. */ object2: ArcadeColliderType; /** - * [description] + * The callback to invoke when the two objects collide. */ collideCallback: ArcadePhysicsCallback; /** - * [description] + * If a processCallback exists it must return true or collision checking will be skipped. */ processCallback: ArcadePhysicsCallback; /** - * [description] + * The context the collideCallback and processCallback will run in. */ callbackContext: object; /** - * [description] - * @param name [description] + * A name for the Collider. + * + * Phaser does not use this value, it's for your own reference. + * @param name The name to assign to the Collider. */ setName(name: string): Phaser.Physics.Arcade.Collider; /** - * [description] + * Called by World as part of its step processing, initial operation of collision checking. */ update(): void; /** - * [description] + * Removes Collider from World and disposes of its resources. */ destroy(): void; @@ -36634,153 +51835,208 @@ declare namespace Phaser { namespace Components { /** - * [description] + * Provides methods used for setting the acceleration properties of an Arcade Physics Body. */ interface Acceleration { /** - * [description] + * Sets the body's horizontal and vertical acceleration. If the vertical acceleration value is not provided, the vertical acceleration is set to the same value as the horizontal acceleration. * @param x The horizontal acceleration * @param y The vertical acceleration Default x. */ setAcceleration(x: number, y?: number): this; /** - * [description] + * Sets the body's horizontal acceleration. * @param value The horizontal acceleration */ setAccelerationX(value: number): this; /** - * [description] + * Sets the body's vertical acceleration. * @param value The vertical acceleration */ setAccelerationY(value: number): this; } /** - * [description] + * Provides methods used for setting the angular acceleration properties of an Arcade Physics Body. */ interface Angular { /** - * [description] - * @param value [description] + * Sets the angular velocity of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular velocity. */ setAngularVelocity(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular acceleration of the body. + * + * In Arcade Physics, bodies cannot rotate. They are always axis-aligned. + * However, they can have angular motion, which is passed on to the Game Object bound to the body, + * causing them to visually rotate, even though the body remains axis-aligned. + * @param value The amount of angular acceleration. */ setAngularAcceleration(value: number): this; /** - * [description] - * @param value [description] + * Sets the angular drag of the body. Drag is applied to the current velocity, providing a form of deceleration. + * @param value The amount of drag. */ setAngularDrag(value: number): this; } /** - * [description] + * Provides methods used for setting the bounce properties of an Arcade Physics Body. */ interface Bounce { /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the bounce values of this body. + * + * Bounce is the amount of restitution, or elasticity, the body has when it collides with another object. + * A value of 1 means that it will retain its full velocity after the rebound. A value of 0 means it will not rebound at all. + * @param x The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. + * @param y The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. Default x. */ setBounce(x: number, y?: number): this; /** - * [description] - * @param value [description] + * Sets the horizontal bounce value for this body. + * @param value The amount of horizontal bounce to apply on collision. A float, typically between 0 and 1. */ setBounceX(value: number): this; /** - * [description] - * @param value [description] + * Sets the vertical bounce value for this body. + * @param value The amount of vertical bounce to apply on collision. A float, typically between 0 and 1. */ setBounceY(value: number): this; /** - * [description] - * @param value [description] + * Sets if this body should collide with the world bounds or not. + * @param value `true` if this body should collide with the world bounds, otherwise `false`. */ setCollideWorldBounds(value: boolean): this; } /** - * [description] + * Provides methods used for setting the debug properties of an Arcade Physics Body. */ interface Debug { /** - * [description] - * @param showBody [description] - * @param showVelocity [description] - * @param bodyColor [description] + * Sets the debug values of this body. + * + * Bodies will only draw their debug if debug has been enabled for Arcade Physics as a whole. + * Note that there is a performance cost in drawing debug displays. It should never be used in production. + * @param showBody Set to `true` to have this body render its outline to the debug display. + * @param showVelocity Set to `true` to have this body render a velocity marker to the debug display. + * @param bodyColor The color of the body outline when rendered to the debug display. */ setDebug(showBody: boolean, showVelocity: boolean, bodyColor: number): this; /** - * [description] - * @param value [description] + * Sets the color of the body outline when it renders to the debug display. + * @param value The color of the body outline when rendered to the debug display. */ setDebugBodyColor(value: number): this; /** - * [description] + * Set to `true` to have this body render its outline to the debug display. */ debugShowBody: boolean; /** - * [description] + * Set to `true` to have this body render a velocity marker to the debug display. */ debugShowVelocity: boolean; /** - * [description] + * The color of the body outline when it renders to the debug display. */ debugBodyColor: number; } /** - * [description] + * Provides methods used for setting the drag properties of an Arcade Physics Body. */ interface Drag { /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the body's horizontal and vertical drag. If the vertical drag value is not provided, the vertical drag is set to the same value as the horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param x The amount of horizontal drag to apply. + * @param y The amount of vertical drag to apply. Default x. */ setDrag(x: number, y?: number): this; /** - * [description] - * @param value [description] + * Sets the body's horizontal drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of horizontal drag to apply. */ setDragX(value: number): this; /** - * [description] - * @param value [description] + * Sets the body's vertical drag. + * + * Drag can be considered as a form of deceleration that will return the velocity of a body back to zero over time. + * It is the absolute loss of velocity due to movement, in pixels per second squared. + * The x and y components are applied separately. + * + * When `useDamping` is true, this is 1 minus the damping factor. + * A value of 1 means the Body loses no velocity. + * A value of 0.95 means the Body loses 5% of its velocity per step. + * A value of 0.5 means the Body loses 50% of its velocity per step. + * + * Drag is applied only when `acceleration` is zero. + * @param value The amount of vertical drag to apply. */ setDragY(value: number): this; /** - * [description] + * If this Body is using `drag` for deceleration this function controls how the drag is applied. + * If set to `true` drag will use a damping effect rather than a linear approach. If you are + * creating a game where the Body moves freely at any angle (i.e. like the way the ship moves in + * the game Asteroids) then you will get a far smoother and more visually correct deceleration + * by using damping, avoiding the axis-drift that is prone with linear deceleration. + * + * If you enable this property then you should use far smaller `drag` values than with linear, as + * they are used as a multiplier on the velocity. Values such as 0.95 will give a nice slow + * deceleration, where-as smaller values, such as 0.5 will stop an object almost immediately. * @param value `true` to use damping for deceleration, or `false` to use linear deceleration. */ setDamping(value: boolean): this; } /** - * [description] + * Provides methods used for setting the enable properties of an Arcade Physics Body. */ interface Enable { /** - * [description] - * @param reset [description] - * @param x [description] - * @param y [description] - * @param enableGameObject [description] - * @param showGameObject [description] + * Enables this Game Object's Body. + * @param reset Also reset the Body and place it at (x, y). + * @param x The horizontal position to place the Game Object and Body. + * @param y The horizontal position to place the Game Object and Body. + * @param enableGameObject Also activate this Game Object. + * @param showGameObject Also show this Game Object. */ enableBody(reset: boolean, x: number, y: number, enableGameObject: boolean, showGameObject: boolean): this; /** - * [description] - * @param disableGameObject [description] Default false. - * @param hideGameObject [description] Default false. + * Stops and disables this Game Object's Body. + * @param disableGameObject Also deactivate this Game Object. Default false. + * @param hideGameObject Also hide this Game Object. Default false. */ disableBody(disableGameObject?: boolean, hideGameObject?: boolean): this; /** - * Syncs the Bodies position and size with its parent Game Object. + * Syncs the Body's position and size with its parent Game Object. * You don't need to call this for Dynamic Bodies, as it happens automatically. * But for Static bodies it's a useful way of modifying the position of a Static Body * in the Physics World, based on its Game Object. @@ -36789,121 +52045,136 @@ declare namespace Phaser { } /** - * [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. The higher than friction, the faster the body will slow down once force stops being applied to it. */ interface Friction { /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of horizontal friction to apply. + * @param y The amount of vertical friction to apply. Default x. */ setFriction(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving horizontally in the X axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. */ setFrictionX(x: number): this; /** - * [description] - * @param y [description] + * Sets the friction (e.g. the amount of velocity reduced over time) of the physics body when moving vertically in the Y axis. + * The higher than friction, the faster the body will slow down once force stops being applied to it. + * @param x The amount of friction to apply. */ - setFrictionY(y: number): this; + setFrictionY(x: number): this; } /** - * [description] + * Provides methods for setting the gravity properties of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. */ interface Gravity { /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Set the X and Y values of the gravitational pull to act upon this Arcade Physics Game Object. Values can be positive or negative. Larger values result in a stronger effect. + * + * If only one value is provided, this value will be used for both the X and Y axis. + * @param x The gravitational force to be applied to the X-axis. + * @param y The gravitational force to be applied to the Y-axis. If this is not specified, the X value will be used. Default x. */ setGravity(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Set the gravitational force to be applied to the X axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param x The gravitational force to be applied to the X-axis. */ setGravityX(x: number): this; /** - * [description] - * @param y [description] + * Set the gravitational force to be applied to the Y axis. Value can be positive or negative. Larger values result in a stronger effect. + * @param y The gravitational force to be applied to the Y-axis. */ setGravityY(y: number): this; } /** - * [description] + * Provides methods used for setting the immovable properties of an Arcade Physics Body. */ interface Immovable { /** - * [description] - * @param value [description] Default true. + * Sets Whether this Body can be moved by collisions with another Body. + * @param value Sets if this body can be moved by collisions with another Body. Default true. */ setImmovable(value?: boolean): this; } /** - * [description] + * Provides methods used for setting the mass properties of an Arcade Physics Body. */ interface Mass { /** - * [description] - * @param value [description] + * Sets the mass of the physics body + * @param value New value for the mass of the body. */ setMass(value: number): this; } /** - * [description] + * Provides methods for setting the size of an Arcade Physics Game Object. + * Should be applied as a mixin and not used directly. */ interface Size { /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the body offset. This allows you to adjust the difference between the center of the body + * and the x and y coordinates of the parent Game Object. + * @param x The amount to offset the body from the parent Game Object along the x-axis. + * @param y The amount to offset the body from the parent Game Object along the y-axis. Defaults to the value given for the x-axis. Default x. */ setOffset(x: number, y?: number): this; /** - * [description] - * @param width [description] - * @param height [description] - * @param center [description] Default true. + * Sets the size of this physics body. Setting the size does not adjust the dimensions + * of the parent Game Object. + * @param width The new width of the physics body, in pixels. + * @param height The new height of the physics body, in pixels. + * @param center Should the body be re-positioned so its center aligns with the parent Game Object? Default true. */ setSize(width: number, height: number, center?: boolean): this; /** - * [description] - * @param radius [description] - * @param offsetX [description] - * @param offsetY [description] + * Sets this physics body to use a circle for collision instead of a rectangle. + * @param radius The radius of the physics body, in pixels. + * @param offsetX The amount to offset the body from the parent Game Object along the x-axis. + * @param offsetY The amount to offset the body from the parent Game Object along the y-axis. */ setCircle(radius: number, offsetX?: number, offsetY?: number): this; } /** - * [description] + * Provides methods for modifying the velocity of an Arcade Physics body. + * + * Should be applied as a mixin and not used directly. */ interface Velocity { /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the velocity of the Body. + * @param x The horizontal velocity of the body. Positive values move the body to the right, while negative values move it to the left. + * @param y The vertical velocity of the body. Positive values move the body down, while negative values move it up. Default x. */ setVelocity(x: number, y?: number): this; /** - * [description] - * @param x [description] + * Sets the horizontal component of the body's velocity. + * + * Positive values move the body to the right, while negative values move it to the left. + * @param x The new horizontal velocity. */ setVelocityX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical component of the body's velocity. + * + * Positive values move the body down, while negative values move it up. + * @param y The new vertical velocity of the body. */ setVelocityY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the maximum velocity of the body. + * @param x The new maximum horizontal velocity. + * @param y The new maximum vertical velocity. Default x. */ setMaxVelocity(x: number, y?: number): this; } @@ -36911,50 +52182,139 @@ declare namespace Phaser { } /** - * [description] + * Dynamic Body. */ var DYNAMIC_BODY: number; /** - * [description] + * Static Body. */ var STATIC_BODY: number; /** - * [description] + * Arcade Physics Group containing Dynamic Bodies. */ var GROUP: number; /** - * [description] + * A Tilemap Layer. */ var TILEMAPLAYER: number; /** - * [description] + * Facing no direction (initial value). */ var FACING_NONE: number; /** - * [description] + * Facing up. */ var FACING_UP: number; /** - * [description] + * Facing down. */ var FACING_DOWN: number; /** - * [description] + * Facing left. */ var FACING_LEFT: number; /** - * [description] + * Facing right. */ var FACING_RIGHT: number; + namespace Events { + /** + * The Arcade Physics World Collide Event. + * + * This event is dispatched by an Arcade Physics World instance if two bodies collide _and_ at least + * one of them has their [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. + * + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('collide', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const COLLIDE: any; + + /** + * The Arcade Physics World Overlap Event. + * + * This event is dispatched by an Arcade Physics World instance if two bodies overlap _and_ at least + * one of them has their [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. + * + * It provides an alternative means to handling overlap events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('overlap', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const OVERLAP: any; + + /** + * The Arcade Physics World Pause Event. + * + * This event is dispatched by an Arcade Physics World instance when it is paused. + * + * Listen to it from a Scene using: `this.physics.world.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Arcade Physics World Resume Event. + * + * This event is dispatched by an Arcade Physics World instance when it resumes from a paused state. + * + * Listen to it from a Scene using: `this.physics.world.on('resume', listener)`. + */ + const RESUME: any; + + /** + * The Arcade Physics Tile Collide Event. + * + * This event is dispatched by an Arcade Physics World instance if a body collides with a Tile _and_ + * has its [onCollide]{@link Phaser.Physics.Arcade.Body#onCollide} property set to `true`. + * + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('tilecollide', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const TILE_COLLIDE: any; + + /** + * The Arcade Physics Tile Overlap Event. + * + * This event is dispatched by an Arcade Physics World instance if a body overlaps with a Tile _and_ + * has its [onOverlap]{@link Phaser.Physics.Arcade.Body#onOverlap} property set to `true`. + * + * It provides an alternative means to handling overlap events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('tileoverlap', listener)`. + * + * Please note that 'collide' and 'overlap' are two different things in Arcade Physics. + */ + const TILE_OVERLAP: any; + + /** + * The Arcade Physics World Bounds Event. + * + * This event is dispatched by an Arcade Physics World instance if a body makes contact with the world bounds _and_ + * it has its [onWorldBounds]{@link Phaser.Physics.Arcade.Body#onWorldBounds} property set to `true`. + * + * It provides an alternative means to handling collide events rather than using the callback approach. + * + * Listen to it from a Scene using: `this.physics.world.on('worldbounds', listener)`. + */ + const WORLD_BOUNDS: any; + + } + /** * The Arcade Physics Factory allows you to easily create Arcade Physics enabled Game Objects. * Objects that are created by this Factory are automatically added to the physics world. @@ -36982,7 +52342,7 @@ declare namespace Phaser { sys: Phaser.Scenes.Systems; /** - * Create a new Arcade Physics Collider object. + * Creates a new Arcade Physics Collider object. * @param object1 The first object to check for collision. * @param object2 The second object to check for collision. * @param collideCallback The callback to invoke when the two objects collide. @@ -36992,7 +52352,7 @@ declare namespace Phaser { collider(object1: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], object2: Phaser.GameObjects.GameObject | Phaser.GameObjects.GameObject[] | Phaser.GameObjects.Group | Phaser.GameObjects.Group[], collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): Phaser.Physics.Arcade.Collider; /** - * Create a new Arcade Physics Collider Overlap object. + * Creates a new Arcade Physics Collider Overlap object. * @param object1 The first object to check for overlap. * @param object2 The second object to check for overlap. * @param collideCallback The callback to invoke when the two objects collide. @@ -37003,8 +52363,8 @@ declare namespace Phaser { /** * Adds an Arcade Physics Body to the given Game Object. - * @param gameObject [description] - * @param isStatic Set to true to create a Static body, otherwise it will create a Dynamic body. Default false. + * @param gameObject A Game Object. + * @param isStatic Create a Static body (true) or Dynamic body (false). Default false. */ existing(gameObject: Phaser.GameObjects.GameObject, isStatic?: boolean): Phaser.GameObjects.GameObject; @@ -37047,18 +52407,18 @@ declare namespace Phaser { /** * Creates a Static Physics Group object. * All Game Objects created by this Group will automatically be static Arcade Physics objects. - * @param children [description] - * @param config [description] + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. */ - staticGroup(children?: object | object[], config?: GroupConfig): Phaser.Physics.Arcade.StaticGroup; + staticGroup(children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig): Phaser.Physics.Arcade.StaticGroup; /** * Creates a Physics Group object. * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. - * @param children [description] - * @param config [description] + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. */ - group(children?: object | object[], config?: PhysicsGroupConfig): Phaser.Physics.Arcade.Group; + group(children?: Phaser.GameObjects.GameObject[] | PhysicsGroupConfig | GroupCreateConfig, config?: PhysicsGroupConfig | GroupCreateConfig): Phaser.Physics.Arcade.Group; /** * Destroys this Factory. @@ -37068,295 +52428,326 @@ declare namespace Phaser { } /** - * [description] - * @param body1 [description] - * @param body2 [description] - * @param overlapOnly [description] - * @param bias [description] + * Calculates and returns the horizontal overlap between two arcade physics bodies and sets their properties + * accordingly, including: `touching.left`, `touching.right`, `touching.none` and `overlapX'. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly Is this an overlap only check, or part of separation? + * @param bias A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). */ function GetOverlapX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): number; /** - * [description] - * @param body1 [description] - * @param body2 [description] - * @param overlapOnly [description] - * @param bias [description] + * Calculates and returns the vertical overlap between two arcade physics bodies and sets their properties + * accordingly, including: `touching.up`, `touching.down`, `touching.none` and `overlapY'. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly Is this an overlap only check, or part of separation? + * @param bias A value added to the delta values during collision checks. Increase it to prevent sprite tunneling(sprites passing through another instead of colliding). */ function GetOverlapY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): number; /** * An Arcade Physics Group object. * - * All Game Objects created by this Group will automatically be dynamic Arcade Physics objects. + * All Game Objects created by this Group will automatically be given dynamic Arcade Physics bodies. + * + * Its static counterpart is {@link Phaser.Physics.Arcade.StaticGroup}. */ class Group extends Phaser.GameObjects.Group { /** * - * @param world [description] - * @param scene [description] - * @param children [description] - * @param config [description] + * @param world The physics simulation. + * @param scene The scene this group belongs to. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. */ - constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children: any[], config?: PhysicsGroupConfig); + constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | PhysicsGroupConfig | GroupCreateConfig, config?: PhysicsGroupConfig | GroupCreateConfig); /** - * [description] + * The physics simulation. */ world: Phaser.Physics.Arcade.World; /** - * The class to create new group members from. + * The class to create new Group members from. + * + * This should be either `Phaser.Physics.Arcade.Image`, `Phaser.Physics.Arcade.Sprite`, or a class extending one of those. */ - classType: Phaser.Physics.Arcade.Sprite; + classType: GroupClassTypeConstructor; /** - * [description] + * The physics type of the Group's members. */ physicsType: integer; /** - * [description] + * Default physics properties applied to Game Objects added to the Group or created by the Group. Derived from the `config` argument. */ defaults: PhysicsGroupDefaults; /** - * [description] - * @param child [description] + * Enables a Game Object's Body and assigns `defaults`. Called when a Group member is added or created. + * @param child The Game Object being added. */ createCallbackHandler(child: Phaser.GameObjects.GameObject): void; /** - * [description] - * @param child [description] + * Disables a Game Object's Body. Called when a Group member is removed. + * @param child The Game Object being removed. */ removeCallbackHandler(child: Phaser.GameObjects.GameObject): void; /** - * [description] - * @param x [description] - * @param y [description] - * @param step [description] + * Sets the velocity of each Group member. + * @param x The horizontal velocity. + * @param y The vertical velocity. + * @param step The velocity increment. When set, the first member receives velocity (x, y), the second (x + step, y + step), and so on. Default 0. */ - setVelocity(x: number, y: number, step: number): Phaser.Physics.Arcade.Group; + setVelocity(x: number, y: number, step?: number): Phaser.Physics.Arcade.Group; /** - * [description] - * @param value [description] - * @param step [description] + * Sets the horizontal velocity of each Group member. + * @param value The velocity value. + * @param step The velocity increment. When set, the first member receives velocity (x), the second (x + step), and so on. Default 0. */ - setVelocityX(value: number, step: number): Phaser.Physics.Arcade.Group; + setVelocityX(value: number, step?: number): Phaser.Physics.Arcade.Group; /** - * [description] - * @param value [description] - * @param step [description] + * Sets the vertical velocity of each Group member. + * @param value The velocity value. + * @param step The velocity increment. When set, the first member receives velocity (y), the second (y + step), and so on. Default 0. */ - setVelocityY(value: number, step: number): Phaser.Physics.Arcade.Group; + setVelocityY(value: number, step?: number): Phaser.Physics.Arcade.Group; } /** - * [description] - * @param body1 [description] - * @param body2 [description] - * @param overlapOnly [description] - * @param bias [description] + * Separates two overlapping bodies on the X-axis (horizontally). + * + * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. + * + * The bodies won't be separated if there is no horizontal overlap between them, if they are static, or if either one uses custom logic for its separation. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly If `true`, the bodies will only have their overlap data set and no separation will take place. + * @param bias A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. */ function SeparateX(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): boolean; /** - * [description] - * @param body1 [description] - * @param body2 [description] - * @param overlapOnly [description] - * @param bias [description] + * Separates two overlapping bodies on the Y-axis (vertically). + * + * Separation involves moving two overlapping bodies so they don't overlap anymore and adjusting their velocities based on their mass. This is a core part of collision detection. + * + * The bodies won't be separated if there is no vertical overlap between them, if they are static, or if either one uses custom logic for its separation. + * @param body1 The first Body to separate. + * @param body2 The second Body to separate. + * @param overlapOnly If `true`, the bodies will only have their overlap data set and no separation will take place. + * @param bias A value to add to the delta value during overlap checking. Used to prevent sprite tunneling. */ function SeparateY(body1: Phaser.Physics.Arcade.Body, body2: Phaser.Physics.Arcade.Body, overlapOnly: boolean, bias: number): boolean; /** - * [description] + * A Static Arcade Physics Body. + * + * A Static Body never moves, and isn't automatically synchronized with its parent Game Object. + * That means if you make any change to the parent's origin, position, or scale after creating or adding the body, you'll need to update the Body manually. + * + * A Static Body can collide with other Bodies, but is never moved by collisions. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Body}. */ class StaticBody { /** * - * @param world [description] - * @param gameObject [description] + * @param world The Arcade Physics simulation this Static Body belongs to. + * @param gameObject The Game Object this Static Body belongs to. */ constructor(world: Phaser.Physics.Arcade.World, gameObject: Phaser.GameObjects.GameObject); /** - * [description] + * The Arcade Physics simulation this Static Body belongs to. */ world: Phaser.Physics.Arcade.World; /** - * [description] + * The Game Object this Static Body belongs to. */ gameObject: Phaser.GameObjects.GameObject; /** - * [description] + * Whether the Static Body's boundary is drawn to the debug display. */ debugShowBody: boolean; /** - * [description] + * The color of this Static Body on the debug display. */ debugBodyColor: integer; /** - * [description] + * Whether this Static Body is updated by the physics simulation. */ enable: boolean; /** - * [description] + * Whether this Static Body's boundary is circular (`true`) or rectangular (`false`). */ isCircle: boolean; /** - * [description] + * If this Static Body is circular, this is the unscaled radius of the Static Body's boundary, as set by {@link #setCircle}, in source pixels. + * The true radius is equal to `halfWidth`. */ radius: number; /** - * [description] + * The offset of this Static Body's actual position from any updated position. + * + * Unlike a dynamic Body, a Static Body does not follow its Game Object. As such, this offset is only applied when resizing the Static Body. */ offset: Phaser.Math.Vector2; /** - * [description] + * The position of this Static Body within the simulation. */ position: Phaser.Math.Vector2; /** - * [description] + * The width of the Static Body's boundary, in pixels. + * If the Static Body is circular, this is also the Static Body's diameter. */ width: number; /** - * [description] + * The height of the Static Body's boundary, in pixels. + * If the Static Body is circular, this is also the Static Body's diameter. */ height: number; /** - * [description] + * Half the Static Body's width, in pixels. + * If the Static Body is circular, this is also the Static Body's radius. */ halfWidth: number; /** - * [description] + * Half the Static Body's height, in pixels. + * If the Static Body is circular, this is also the Static Body's radius. */ halfHeight: number; /** - * [description] + * The center of the Static Body's boundary. + * This is the midpoint of its `position` (top-left corner) and its bottom-right corner. */ center: Phaser.Math.Vector2; /** - * [description] + * A constant zero velocity used by the Arcade Physics simulation for calculations. */ - velocity: Phaser.Math.Vector2; + readonly velocity: Phaser.Math.Vector2; /** - * [description] + * A constant `false` value expected by the Arcade Physics simulation. */ - allowGravity: boolean; + readonly allowGravity: boolean; /** - * [description] + * Gravitational force applied specifically to this Body. Values are in pixels per second squared. Always zero for a Static Body. */ - gravity: Phaser.Math.Vector2; + readonly gravity: Phaser.Math.Vector2; /** - * [description] + * Rebound, or restitution, following a collision, relative to 1. Always zero for a Static Body. */ - bounce: Phaser.Math.Vector2; + readonly bounce: Phaser.Math.Vector2; /** - * [description] + * Whether the simulation emits a `worldbounds` event when this StaticBody collides with the world boundary. + * Always false for a Static Body. (Static Bodies never collide with the world boundary and never trigger a `worldbounds` event.) */ - onWorldBounds: boolean; + readonly onWorldBounds: boolean; /** - * [description] + * Whether the simulation emits a `collide` event when this StaticBody collides with another. */ onCollide: boolean; /** - * [description] + * Whether the simulation emits an `overlap` event when this StaticBody overlaps with another. */ onOverlap: boolean; /** - * [description] + * The StaticBody's inertia, relative to a default unit (1). With `bounce`, this affects the exchange of momentum (velocities) during collisions. */ mass: number; /** - * [description] + * Whether this object can be moved by collisions with another body. */ immovable: boolean; /** - * [description] + * A flag disabling the default horizontal separation of colliding bodies. Pass your own `collideHandler` to the collider. */ customSeparateX: boolean; /** - * [description] + * A flag disabling the default vertical separation of colliding bodies. Pass your own `collideHandler` to the collider. */ customSeparateY: boolean; /** - * [description] + * The amount of horizontal overlap (before separation), if this Body is colliding with another. */ overlapX: number; /** - * [description] + * The amount of vertical overlap (before separation), if this Body is colliding with another. */ overlapY: number; /** - * [description] + * The amount of overlap (before separation), if this StaticBody is circular and colliding with another circular body. */ overlapR: number; /** - * [description] + * Whether this StaticBody has ever overlapped with another while both were not moving. */ embedded: boolean; /** - * [description] + * Whether this StaticBody interacts with the world boundary. + * Always false for a Static Body. (Static Bodies never collide with the world boundary.) */ - collideWorldBounds: boolean; + readonly collideWorldBounds: boolean; /** - * [description] + * Whether this StaticBody is checked for collisions and for which directions. You can set `checkCollision.none = false` to disable collision checks. */ checkCollision: ArcadeBodyCollision; /** - * [description] + * Whether this StaticBody has ever collided with another body and in which direction. */ touching: ArcadeBodyCollision; /** - * [description] + * Whether this StaticBody was colliding with another body during the last step or any previous step, and in which direction. */ wasTouching: ArcadeBodyCollision; /** - * [description] + * Whether this StaticBody has ever collided with a tile or the world boundary. */ blocked: ArcadeBodyCollision; /** - * [description] + * The StaticBody's physics type (static by default). */ physicsType: integer; @@ -37376,181 +52767,193 @@ declare namespace Phaser { updateFromGameObject(): Phaser.Physics.Arcade.StaticBody; /** - * [description] - * @param x [description] - * @param y [description] + * Sets the offset of the body. + * @param x The horizontal offset of the Body from the Game Object's center. + * @param y The vertical offset of the Body from the Game Object's center. */ setOffset(x: number, y: number): Phaser.Physics.Arcade.StaticBody; /** - * [description] - * @param width [description] - * @param height [description] - * @param offsetX [description] - * @param offsetY [description] + * Sets the size of the body. + * Resets the width and height to match current frame, if no width and height provided and a frame is found. + * @param width The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width. + * @param height The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height. + * @param offsetX The horizontal offset of the Body from the Game Object's center. + * @param offsetY The vertical offset of the Body from the Game Object's center. */ - setSize(width: number, height: number, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.StaticBody; + setSize(width?: integer, height?: integer, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.StaticBody; /** - * [description] - * @param radius [description] - * @param offsetX [description] - * @param offsetY [description] + * Sets this Static Body to have a circular body and sets its sizes and position. + * @param radius The radius of the StaticBody, in pixels. + * @param offsetX The horizontal offset of the StaticBody from its Game Object, in pixels. + * @param offsetY The vertical offset of the StaticBody from its Game Object, in pixels. */ setCircle(radius: number, offsetX?: number, offsetY?: number): Phaser.Physics.Arcade.StaticBody; /** - * [description] + * Updates the StaticBody's `center` from its `position` and dimensions. */ updateCenter(): void; /** - * [description] - * @param x [description] - * @param y [description] + * Resets this Body to the given coordinates. Also positions its parent Game Object to the same coordinates. + * Similar to `updateFromGameObject`, but doesn't modify the Body's dimensions. + * @param x The x coordinate to reset the body to. If not given will use the parent Game Object's coordinate. + * @param y The y coordinate to reset the body to. If not given will use the parent Game Object's coordinate. */ - reset(x: number, y: number): void; + reset(x?: number, y?: number): void; /** - * [description] + * NOOP function. A Static Body cannot be stopped. */ stop(): Phaser.Physics.Arcade.StaticBody; /** - * [description] - * @param obj [description] + * Returns the x and y coordinates of the top left and bottom right points of the StaticBody. + * @param obj The object which will hold the coordinates of the bounds. */ getBounds(obj: ArcadeBodyBounds): ArcadeBodyBounds; /** - * [description] - * @param x [description] - * @param y [description] + * Checks to see if a given x,y coordinate is colliding with this Static Body. + * @param x The x coordinate to check against this body. + * @param y The y coordinate to check against this body. */ hitTest(x: number, y: number): boolean; /** - * [description] + * NOOP + */ + postUpdate(): void; + + /** + * The absolute (non-negative) change in this StaticBody's horizontal position from the previous step. Always zero. */ deltaAbsX(): number; /** - * [description] + * The absolute (non-negative) change in this StaticBody's vertical position from the previous step. Always zero. */ deltaAbsY(): number; /** - * [description] + * The change in this StaticBody's horizontal position from the previous step. Always zero. */ deltaX(): number; /** - * [description] + * The change in this StaticBody's vertical position from the previous step. Always zero. */ deltaY(): number; /** - * [description] + * The change in this StaticBody's rotation from the previous step. Always zero. */ deltaZ(): number; /** - * [description] + * Disables this Body and marks it for destruction during the next step. */ destroy(): void; /** - * [description] - * @param graphic [description] + * Draws a graphical representation of the StaticBody for visual debugging purposes. + * @param graphic The Graphics object to use for the debug drawing of the StaticBody. */ drawDebug(graphic: Phaser.GameObjects.Graphics): void; /** - * [description] + * Indicates whether the StaticBody is going to be showing a debug visualization during postUpdate. */ willDrawDebug(): boolean; /** - * [description] - * @param value [description] + * Sets the Mass of the StaticBody. Will set the Mass to 0.1 if the value passed is less than or equal to zero. + * @param value The value to set the Mass to. Values of zero or less are changed to 0.1. */ setMass(value: number): Phaser.Physics.Arcade.StaticBody; /** - * [description] + * The x coordinate of the StaticBody. */ x: number; /** - * [description] + * The y coordinate of the StaticBody. */ y: number; /** - * [description] + * Returns the left-most x coordinate of the area of the StaticBody. */ readonly left: number; /** - * [description] + * The right-most x coordinate of the area of the StaticBody. */ readonly right: number; /** - * [description] + * The highest y coordinate of the area of the StaticBody. */ readonly top: number; /** - * [description] + * The lowest y coordinate of the area of the StaticBody. (y + height) */ readonly bottom: number; } /** - * [description] + * An Arcade Physics Static Group object. + * + * All Game Objects created by this Group will automatically be given static Arcade Physics bodies. + * + * Its dynamic counterpart is {@link Phaser.Physics.Arcade.Group}. */ class StaticGroup extends Phaser.GameObjects.Group { /** * - * @param world [description] - * @param scene [description] - * @param children [description] - * @param config [description] + * @param world The physics simulation. + * @param scene The scene this group belongs to. + * @param children Game Objects to add to this group; or the `config` argument. + * @param config Settings for this group. */ - constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children: any[], config: GroupConfig); + constructor(world: Phaser.Physics.Arcade.World, scene: Phaser.Scene, children?: Phaser.GameObjects.GameObject[] | GroupConfig | GroupCreateConfig, config?: GroupConfig | GroupCreateConfig); /** - * [description] + * The physics simulation. */ world: Phaser.Physics.Arcade.World; /** - * [description] + * The scene this group belongs to. */ physicsType: integer; /** - * [description] - * @param child [description] + * Adds a static physics body to the new group member (if it lacks one) and adds it to the simulation. + * @param child The new group member. */ createCallbackHandler(child: Phaser.GameObjects.GameObject): void; /** - * [description] - * @param child [description] + * Disables the group member's physics body, removing it from the simulation. + * @param child The group member being removed. */ removeCallbackHandler(child: Phaser.GameObjects.GameObject): void; /** - * [description] - * @param entries [description] + * Refreshes the group. + * @param entries The newly created group members. */ - createMultipleCallbackHandler(entries: object): void; + createMultipleCallbackHandler(entries: Phaser.GameObjects.GameObject[]): void; /** - * [description] + * Resets each Body to the position of its parent Game Object. + * Body sizes aren't changed (use {@link Phaser.Physics.Arcade.Components.Enable#refreshBody} for that). */ refresh(): Phaser.Physics.Arcade.StaticGroup; @@ -37558,11 +52961,11 @@ declare namespace Phaser { namespace Tilemap { /** - * [description] - * @param tile [description] - * @param sprite [description] + * A function to process the collision callbacks between a single tile and an Arcade Physics enabled Game Object. + * @param tile The Tile to process. + * @param sprite The Game Object to process with the Tile. */ - function ProcessTileCallbacks(tile: Phaser.Tilemaps.Tilemap, sprite: Phaser.GameObjects.Sprite): boolean; + function ProcessTileCallbacks(tile: Phaser.Tilemaps.Tile, sprite: Phaser.GameObjects.Sprite): boolean; /** * Internal function to process the separation of a physics body from a tile. @@ -37580,39 +52983,41 @@ declare namespace Phaser { /** * The core separation function to separate a physics body and a tile. - * @param i [description] + * @param i The index of the tile within the map data. * @param body The Body object to separate. * @param tile The tile to collide against. - * @param tileWorldRect [description] + * @param tileWorldRect A rectangle-like object defining the dimensions of the tile. * @param tilemapLayer The tilemapLayer to collide against. - * @param tileBias [description] + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. */ function SeparateTile(i: number, body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileWorldRect: Phaser.Geom.Rectangle, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, tileBias: number): boolean; /** * Check the body against the given tile on the X axis. + * Used internally by the SeparateTile function. * @param body The Body object to separate. * @param tile The tile to check. - * @param tileLeft [description] - * @param tileRight [description] - * @param tileBias [description] + * @param tileLeft The left position of the tile within the tile world. + * @param tileRight The right position of the tile within the tile world. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. */ function TileCheckX(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileLeft: number, tileRight: number, tileBias: number): number; /** * Check the body against the given tile on the Y axis. + * Used internally by the SeparateTile function. * @param body The Body object to separate. * @param tile The tile to check. - * @param tileTop [description] - * @param tileBottom [description] - * @param tileBias [description] + * @param tileTop The top position of the tile within the tile world. + * @param tileBottom The bottom position of the tile within the tile world. + * @param tileBias The tile bias value. Populated by the `World.TILE_BIAS` constant. */ function TileCheckY(body: Phaser.Physics.Arcade.Body, tile: Phaser.Tilemaps.Tile, tileTop: number, tileBottom: number, tileBias: number): number; /** - * [description] - * @param tileWorldRect [description] - * @param body [description] + * Checks for intersection between the given tile rectangle-like object and an Arcade Physics body. + * @param tileWorldRect A rectangle object that defines the tile placement in the world. + * @param body The body to check for intersection against. */ function TileIntersectsBody(tileWorldRect: Object, body: Phaser.Physics.Arcade.Body): boolean; @@ -38002,8 +53407,8 @@ declare namespace Phaser { protected update(time: number, delta: number): void; /** - * Advances the simulation by one step. - * @param delta The delta time amount, in ms, by which to advance the simulation. + * Advances the simulation by a time increment. + * @param delta The delta time amount, in seconds, by which to advance the simulation. */ step(delta: number): void; @@ -38015,21 +53420,21 @@ declare namespace Phaser { /** * Calculates a Body's velocity and updates its position. * @param body The Body to be updated. - * @param delta The delta value to be used in the motion calculations. + * @param delta The delta value to be used in the motion calculations, in seconds. */ updateMotion(body: Phaser.Physics.Arcade.Body, delta: number): void; /** * Calculates a Body's angular velocity. * @param body The Body to compute the velocity for. - * @param delta The delta value to be used in the calculation. + * @param delta The delta value to be used in the calculation, in seconds. */ computeAngularVelocity(body: Phaser.Physics.Arcade.Body, delta: number): void; /** * Calculates a Body's per-axis velocity. * @param body The Body to compute the velocity for. - * @param delta The delta value to be used in the calculation. + * @param delta The delta value to be used in the calculation, in seconds. */ computeVelocity(body: Phaser.Physics.Arcade.Body, delta: number): void; @@ -38068,11 +53473,11 @@ declare namespace Phaser { /** * Tests if Game Objects overlap. - * @param object1 [description] - * @param object2 [description] - * @param overlapCallback [description] - * @param processCallback [description] - * @param callbackContext [description] + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param overlapCallback An optional callback function that is called if the objects overlap. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they overlap. If this is set then `overlapCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. */ overlap(object1: ArcadeColliderType, object2?: ArcadeColliderType, overlapCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; @@ -38093,90 +53498,25 @@ declare namespace Phaser { * for 'arcade' style games it lacks stability when multiple objects are in close proximity or resting upon each other. * The separation that stops two objects penetrating may create a new penetration against a different object. If you * require a high level of stability please consider using an alternative physics system, such as Matter.js. - * @param object1 [description] - * @param object2 [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] + * @param object1 The first object or array of objects to check. + * @param object2 The second object or array of objects to check, or `undefined`. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. */ collide(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any): boolean; /** - * Helper for Phaser.Physics.Arcade.World#collide. - * @param object1 [description] - * @param object2 [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] - * @param overlapOnly [description] + * Internal handler for Sprite vs. Tilemap collisions. + * Please use Phaser.Physics.Arcade.World#collide instead. + * @param sprite The first object to check for collision. + * @param tilemapLayer The second object to check for collision. + * @param collideCallback An optional callback function that is called if the objects collide. + * @param processCallback An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then `collideCallback` will only be called if this callback returns `true`. + * @param callbackContext The context in which to run the callbacks. + * @param overlapOnly Whether this is a collision or overlap check. */ - collideObjects(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any, overlapOnly?: boolean): boolean; - - /** - * Helper for Phaser.Physics.Arcade.World#collide and Phaser.Physics.Arcade.World#overlap. - * @param object1 [description] - * @param object2 [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] - * @param overlapOnly [description] - */ - collideHandler(object1: ArcadeColliderType, object2?: ArcadeColliderType, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any, overlapOnly?: boolean): boolean; - - /** - * Handler for Sprite vs. Sprite collisions. - * @param sprite1 [description] - * @param sprite2 [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] - * @param overlapOnly [description] - */ - collideSpriteVsSprite(sprite1: Phaser.GameObjects.GameObject, sprite2: Phaser.GameObjects.GameObject, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any, overlapOnly: boolean): boolean; - - /** - * Handler for Sprite vs. Group collisions. - * @param sprite [description] - * @param group [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] - * @param overlapOnly [description] - */ - collideSpriteVsGroup(sprite: Phaser.GameObjects.GameObject, group: Phaser.GameObjects.Group, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any, overlapOnly: boolean): boolean; - - /** - * Helper for Group vs. Tilemap collisions. - * @param group [description] - * @param tilemapLayer [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] - * @param overlapOnly [description] - */ - collideGroupVsTilemapLayer(group: Phaser.GameObjects.Group, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any, overlapOnly: boolean): boolean; - - /** - * Helper for Sprite vs. Tilemap collisions. - * @param sprite [description] - * @param tilemapLayer [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] - * @param overlapOnly [description] - */ - collideSpriteVsTilemapLayer(sprite: Phaser.GameObjects.GameObject, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any, overlapOnly: boolean): boolean; - - /** - * Helper for Group vs. Group collisions. - * @param group1 [description] - * @param group2 [description] - * @param collideCallback [description] - * @param processCallback [description] - * @param callbackContext [description] - * @param overlapOnly [description] - */ - collideGroupVsGroup(group1: Phaser.GameObjects.Group, group2: Phaser.GameObjects.Group, collideCallback: ArcadePhysicsCallback, processCallback: ArcadePhysicsCallback, callbackContext: any, overlapOnly: boolean): boolean; + collideSpriteVsTilemapLayer(sprite: Phaser.GameObjects.GameObject, tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, collideCallback?: ArcadePhysicsCallback, processCallback?: ArcadePhysicsCallback, callbackContext?: any, overlapOnly?: boolean): boolean; /** * Wrap an object's coordinates (or several objects' coordinates) within {@link Phaser.Physics.Arcade.World#bounds}. @@ -38398,7 +53738,7 @@ declare namespace Phaser { /** * [description] - * @param delta [description] + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(delta: number): void; @@ -38419,22 +53759,22 @@ declare namespace Phaser { skipHash(): boolean; /** - * [description] + * Determines whether the body collides with the `other` one or not. * @param other [description] */ touches(other: Phaser.Physics.Impact.Body): boolean; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] + * Reset the size and position of the physics body. + * @param x The x coordinate to position the body. + * @param y The y coordinate to position the body. + * @param width The width of the body. + * @param height The height of the body. */ resetSize(x: number, y: number, width: number, height: number): Phaser.Physics.Impact.Body; /** - * [description] + * Export this body object to JSON. */ toJSON(): JSONImpactBody; @@ -38588,47 +53928,50 @@ declare namespace Phaser { namespace Components { /** - * [description] + * The Impact Acceleration component. + * Should be applied as a mixin. */ interface Acceleration { /** - * [description] - * @param x [description] + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. */ - setAccelerationX(x: number): Phaser.GameObjects.GameObject; + setAccelerationX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. */ - setAccelerationY(y: number): Phaser.GameObjects.GameObject; + setAccelerationY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. */ - setAcceleration(x: number, y: number): Phaser.GameObjects.GameObject; + setAcceleration(x: number, y: number): this; } /** - * [description] + * The Impact Body Scale component. + * Should be applied as a mixin. */ interface BodyScale { /** - * [description] - * @param width [description] - * @param height [description] Default width. + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. */ - setBodySize(width: number, height?: number): Phaser.GameObjects.GameObject; + setBodySize(width: number, height?: number): this; /** - * [description] - * @param scaleX [description] - * @param scaleY [description] + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. */ - setBodyScale(scaleX: number, scaleY?: number): Phaser.GameObjects.GameObject; + setBodyScale(scaleX: number, scaleY?: number): this; } /** - * [description] + * The Impact Body Type component. + * Should be applied as a mixin. */ interface BodyType { /** @@ -38650,27 +53993,30 @@ declare namespace Phaser { } /** - * [description] + * The Impact Bounce component. + * Should be applied as a mixin. */ interface Bounce { /** - * [description] - * @param value [description] + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) */ setBounce(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. */ setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) */ bounce: number; } /** - * [description] + * The Impact Check Against component. + * Should be applied as a mixin. */ interface CheckAgainst { /** @@ -38700,7 +54046,8 @@ declare namespace Phaser { } /** - * [description] + * The Impact Collides component. + * Should be applied as a mixin. */ interface Collides { /** @@ -38736,7 +54083,8 @@ declare namespace Phaser { } /** - * [description] + * The Impact Debug component. + * Should be applied as a mixin. */ interface Debug { /** @@ -38766,7 +54114,8 @@ declare namespace Phaser { } /** - * [description] + * The Impact Friction component. + * Should be applied as a mixin. */ interface Friction { /** @@ -38788,7 +54137,8 @@ declare namespace Phaser { } /** - * [description] + * The Impact Gravity component. + * Should be applied as a mixin. */ interface Gravity { /** @@ -38803,7 +54153,8 @@ declare namespace Phaser { } /** - * [description] + * The Impact Offset component. + * Should be applied as a mixin. */ interface Offset { /** @@ -38817,7 +54168,8 @@ declare namespace Phaser { } /** - * [description] + * The Impact Set Game Object component. + * Should be applied as a mixin. */ interface SetGameObject { /** @@ -38833,35 +54185,66 @@ declare namespace Phaser { } /** - * [description] + * The Impact Velocity component. + * Should be applied as a mixin. */ interface Velocity { /** - * [description] - * @param x [description] + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. */ - setVelocityX(x: number): Phaser.GameObjects.GameObject; + setVelocityX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. */ - setVelocityY(y: number): Phaser.GameObjects.GameObject; + setVelocityY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. */ - setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setVelocity(x: number, y?: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. */ - setMaxVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setMaxVelocity(x: number, y?: number): this; } } + namespace Events { + /** + * 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)`. + */ + const COLLIDE: any; + + /** + * 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)`. + */ + const PAUSE: any; + + /** + * 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)`. + */ + const RESUME: any; + + } + /** * 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. @@ -38869,12 +54252,12 @@ declare namespace Phaser { class Factory { /** * - * @param world [description] + * @param world A reference to the Impact Physics world. */ constructor(world: Phaser.Physics.Impact.World); /** - * [description] + * A reference to the Impact Physics world. */ world: Phaser.Physics.Impact.World; @@ -38884,22 +54267,22 @@ declare namespace Phaser { sys: Phaser.Scenes.Systems; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] + * Creates a new ImpactBody object and adds it to the physics simulation. + * @param x The horizontal position of the body in the physics world. + * @param y The vertical position of the body in the physics world. + * @param width The width of the body. + * @param height The height of the body. */ body(x: number, y: number, width: number, height: number): Phaser.Physics.Impact.ImpactBody; /** * Adds an Impact Physics Body to the given Game Object. - * @param gameObject [description] + * @param gameObject The Game Object to receive the physics body. */ existing(gameObject: Phaser.GameObjects.GameObject): Phaser.GameObjects.GameObject; /** - * [description] + * Creates a new ImpactImage object and adds it to the physics world. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. * @param key The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. @@ -38908,7 +54291,7 @@ declare namespace Phaser { image(x: number, y: number, key: string, frame?: string | integer): Phaser.Physics.Impact.ImpactImage; /** - * [description] + * Creates a new ImpactSprite object and adds it to the physics world. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. * @param key The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. @@ -38925,7 +54308,7 @@ declare namespace Phaser { /** * [description] - * @param delta [description] + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. * @param vel [description] * @param accel [description] * @param friction [description] @@ -38940,9 +54323,9 @@ declare namespace Phaser { /** * * @param world [description] - * @param x [description] - * @param y [description] - * @param width [description] + * @param x x - The horizontal position of this physics body in the world. + * @param y y - The vertical position of this physics body in the world. + * @param width The width of the physics body in the world. * @param height [description] */ constructor(world: Phaser.Physics.Impact.World, x: number, y: number, width: number, height: number); @@ -38983,37 +54366,37 @@ declare namespace Phaser { maxVel: Object; /** - * [description] - * @param x [description] + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. */ - setAccelerationX(x: number): Phaser.GameObjects.GameObject; + setAccelerationX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. */ - setAccelerationY(y: number): Phaser.GameObjects.GameObject; + setAccelerationY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. */ - setAcceleration(x: number, y: number): Phaser.GameObjects.GameObject; + setAcceleration(x: number, y: number): this; /** - * [description] - * @param width [description] - * @param height [description] Default width. + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. */ - setBodySize(width: number, height?: number): Phaser.GameObjects.GameObject; + setBodySize(width: number, height?: number): this; /** - * [description] - * @param scaleX [description] - * @param scaleY [description] + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. */ - setBodyScale(scaleX: number, scaleY?: number): Phaser.GameObjects.GameObject; + setBodyScale(scaleX: number, scaleY?: number): this; /** * [description] @@ -39036,19 +54419,20 @@ declare namespace Phaser { setTypeB(): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) */ setBounce(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. */ setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) */ bounce: number; @@ -39200,30 +54584,30 @@ declare namespace Phaser { syncGameObject(): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. */ - setVelocityX(x: number): Phaser.GameObjects.GameObject; + setVelocityX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. */ - setVelocityY(y: number): Phaser.GameObjects.GameObject; + setVelocityY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. */ - setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setVelocity(x: number, y?: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. */ - setMaxVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setMaxVelocity(x: number, y?: number): this; } @@ -39238,7 +54622,7 @@ declare namespace Phaser { class ImpactImage extends Phaser.GameObjects.Image implements Phaser.Physics.Impact.Components.Acceleration, Phaser.Physics.Impact.Components.BodyScale, Phaser.Physics.Impact.Components.BodyType, Phaser.Physics.Impact.Components.Bounce, Phaser.Physics.Impact.Components.CheckAgainst, Phaser.Physics.Impact.Components.Collides, Phaser.Physics.Impact.Components.Debug, Phaser.Physics.Impact.Components.Friction, Phaser.Physics.Impact.Components.Gravity, Phaser.Physics.Impact.Components.Offset, Phaser.Physics.Impact.Components.SetGameObject, Phaser.Physics.Impact.Components.Velocity, Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Size, Phaser.GameObjects.Components.Texture, Phaser.GameObjects.Components.Tint, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * - * @param world [description] + * @param world The physics world of the Impact physics system. * @param x The horizontal position of this Game Object in the world. * @param y The vertical position of this Game Object in the world. * @param texture The key of the Texture this Game Object will use to render with, as stored in the Texture Manager. @@ -39247,37 +54631,37 @@ declare namespace Phaser { constructor(world: Phaser.Physics.Impact.World, x: number, y: number, texture: string, frame?: string | integer); /** - * [description] + * The Physics Body linked to an ImpactImage. */ body: Phaser.Physics.Impact.Body; /** - * [description] + * The size of the physics Body. */ size: Object; /** - * [description] + * The X and Y offset of the Body from the left and top of the Image. */ offset: Object; /** - * [description] + * The velocity, or rate of change the Body's position. Measured in pixels per second. */ vel: Object; /** - * [description] + * The acceleration is the rate of change of the velocity. Measured in pixels per second squared. */ accel: Object; /** - * [description] + * Friction between colliding bodies. */ friction: Object; /** - * [description] + * The maximum velocity of the body. */ maxVel: Object; @@ -39342,6 +54726,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -39364,6 +54749,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -39371,7 +54757,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -39506,12 +54892,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -39622,15 +55012,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -39666,6 +55056,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -39680,6 +55075,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -39694,6 +55094,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -39701,34 +55106,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -39736,6 +55171,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -39752,6 +55188,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -39776,21 +55248,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -39820,6 +55335,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -39943,8 +55463,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -39962,37 +55483,37 @@ declare namespace Phaser { setVisible(value: boolean): this; /** - * [description] - * @param x [description] + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. */ - setAccelerationX(x: number): Phaser.GameObjects.GameObject; + setAccelerationX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. */ - setAccelerationY(y: number): Phaser.GameObjects.GameObject; + setAccelerationY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. */ - setAcceleration(x: number, y: number): Phaser.GameObjects.GameObject; + setAcceleration(x: number, y: number): this; /** - * [description] - * @param width [description] - * @param height [description] Default width. + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. */ - setBodySize(width: number, height?: number): Phaser.GameObjects.GameObject; + setBodySize(width: number, height?: number): this; /** - * [description] - * @param scaleX [description] - * @param scaleY [description] + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. */ - setBodyScale(scaleX: number, scaleY?: number): Phaser.GameObjects.GameObject; + setBodyScale(scaleX: number, scaleY?: number): this; /** * [description] @@ -40015,19 +55536,20 @@ declare namespace Phaser { setTypeB(): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) */ setBounce(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. */ setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) */ bounce: number; @@ -40179,30 +55701,30 @@ declare namespace Phaser { syncGameObject(): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. */ - setVelocityX(x: number): Phaser.GameObjects.GameObject; + setVelocityX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. */ - setVelocityY(y: number): Phaser.GameObjects.GameObject; + setVelocityY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. */ - setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setVelocity(x: number, y?: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. */ - setMaxVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setMaxVelocity(x: number, y?: number): this; } @@ -40376,6 +55898,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -40398,6 +55921,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -40405,7 +55929,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -40540,12 +56064,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -40656,15 +56184,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -40700,6 +56228,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -40714,6 +56247,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -40728,6 +56266,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -40735,34 +56278,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -40770,6 +56343,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -40786,6 +56360,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -40810,21 +56420,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -40854,6 +56507,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -40977,8 +56635,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -40996,37 +56655,37 @@ declare namespace Phaser { setVisible(value: boolean): this; /** - * [description] - * @param x [description] + * Sets the horizontal acceleration of this body. + * @param x The amount of acceleration to apply. */ - setAccelerationX(x: number): Phaser.GameObjects.GameObject; + setAccelerationX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical acceleration of this body. + * @param y The amount of acceleration to apply. */ - setAccelerationY(y: number): Phaser.GameObjects.GameObject; + setAccelerationY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] + * Sets the horizontal and vertical acceleration of this body. + * @param x The amount of horizontal acceleration to apply. + * @param y The amount of vertical acceleration to apply. */ - setAcceleration(x: number, y: number): Phaser.GameObjects.GameObject; + setAcceleration(x: number, y: number): this; /** - * [description] - * @param width [description] - * @param height [description] Default width. + * Sets the size of the physics body. + * @param width The width of the body in pixels. + * @param height The height of the body in pixels. Default width. */ - setBodySize(width: number, height?: number): Phaser.GameObjects.GameObject; + setBodySize(width: number, height?: number): this; /** - * [description] - * @param scaleX [description] - * @param scaleY [description] + * Sets the scale of the physics body. + * @param scaleX The horizontal scale of the body. + * @param scaleY The vertical scale of the body. If not given, will use the horizontal scale value. */ - setBodyScale(scaleX: number, scaleY?: number): Phaser.GameObjects.GameObject; + setBodyScale(scaleX: number, scaleY?: number): this; /** * [description] @@ -41049,19 +56708,20 @@ declare namespace Phaser { setTypeB(): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the impact physics bounce, or restitution, value. + * @param value A value between 0 (no rebound) and 1 (full rebound) */ setBounce(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the minimum velocity the body is allowed to be moving to be considered for rebound. + * @param value The minimum allowed velocity. */ setMinBounceVelocity(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * The bounce, or restitution, value of this body. + * A value between 0 (no rebound) and 1 (full rebound) */ bounce: number; @@ -41213,30 +56873,30 @@ declare namespace Phaser { syncGameObject(): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. */ - setVelocityX(x: number): Phaser.GameObjects.GameObject; + setVelocityX(x: number): this; /** - * [description] - * @param y [description] + * Sets the vertical velocity of the physics body. + * @param y The vertical velocity value. */ - setVelocityY(y: number): Phaser.GameObjects.GameObject; + setVelocityY(y: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the horizontal and vertical velocities of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value. If not given, defaults to the horizontal value. Default x. */ - setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setVelocity(x: number, y?: number): this; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets the maximum velocity this body can travel at. + * @param x The maximum allowed horizontal velocity. + * @param y The maximum allowed vertical velocity. If not given, defaults to the horizontal value. Default x. */ - setMaxVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; + setMaxVelocity(x: number, y?: number): this; } @@ -41247,7 +56907,7 @@ declare namespace Phaser { * @param right [description] * @param weak [description] */ - function SeperateX(world: Phaser.Physics.Impact.World, left: Phaser.Physics.Impact.Body, right: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; + function SeparateX(world: Phaser.Physics.Impact.World, left: Phaser.Physics.Impact.Body, right: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; /** * [description] @@ -41256,13 +56916,13 @@ declare namespace Phaser { * @param bottom [description] * @param weak [description] */ - function SeperateY(world: Phaser.Physics.Impact.World, top: Phaser.Physics.Impact.Body, bottom: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; + function SeparateY(world: Phaser.Physics.Impact.World, top: Phaser.Physics.Impact.Body, bottom: Phaser.Physics.Impact.Body, weak?: Phaser.Physics.Impact.Body): void; /** * Impact Physics Solver - * @param world [description] - * @param bodyA [description] - * @param bodyB [description] + * @param world The Impact simulation to run the solver in. + * @param bodyA The first body in the collision. + * @param bodyB The second body in the collision. */ function Solver(world: Phaser.Physics.Impact.World, bodyA: Phaser.Physics.Impact.Body, bodyB: Phaser.Physics.Impact.Body): void; @@ -41308,15 +56968,15 @@ declare namespace Phaser { type WorldConfig = { /** - * [description] + * Sets {@link Phaser.Physics.Impact.World#gravity} */ gravity?: number; /** - * [description] + * The size of the cells used for the broadphase pass. Increase this value if you have lots of large objects in the world. */ cellSize?: number; /** - * [description] + * 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. */ timeScale?: number; /** @@ -41324,87 +56984,87 @@ declare namespace Phaser { */ maxStep?: number; /** - * [description] + * Sets {@link Phaser.Physics.Impact.World#debug}. */ debug?: boolean; /** - * [description] + * The maximum velocity a body can move. */ maxVelocity?: number; /** - * [description] + * Whether the Body's boundary is drawn to the debug display. */ debugShowBody?: boolean; /** - * [description] + * Whether the Body's velocity is drawn to the debug display. */ debugShowVelocity?: boolean; /** - * [description] + * The color of this Body on the debug display. */ debugBodyColor?: number; /** - * [description] + * The color of the Body's velocity on the debug display. */ debugVelocityColor?: number; /** - * [description] + * Maximum X velocity objects can move. */ maxVelocityX?: number; /** - * [description] + * Maximum Y velocity objects can move. */ maxVelocityY?: number; /** - * [description] + * The minimum velocity an object can be moving at to be considered for bounce. */ minBounceVelocity?: number; /** - * [description] + * Gravity multiplier. Set to 0 for no gravity. */ gravityFactor?: number; /** - * [description] + * The default bounce, or restitution, of bodies in the world. */ bounciness?: number; /** - * [description] + * Should the world have bounds enabled by default? */ setBounds?: object | boolean; /** - * [description] + * The x coordinate of the world bounds. */ "setBounds.x"?: number; /** - * [description] + * The y coordinate of the world bounds. */ "setBounds.y"?: number; /** - * [description] + * The width of the world bounds. */ "setBounds.width"?: number; /** - * [description] + * The height of the world bounds. */ "setBounds.height"?: number; /** - * [description] + * The thickness of the walls of the world bounds. */ "setBounds.thickness"?: number; /** - * [description] + * Should the left-side world bounds wall be created? */ "setBounds.left"?: boolean; /** - * [description] + * Should the right-side world bounds wall be created? */ "setBounds.right"?: boolean; /** - * [description] + * Should the top world bounds wall be created? */ "setBounds.top"?: boolean; /** - * [description] + * Should the bottom world bounds wall be created? */ "setBounds.bottom"?: boolean; }; @@ -41414,58 +57074,58 @@ declare namespace Phaser { */ type WorldDefaults = { /** - * [description] + * Whether the Body's boundary is drawn to the debug display. */ debugShowBody: boolean; /** - * [description] + * Whether the Body's velocity is drawn to the debug display. */ debugShowVelocity: boolean; /** - * [description] + * The color of this Body on the debug display. */ bodyDebugColor: number; /** - * [description] + * The color of the Body's velocity on the debug display. */ velocityDebugColor: number; /** - * [description] + * Maximum X velocity objects can move. */ maxVelocityX: number; /** - * [description] + * Maximum Y velocity objects can move. */ maxVelocityY: number; /** - * [description] + * The minimum velocity an object can be moving at to be considered for bounce. */ minBounceVelocity: number; /** - * [description] + * Gravity multiplier. Set to 0 for no gravity. */ gravityFactor: number; /** - * [description] + * The default bounce, or restitution, of bodies in the world. */ bounciness: number; }; type WorldWalls = { /** - * [description] + * The left-side wall of the world bounds. */ left: Phaser.Physics.Impact.Body; /** - * [description] + * The right-side wall of the world bounds. */ right: Phaser.Physics.Impact.Body; /** - * [description] + * The top wall of the world bounds. */ top: Phaser.Physics.Impact.Body; /** - * [description] + * The bottom wall of the world bounds. */ bottom: Phaser.Physics.Impact.Body; }; @@ -41476,7 +57136,7 @@ declare namespace Phaser { class World extends Phaser.Events.EventEmitter { /** * - * @param scene [description] + * @param scene The Scene to which this Impact World instance belongs. * @param config [description] */ constructor(scene: Phaser.Scene, config: Phaser.Physics.Impact.WorldConfig); @@ -41563,17 +57223,8 @@ declare namespace Phaser { * manually create a slopeMap that stores the mapping between tile indices and slope IDs. * @param tilemapLayer The tilemap layer to use. * @param options Options for controlling the mapping from tiles to slope IDs. - * @param options.slopeTileProperty Slope IDs can be stored on tiles directly - * using Tiled's 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. Default null. - * @param options.slopeMap A tile index to slope definition map. Default null. - * @param options.defaultCollidingSlope If specified, the default slope ID to - * assign to a colliding tile. If not specified, the tile's index is used. Default null. - * @param options.defaultNonCollidingSlope The default slope ID to assign to a - * non-colliding tile. Default 0. */ - setCollisionMapFromTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, options?: object): Phaser.Physics.Impact.CollisionMap; + setCollisionMapFromTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer, options?: CollisionOptions): Phaser.Physics.Impact.CollisionMap; /** * Sets the bounds of the Physics world to match the given world pixel dimensions. @@ -41606,7 +57257,7 @@ declare namespace Phaser { updateWall(add: boolean, position: string, x: number, y: number, width: number, height: number): void; /** - * [description] + * Creates a Graphics Game Object used for debug display and enables the world for debug drawing. */ createDebugGraphic(): Phaser.GameObjects.Graphics; @@ -41642,8 +57293,8 @@ declare namespace Phaser { /** * [description] - * @param time [description] - * @param delta [description] + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(time: number, delta: number): void; @@ -41757,120 +57408,120 @@ declare namespace Phaser { namespace Matter { namespace Components { /** - * [description] + * A component to set restitution on objects. */ interface Bounce { /** - * [description] - * @param value [description] + * Sets the restitution on the physics object. + * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` */ setBounce(value: number): Phaser.GameObjects.GameObject; } /** - * [description] + * Contains methods for changing the collision filter of a Matter Body. Should be used as a mixin and not called directly. */ interface Collision { /** - * [description] + * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision categories are included in their collision masks (see {@link #setCollidesWith}). * @param value Unique category bitfield. */ setCollisionCategory(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, they will never collide. * @param value Unique group index. */ setCollisionGroup(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0` are both true. * @param categories A unique category bitfield, or an array of them. */ setCollidesWith(categories: number | number[]): Phaser.GameObjects.GameObject; } /** - * [description] + * A component to apply force to Matter.js bodies. */ interface Force { /** - * [description] - * @param force [description] + * Applies a force to a body. + * @param force A Vector that specifies the force to apply. */ applyForce(force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; /** - * [description] - * @param position [description] - * @param force [description] + * Applies a force to a body from a given position. + * @param position The position in which the force comes from. + * @param force A Vector that specifies the force to apply. */ applyForceFrom(position: Phaser.Math.Vector2, force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the forward position of the body. + * @param speed A speed value to be applied to a directional force. */ thrust(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the left position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustLeft(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the right position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustRight(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the back position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustBack(speed: number): Phaser.GameObjects.GameObject; } /** - * [description] + * Contains methods for changing the friction of a Game Object's Matter Body. Should be used a mixin, not called directly. */ interface Friction { /** - * [description] - * @param value [description] - * @param air [description] - * @param fstatic [description] + * Sets new friction values for this Game Object's Matter Body. + * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. + * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. + * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. */ setFriction(value: number, air?: number, fstatic?: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new air resistance for this Game Object's Matter Body. A value of 0 means the Body will never slow as it moves through space. The higher the value, the faster a Body slows when moving through space. + * @param value The new air resistance for the Body. */ setFrictionAir(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new static friction for this Game Object's Matter Body. A value of 0 means the Body will never "stick" when it is nearly stationary. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. + * @param value The new static friction for the Body. */ setFrictionStatic(value: number): Phaser.GameObjects.GameObject; } /** - * [description] + * A component to manipulate world gravity for Matter.js bodies. */ interface Gravity { /** - * [description] - * @param value [description] + * A togglable function for ignoring world gravity in real-time on the current body. + * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. */ setIgnoreGravity(value: boolean): Phaser.GameObjects.GameObject; } /** - * [description] + * Allows accessing the mass, density, and center of mass of a Matter-enabled Game Object. Should be used as a mixin and not directly. */ interface Mass { /** - * [description] - * @param value [description] + * Sets the mass of the Game Object's Matter Body. + * @param value The new mass of the body. */ setMass(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets density of the body. + * @param value The new density of the body. */ setDensity(value: number): Phaser.GameObjects.GameObject; /** @@ -41899,9 +57550,9 @@ declare namespace Phaser { */ interface SetBody { /** - * [description] - * @param width [description] - * @param height [description] + * Set the body on a Game Object to a rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. * @param options [description] */ setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; @@ -41912,18 +57563,18 @@ declare namespace Phaser { */ setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; /** - * [description] - * @param radius [description] - * @param sides [description] - * @param options [description] + * Set the body on the Game Object to a polygon shape. + * @param radius The radius of the polygon. + * @param sides The amount of sides creating the polygon. + * @param options A matterjs config object. */ setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; /** - * [description] - * @param width [description] - * @param height [description] - * @param slope [description] - * @param options [description] + * Creates a new matterjs trapezoid body. + * @param width The width of the trapezoid. + * @param height The height of the trapezoid. + * @param slope The angle of slope for the trapezoid. + * @param options A matterjs config object for the body. */ setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; /** @@ -41983,60 +57634,60 @@ declare namespace Phaser { } /** - * [description] + * Provides methods used for getting and setting the position, scale and rotation of a Game Object. */ interface Transform { /** - * [description] + * The x position of this Game Object. */ x: number; /** - * [description] + * The y position of this Game Object. */ y: number; /** - * [description] + * The horizontal scale of this Game Object. */ scaleX: number; /** - * [description] + * The vertical scale of this Game Object. */ scaleY: number; /** - * [description] + * Use `angle` to set or get rotation of the physics body associated to this GameObject. Unlike rotation, when using set the value can be in degrees, which will be converted to radians internally. */ angle: number; /** - * [description] + * Use `rotation` to set or get the rotation of the physics body associated with this GameObject. The value when set must be in radians. */ rotation: number; /** - * [description] - * @param x [description] Default 0. - * @param y [description] Default x. + * Sets the position of the physics body along x and y axes. Both the parameters to this function are optional and if not passed any they default to 0. + * @param x The horizontal position of the body. Default 0. + * @param y The vertical position of the body. Default x. */ - setPosition(x?: number, y?: number): void; + setPosition(x?: number, y?: number): this; /** * [description] * @param radians [description] Default 0. */ - setRotation(radians?: number): Phaser.GameObjects.GameObject; + setRotation(radians?: number): this; /** * [description] */ - setFixedRotation(): Phaser.GameObjects.GameObject; + setFixedRotation(): this; /** * [description] * @param degrees [description] Default 0. */ - setAngle(degrees?: number): Phaser.GameObjects.GameObject; + setAngle(degrees?: number): this; /** - * [description] - * @param x [description] Default 1. - * @param y [description] Default x. - * @param point [description] + * Sets the scale of this Game Object. + * @param x The horizontal scale of this Game Object. Default 1. + * @param y The vertical scale of this Game Object. If not set it will use the x value. Default x. + * @param point The point (Vector2) from which scaling will occur. */ - setScale(x?: number, y?: number, point?: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; + setScale(x?: number, y?: number, point?: Phaser.Math.Vector2): this; } /** @@ -42049,42 +57700,268 @@ declare namespace Phaser { */ setAngularVelocity(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. */ setVelocityX(x: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param y [description] + * Sets vertical velocity of the physics body. + * @param y The vertical velocity value. */ setVelocityY(y: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets both the horizontal and vertical velocity of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. Default x. */ setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; } } + namespace Events { + type AfterUpdateEvent = { + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics After Update Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated and all collision events have resolved. + * + * Listen to it from a Scene using: `this.matter.world.on('afterupdate', listener)`. + */ + const AFTER_UPDATE: any; + + type BeforeUpdateEvent = { + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Before Update Event. + * + * This event is dispatched by a Matter Physics World instance right before all the collision processing takes place. + * + * Listen to it from a Scene using: `this.matter.world.on('beforeupdate', listener)`. + */ + const BEFORE_UPDATE: any; + + type CollisionActiveEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: any[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Collision Active Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that are colliding in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionactive', listener)`. + */ + const COLLISION_ACTIVE: any; + + type CollisionEndEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: any[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Collision End Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that have finished colliding in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionend', listener)`. + */ + const COLLISION_END: any; + + type CollisionStartEvent = { + /** + * A list of all affected pairs in the collision. + */ + pairs: any[]; + /** + * The Matter Engine `timing.timestamp` value for the event. + */ + timestamp: number; + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Collision Start Event. + * + * This event is dispatched by a Matter Physics World instance after the engine has updated. + * It provides a list of all pairs that have started to collide in the current tick (if any). + * + * Listen to it from a Scene using: `this.matter.world.on('collisionstart', listener)`. + */ + const COLLISION_START: any; + + /** + * The Matter Physics Drag End Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * stops dragging a body. + * + * Listen to it from a Scene using: `this.matter.world.on('dragend', listener)`. + */ + const DRAG_END: any; + + /** + * The Matter Physics Drag Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * is actively dragging a body. It is emitted each time the pointer moves. + * + * Listen to it from a Scene using: `this.matter.world.on('drag', listener)`. + */ + const DRAG: any; + + /** + * The Matter Physics Drag Start Event. + * + * This event is dispatched by a Matter Physics World instance when a Pointer Constraint + * starts dragging a body. + * + * Listen to it from a Scene using: `this.matter.world.on('dragstart', listener)`. + */ + const DRAG_START: any; + + /** + * The Matter Physics World Pause Event. + * + * This event is dispatched by an Matter Physics World instance when it is paused. + * + * Listen to it from a Scene using: `this.matter.world.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Matter Physics World Resume Event. + * + * This event is dispatched by an Matter Physics World instance when it resumes from a paused state. + * + * Listen to it from a Scene using: `this.matter.world.on('resume', listener)`. + */ + const RESUME: any; + + type SleepEndEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Sleep End Event. + * + * This event is dispatched by a Matter Physics World instance when a Body stop sleeping. + * + * Listen to it from a Scene using: `this.matter.world.on('sleepend', listener)`. + */ + const SLEEP_END: any; + + type SleepStartEvent = { + /** + * The source object of the event. + */ + source: any; + /** + * The name of the event. + */ + name: string; + }; + + /** + * The Matter Physics Sleep Start Event. + * + * This event is dispatched by a Matter Physics World instance when a Body goes to sleep. + * + * Listen to it from a Scene using: `this.matter.world.on('sleepstart', listener)`. + */ + const SLEEP_START: any; + + } + /** - * [description] + * The Matter Factory can create different types of bodies and them to a physics world. */ class Factory { /** * - * @param world [description] + * @param world The Matter World which this Factory adds to. */ constructor(world: Phaser.Physics.Matter.World); /** - * [description] + * The Matter World which this Factory adds to. */ world: Phaser.Physics.Matter.World; /** - * [description] + * The Scene which this Factory's Matter World belongs to. */ scene: Phaser.Scene; @@ -42094,55 +57971,56 @@ declare namespace Phaser { sys: Phaser.Scenes.Systems; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - * @param options [description] + * Creates a new rigid rectangular Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param width The width of the Body. + * @param height The height of the Body. + * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. */ rectangle(x: number, y: number, width: number, height: number, options: object): MatterJS.Body; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - * @param slope [description] - * @param options [description] + * Creates a new rigid trapezoidal Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param width The width of the trapezoid of the Body. + * @param height The height of the trapezoid of the Body. + * @param slope The slope of the trapezoid. 0 creates a rectangle, while 1 creates a triangle. Positive values make the top side shorter, while negative values make the bottom side shorter. + * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. */ trapezoid(x: number, y: number, width: number, height: number, slope: number, options: object): MatterJS.Body; /** - * [description] - * @param x [description] - * @param y [description] - * @param radius [description] - * @param options [description] - * @param maxSides [description] + * Creates a new rigid circular Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param radius The radius of the circle. + * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. + * @param maxSides The maximum amount of sides to use for the polygon which will approximate this circle. */ circle(x: number, y: number, radius: number, options: object, maxSides: number): MatterJS.Body; /** - * [description] - * @param x [description] - * @param y [description] - * @param sides [description] - * @param radius [description] - * @param options [description] + * Creates a new rigid polygonal Body and adds it to the World. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. + * @param sides The number of sides the polygon will have. + * @param radius The "radius" of the polygon, i.e. the distance from its center to any vertex. This is also the radius of its circumcircle. + * @param options An object of properties to set on the Body. You can also specify a `chamfer` property to automatically adjust the body. */ polygon(x: number, y: number, sides: number, radius: number, options: object): MatterJS.Body; /** - * [description] - * @param x [description] - * @param y [description] + * Creates a body using the supplied vertices (or an array containing multiple sets of vertices) and adds it to the World. + * If the vertices are convex, they will pass through as supplied. Otherwise, if the vertices are concave, they will be decomposed. Note that this process is not guaranteed to support complex sets of vertices, e.g. ones with holes. + * @param x The X coordinate of the center of the Body. + * @param y The Y coordinate of the center of the Body. * @param vertexSets [description] * @param options [description] - * @param flagInternal [description] - * @param removeCollinear [description] - * @param minimumArea [description] + * @param flagInternal Flag internal edges (coincident part edges) + * @param removeCollinear Whether Matter.js will discard collinear edges (to improve performance). + * @param minimumArea During decomposition discard parts that have an area less than this */ fromVertices(x: number, y: number, vertexSets: any[], options: object, flagInternal: boolean, removeCollinear: boolean, minimumArea: number): MatterJS.Body; @@ -42183,7 +58061,7 @@ declare namespace Phaser { * @param rows The number of rows in the pyramid. * @param columnGap The distance between each column. * @param rowGap The distance between each row. - * @param callback [description] + * @param callback The callback function to be invoked. */ pyramid(x: number, y: number, columns: number, rows: number, columnGap: number, rowGap: number, callback: Function): MatterJS.Composite; @@ -42237,7 +58115,7 @@ declare namespace Phaser { * @param columnGap The distance between each column. * @param rowGap The distance between each row. * @param crossBrace [description] - * @param particleRadius [description] + * @param particleRadius The radius of this circlular composite. * @param particleOptions [description] * @param constraintOptions [description] */ @@ -42255,10 +58133,10 @@ declare namespace Phaser { /** * [description] - * @param bodyA [description] - * @param bodyB [description] - * @param length [description] - * @param stiffness [description] Default 1. + * @param bodyA The first possible `Body` that this constraint is attached to. + * @param bodyB The second possible `Body` that this constraint is attached to. + * @param length A Number that specifies the target resting length of the constraint. It is calculated automatically in `Constraint.create` from initial positions of the `constraint.bodyA` and `constraint.bodyB` + * @param stiffness A Number that specifies the stiffness of the constraint, i.e. the rate at which it returns to its resting `constraint.length`. A value of `1` means the constraint should be very stiff. A value of `0.2` means the constraint acts as a soft spring. Default 1. * @param options [description] Default {}. */ spring(bodyA: MatterJS.Body, bodyB: MatterJS.Body, length: number, stiffness?: number, options?: object): MatterJS.Constraint; @@ -42337,9 +58215,9 @@ declare namespace Phaser { /** * [description] - * @param world [description] - * @param gameObject [description] - * @param options [description] + * @param world The Matter world to add the body to. + * @param gameObject The Game Object that will have the Matter body applied to it. + * @param options Matter options config object. */ function MatterGameObject(world: Phaser.Physics.Matter.World, gameObject: Phaser.GameObjects.GameObject, options: object): Phaser.GameObjects.GameObject; @@ -42429,6 +58307,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -42451,6 +58330,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -42458,7 +58338,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -42593,12 +58473,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -42709,15 +58593,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -42753,6 +58637,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -42767,6 +58656,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -42781,6 +58675,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -42788,34 +58687,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -42823,6 +58752,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -42839,6 +58769,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -42863,21 +58829,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -42907,6 +58916,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -43030,8 +59044,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -43049,101 +59064,101 @@ declare namespace Phaser { setVisible(value: boolean): this; /** - * [description] - * @param value [description] + * Sets the restitution on the physics object. + * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` */ setBounce(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision categories are included in their collision masks (see {@link #setCollidesWith}). * @param value Unique category bitfield. */ setCollisionCategory(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, they will never collide. * @param value Unique group index. */ setCollisionGroup(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0` are both true. * @param categories A unique category bitfield, or an array of them. */ setCollidesWith(categories: number | number[]): Phaser.GameObjects.GameObject; /** - * [description] - * @param force [description] + * Applies a force to a body. + * @param force A Vector that specifies the force to apply. */ applyForce(force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; /** - * [description] - * @param position [description] - * @param force [description] + * Applies a force to a body from a given position. + * @param position The position in which the force comes from. + * @param force A Vector that specifies the force to apply. */ applyForceFrom(position: Phaser.Math.Vector2, force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the forward position of the body. + * @param speed A speed value to be applied to a directional force. */ thrust(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the left position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustLeft(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the right position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustRight(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the back position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustBack(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] - * @param air [description] - * @param fstatic [description] + * Sets new friction values for this Game Object's Matter Body. + * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. + * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. + * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. */ setFriction(value: number, air?: number, fstatic?: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new air resistance for this Game Object's Matter Body. A value of 0 means the Body will never slow as it moves through space. The higher the value, the faster a Body slows when moving through space. + * @param value The new air resistance for the Body. */ setFrictionAir(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new static friction for this Game Object's Matter Body. A value of 0 means the Body will never "stick" when it is nearly stationary. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. + * @param value The new static friction for the Body. */ setFrictionStatic(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * A togglable function for ignoring world gravity in real-time on the current body. + * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. */ setIgnoreGravity(value: boolean): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the mass of the Game Object's Matter Body. + * @param value The new mass of the body. */ setMass(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets density of the body. + * @param value The new density of the body. */ setDensity(value: number): Phaser.GameObjects.GameObject; @@ -43164,9 +59179,9 @@ declare namespace Phaser { isSensor(): boolean; /** - * [description] - * @param width [description] - * @param height [description] + * Set the body on a Game Object to a rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. * @param options [description] */ setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; @@ -43179,19 +59194,19 @@ declare namespace Phaser { setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; /** - * [description] - * @param radius [description] - * @param sides [description] - * @param options [description] + * Set the body on the Game Object to a polygon shape. + * @param radius The radius of the polygon. + * @param sides The amount of sides creating the polygon. + * @param options A matterjs config object. */ setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; /** - * [description] - * @param width [description] - * @param height [description] - * @param slope [description] - * @param options [description] + * Creates a new matterjs trapezoid body. + * @param width The width of the trapezoid. + * @param height The height of the trapezoid. + * @param slope The angle of slope for the trapezoid. + * @param options A matterjs config object for the body. */ setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; @@ -43248,7 +59263,7 @@ declare namespace Phaser { /** * [description] */ - setFixedRotation(): Phaser.GameObjects.GameObject; + setFixedRotation(): this; /** * [description] @@ -43257,21 +59272,21 @@ declare namespace Phaser { setAngularVelocity(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. */ setVelocityX(x: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param y [description] + * Sets vertical velocity of the physics body. + * @param y The vertical velocity value. */ setVelocityY(y: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets both the horizontal and vertical velocity of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. Default x. */ setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; @@ -43312,6 +59327,13 @@ declare namespace Phaser { */ add: Phaser.Physics.Matter.Factory; + /** + * A reference to the `Matter.Vertices` module which contains methods for creating and manipulating sets of vertices. + * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. + * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). + */ + verts: MatterJS.Vertices; + /** * [description] */ @@ -43465,6 +59487,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -43487,6 +59510,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -43494,7 +59518,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -43629,12 +59653,16 @@ declare namespace Phaser { /** * Sets the mask that this Game Object will use to render with. * - * The mask must have been previously created and can be either a - * GeometryMask or a BitmapMask. - * + * The mask must have been previously created and can be either a GeometryMask or a BitmapMask. * Note: Bitmap Masks only work on WebGL. Geometry Masks work on both WebGL and Canvas. * * If a mask is already set on this Game Object it will be immediately replaced. + * + * Masks are positioned in global space and are not relative to the Game Object to which they + * are applied. The reason for this is that multiple Game Objects can all share the same mask. + * + * Masks have no impact on physics or input detection. They are purely a rendering component + * that allows you to limit what is visible during the render pass. * @param mask The mask this Game Object will use when rendering. */ setMask(mask: Phaser.Display.Masks.BitmapMask | Phaser.Display.Masks.GeometryMask): this; @@ -43745,15 +59773,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -43789,6 +59817,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -43803,6 +59836,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -43817,6 +59855,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -43824,34 +59867,64 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** * Sets the size of this Game Object to be that of the given Frame. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param frame The frame to base the size of this Game Object on. */ setSizeToFrame(frame: Phaser.Textures.Frame): this; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -43859,6 +59932,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -43875,6 +59949,42 @@ declare namespace Phaser { */ frame: Phaser.Textures.Frame; + /** + * A boolean flag indicating if this Game Object is being cropped or not. + * You can toggle this at any time after `setCrop` has been called, to turn cropping on or off. + * Equally, calling `setCrop` with no arguments will reset the crop and disable it. + */ + isCropped: boolean; + + /** + * Applies a crop to a texture based Game Object, such as a Sprite or Image. + * + * The crop is a rectangle that limits the area of the texture frame that is visible during rendering. + * + * Cropping a Game Object does not change its size, dimensions, physics body or hit area, it just + * changes what is shown when rendered. + * + * The crop coordinates are relative to the texture frame, not the Game Object, meaning 0 x 0 is the top-left. + * + * Therefore, if you had a Game Object that had an 800x600 sized texture, and you wanted to show only the left + * half of it, you could call `setCrop(0, 0, 400, 600)`. + * + * It is also scaled to match the Game Object scale automatically. Therefore a crop rect of 100x50 would crop + * an area of 200x100 when applied to a Game Object that had a scale factor of 2. + * + * You can either pass in numeric values directly, or you can provide a single Rectangle object as the first argument. + * + * Call this method with no arguments at all to reset the crop, or toggle the property `isCropped` to `false`. + * + * You should do this if the crop rectangle becomes the same size as the frame itself, as it will allow + * the renderer to skip several internal calculations. + * @param x The x coordinate to start the crop from. Or a Phaser.Geom.Rectangle object, in which case the rest of the arguments are ignored. + * @param y The y coordinate to start the crop from. + * @param width The width of the crop rectangle in pixels. + * @param height The height of the crop rectangle in pixels. + */ + setCrop(x?: number | Phaser.Geom.Rectangle, y?: number, width?: number, height?: number): this; + /** * Sets the texture and frame this Game Object will use to render with. * @@ -43899,21 +60009,64 @@ declare namespace Phaser { */ setFrame(frame: string | integer, updateSize?: boolean, updateOrigin?: boolean): this; + /** + * Fill or additive? + */ + tintFill: boolean; + /** * Clears all tint values associated with this Game Object. - * Immediately sets the alpha levels back to 0xffffff (no tint) + * + * Immediately sets the color values back to 0xffffff and the tint type to 'additive', + * which results in no visible change to the texture. */ clearTint(): this; /** - * Sets the tint values for this Game Object. - * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * Sets an additive tint on this Game Object. + * + * The tint works by taking the pixel color values from the Game Objects texture, and then + * multiplying it by the color value of the tint. You can provide either one color value, + * in which case the whole Game Object will be tinted in that color. Or you can provide a color + * per corner. The colors are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being an additive tint to a fill based tint set the property `tintFill` to `true`. + * @param topLeft The tint being applied to the top-left of the Game Object. If no other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. * @param topRight The tint being applied to the top-right of the Game Object. * @param bottomLeft The tint being applied to the bottom-left of the Game Object. * @param bottomRight The tint being applied to the bottom-right of the Game Object. */ setTint(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** + * Sets a fill-based tint on this Game Object. + * + * Unlike an additive tint, a fill-tint literally replaces the pixel colors from the texture + * with those in the tint. You can use this for effects such as making a player flash 'white' + * if hit by something. You can provide either one color value, in which case the whole + * Game Object will be rendered in that color. Or you can provide a color per corner. The colors + * are blended together across the extent of the Game Object. + * + * To modify the tint color once set, either call this method again with new values or use the + * `tint` property to set all colors at once. Or, use the properties `tintTopLeft`, `tintTopRight, + * `tintBottomLeft` and `tintBottomRight` to set the corner color values independently. + * + * To remove a tint call `clearTint`. + * + * To swap this from being a fill-tint to an additive tint set the property `tintFill` to `false`. + * @param topLeft The tint being applied to the top-left of the Game Object. If not other values are given this value is applied evenly, tinting the whole Game Object. Default 0xffffff. + * @param topRight The tint being applied to the top-right of the Game Object. + * @param bottomLeft The tint being applied to the bottom-left of the Game Object. + * @param bottomRight The tint being applied to the bottom-right of the Game Object. + */ + setTintFill(topLeft?: integer, topRight?: integer, bottomLeft?: integer, bottomRight?: integer): this; + /** * The tint value being applied to the top-left of the Game Object. * This value is interpolated from the corner to the center of the Game Object. @@ -43943,6 +60096,11 @@ declare namespace Phaser { */ tint: integer; + /** + * Does this Game Object have a tint applied to it or not? + */ + readonly isTinted: boolean; + /** * The x position of this Game Object. */ @@ -44066,8 +60224,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -44085,101 +60244,101 @@ declare namespace Phaser { setVisible(value: boolean): this; /** - * [description] - * @param value [description] + * Sets the restitution on the physics object. + * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` */ setBounce(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision categories are included in their collision masks (see {@link #setCollidesWith}). * @param value Unique category bitfield. */ setCollisionCategory(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, they will never collide. * @param value Unique group index. */ setCollisionGroup(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0` are both true. * @param categories A unique category bitfield, or an array of them. */ setCollidesWith(categories: number | number[]): Phaser.GameObjects.GameObject; /** - * [description] - * @param force [description] + * Applies a force to a body. + * @param force A Vector that specifies the force to apply. */ applyForce(force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; /** - * [description] - * @param position [description] - * @param force [description] + * Applies a force to a body from a given position. + * @param position The position in which the force comes from. + * @param force A Vector that specifies the force to apply. */ applyForceFrom(position: Phaser.Math.Vector2, force: Phaser.Math.Vector2): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the forward position of the body. + * @param speed A speed value to be applied to a directional force. */ thrust(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the left position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustLeft(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the right position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustRight(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param speed [description] + * Apply thrust to the back position of the body. + * @param speed A speed value to be applied to a directional force. */ thrustBack(speed: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] - * @param air [description] - * @param fstatic [description] + * Sets new friction values for this Game Object's Matter Body. + * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. + * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. + * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. */ setFriction(value: number, air?: number, fstatic?: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new air resistance for this Game Object's Matter Body. A value of 0 means the Body will never slow as it moves through space. The higher the value, the faster a Body slows when moving through space. + * @param value The new air resistance for the Body. */ setFrictionAir(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new static friction for this Game Object's Matter Body. A value of 0 means the Body will never "stick" when it is nearly stationary. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. + * @param value The new static friction for the Body. */ setFrictionStatic(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * A togglable function for ignoring world gravity in real-time on the current body. + * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. */ setIgnoreGravity(value: boolean): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the mass of the Game Object's Matter Body. + * @param value The new mass of the body. */ setMass(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets density of the body. + * @param value The new density of the body. */ setDensity(value: number): Phaser.GameObjects.GameObject; @@ -44200,9 +60359,9 @@ declare namespace Phaser { isSensor(): boolean; /** - * [description] - * @param width [description] - * @param height [description] + * Set the body on a Game Object to a rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. * @param options [description] */ setRectangle(width: number, height: number, options: object): Phaser.GameObjects.GameObject; @@ -44215,19 +60374,19 @@ declare namespace Phaser { setCircle(radius: number, options: object): Phaser.GameObjects.GameObject; /** - * [description] - * @param radius [description] - * @param sides [description] - * @param options [description] + * Set the body on the Game Object to a polygon shape. + * @param radius The radius of the polygon. + * @param sides The amount of sides creating the polygon. + * @param options A matterjs config object. */ setPolygon(radius: number, sides: number, options: object): Phaser.GameObjects.GameObject; /** - * [description] - * @param width [description] - * @param height [description] - * @param slope [description] - * @param options [description] + * Creates a new matterjs trapezoid body. + * @param width The width of the trapezoid. + * @param height The height of the trapezoid. + * @param slope The angle of slope for the trapezoid. + * @param options A matterjs config object for the body. */ setTrapezoid(width: number, height: number, slope: number, options: object): Phaser.GameObjects.GameObject; @@ -44284,7 +60443,7 @@ declare namespace Phaser { /** * [description] */ - setFixedRotation(): Phaser.GameObjects.GameObject; + setFixedRotation(): this; /** * [description] @@ -44293,21 +60452,21 @@ declare namespace Phaser { setAngularVelocity(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] + * Sets the horizontal velocity of the physics body. + * @param x The horizontal velocity value. */ setVelocityX(x: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param y [description] + * Sets vertical velocity of the physics body. + * @param y The vertical velocity value. */ setVelocityY(y: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param x [description] - * @param y [description] Default x. + * Sets both the horizontal and vertical velocity of the physics body. + * @param x The horizontal velocity value. + * @param y The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the `x` value. Default x. */ setVelocity(x: number, y?: number): Phaser.GameObjects.GameObject; @@ -44330,16 +60489,9 @@ declare namespace Phaser { * * @param world [description] * @param tile The target tile that should have a Matter body. - * @param options Options to be used when creating the Matter body. See - * Phaser.Physics.Matter.Matter.Body for a list of what Matter accepts. - * @param options.body An existing Matter body to - * be used instead of creating a new one. Default null. - * @param options.isStatic Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. Default true. - * @param options.addToWorld Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. Default true. + * @param options Options to be used when creating the Matter body. */ - constructor(world: Phaser.Physics.Matter.World, tile: Phaser.Tilemaps.Tile, options?: object); + constructor(world: Phaser.Physics.Matter.World, tile: Phaser.Tilemaps.Tile, options?: MatterTileOptions); /** * The tile object the body is associated with. @@ -44354,12 +60506,8 @@ declare namespace Phaser { /** * Sets the current body to a rectangle that matches the bounds of the tile. * @param options Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. - * @param options.isStatic Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. Default true. - * @param options.addToWorld Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. Default true. */ - setFromTileRectangle(options?: object): Phaser.Physics.Matter.TileBody; + setFromTileRectangle(options?: MatterBodyTileOptions): Phaser.Physics.Matter.TileBody; /** * Sets the current body from the collision group associated with the Tile. This is typically @@ -44372,12 +60520,8 @@ declare namespace Phaser { * work for complex shapes (e.g. holes), so it's often best to manually decompose a concave * polygon into multiple convex polygons yourself. * @param options Options to be used when creating the Matter body. See MatterJS.Body for a list of what Matter accepts. - * @param options.isStatic Whether or not the newly created body should be - * made static. This defaults to true since typically tiles should not be moved. Default true. - * @param options.addToWorld Whether or not to add the newly created body (or - * existing body if options.body is used) to the Matter world. Default true. */ - setFromTileCollision(options?: object): Phaser.Physics.Matter.TileBody; + setFromTileCollision(options?: MatterBodyTileOptions): Phaser.Physics.Matter.TileBody; /** * Sets the current body to the given body. This will remove the previous body, if one already @@ -44398,64 +60542,64 @@ declare namespace Phaser { destroy(): Phaser.Physics.Matter.TileBody; /** - * [description] - * @param value [description] + * Sets the restitution on the physics object. + * @param value A Number that defines the restitution (elasticity) of the body. The value is always positive and is in the range (0, 1). A value of 0 means collisions may be perfectly inelastic and no bouncing may occur. A value of 0.8 means the body may bounce back with approximately 80% of its kinetic energy. Note that collision response is based on pairs of bodies, and that restitution values are combined with the following formula: `Math.max(bodyA.restitution, bodyB.restitution)` */ setBounce(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision category of this Game Object's Matter Body. This number must be a power of two between 2^0 (= 1) and 2^31. Two bodies with different collision groups (see {@link #setCollisionGroup}) will only collide if their collision categories are included in their collision masks (see {@link #setCollidesWith}). * @param value Unique category bitfield. */ setCollisionCategory(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision group of this Game Object's Matter Body. If this is zero or two Matter Bodies have different values, they will collide according to the usual rules (see {@link #setCollisionCategory} and {@link #setCollisionGroup}). If two Matter Bodies have the same positive value, they will always collide; if they have the same negative value, they will never collide. * @param value Unique group index. */ setCollisionGroup(value: number): Phaser.GameObjects.GameObject; /** - * [description] + * Sets the collision mask for this Game Object's Matter Body. Two Matter Bodies with different collision groups will only collide if each one includes the other's category in its mask based on a bitwise AND, i.e. `(categoryA & maskB) !== 0` and `(categoryB & maskA) !== 0` are both true. * @param categories A unique category bitfield, or an array of them. */ setCollidesWith(categories: number | number[]): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] - * @param air [description] - * @param fstatic [description] + * Sets new friction values for this Game Object's Matter Body. + * @param value The new friction of the body, between 0 and 1, where 0 allows the Body to slide indefinitely, while 1 allows it to stop almost immediately after a force is applied. + * @param air If provided, the new air resistance of the Body. The higher the value, the faster the Body will slow as it moves through space. 0 means the body has no air resistance. + * @param fstatic If provided, the new static friction of the Body. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. 0 means the body will never "stick" when it is nearly stationary. */ setFriction(value: number, air?: number, fstatic?: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new air resistance for this Game Object's Matter Body. A value of 0 means the Body will never slow as it moves through space. The higher the value, the faster a Body slows when moving through space. + * @param value The new air resistance for the Body. */ setFrictionAir(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets a new static friction for this Game Object's Matter Body. A value of 0 means the Body will never "stick" when it is nearly stationary. The higher the value (e.g. 10), the more force it will take to initially get the Body moving when it is nearly stationary. + * @param value The new static friction for the Body. */ setFrictionStatic(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * A togglable function for ignoring world gravity in real-time on the current body. + * @param value Set to true to ignore the effect of world gravity, or false to not ignore it. */ setIgnoreGravity(value: boolean): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets the mass of the Game Object's Matter Body. + * @param value The new mass of the body. */ setMass(value: number): Phaser.GameObjects.GameObject; /** - * [description] - * @param value [description] + * Sets density of the body. + * @param value The new density of the body. */ setDensity(value: number): Phaser.GameObjects.GameObject; @@ -44544,77 +60688,117 @@ declare namespace Phaser { } /** - * [description] + * A Pointer Constraint is a special type of constraint that allows you to click + * and drag bodies in a Matter World. It monitors the active Pointers in a Scene, + * and when one is pressed down it checks to see if that hit any part of any active + * body in the world. If it did, and the body has input enabled, it will begin to + * drag it until either released, or you stop it via the `stopDrag` method. + * + * You can adjust the stiffness, length and other properties of the constraint via + * the `options` object on creation. */ class PointerConstraint { /** * - * @param scene [description] - * @param world [description] - * @param options [description] + * @param scene A reference to the Scene to which this Pointer Constraint belongs. + * @param world A reference to the Matter World instance to which this Constraint belongs. + * @param options A Constraint configuration object. */ - constructor(scene: Phaser.Scene, world: Phaser.Physics.Matter.World, options: object); + constructor(scene: Phaser.Scene, world: Phaser.Physics.Matter.World, options?: object); /** - * [description] + * A reference to the Scene to which this Pointer Constraint belongs. + * This is the same Scene as the Matter World instance. */ scene: Phaser.Scene; /** - * [description] + * A reference to the Matter World instance to which this Constraint belongs. */ world: Phaser.Physics.Matter.World; /** - * [description] + * The Camera the Pointer was interacting with when the input + * down event was processed. */ camera: Phaser.Cameras.Scene2D.Camera; /** - * [description] + * A reference to the Input Pointer that activated this Constraint. + * This is set in the `onDown` handler. */ pointer: Phaser.Input.Pointer; /** - * [description] + * Is this Constraint active or not? + * + * An active constraint will be processed each update. An inactive one will be skipped. + * Use this to toggle a Pointer Constraint on and off. */ active: boolean; /** - * The transformed position. + * The internal transformed position. */ position: Phaser.Math.Vector2; /** - * [description] + * The body that is currently being dragged, if any. + */ + body: MatterJS.Body; + + /** + * The part of the body that was clicked on to start the drag. + */ + part: MatterJS.Body; + + /** + * The native Matter Constraint that is used to attach to bodies. */ constraint: object; /** - * [description] - * @param pointer [description] + * A Pointer has been pressed down onto the Scene. + * + * If this Constraint doesn't have an active Pointer then a hit test is + * run against all active bodies in the world. If one is found it is bound + * to this constraint and the drag begins. + * @param pointer A reference to the Pointer that was pressed. */ onDown(pointer: Phaser.Input.Pointer): void; /** - * [description] + * Scans all active bodies in the current Matter World to see if any of them + * are hit by the Pointer. The _first one_ found to hit is set as the active contraint + * body. */ - onUp(): void; + getBody(): boolean; /** - * [description] - * @param body [description] - * @param position [description] + * Scans the current body to determine if a part of it was clicked on. + * If a part is found the body is set as the `constraint.bodyB` property, + * as well as the `body` property of this class. The part is also set. + * @param body The Matter Body to check. + * @param position A translated hit test position. */ - getBodyPart(body: MatterJS.Body, position: Phaser.Math.Vector2): boolean; + hitTestBody(body: MatterJS.Body, position: Phaser.Math.Vector2): boolean; /** - * [description] + * Internal update handler. Called in the Matter BEFORE_UPDATE step. */ update(): void; /** - * [description] + * Stops the Pointer Constraint from dragging the body any further. + * + * This is called automatically if the Pointer is released while actively + * dragging a body. Or, you can call it manually to release a body from a + * constraint without having to first release the pointer. + */ + stopDrag(): void; + + /** + * Destroys this Pointer Constraint instance and all of its references. */ destroy(): void; @@ -44626,18 +60810,18 @@ declare namespace Phaser { class World extends Phaser.Events.EventEmitter { /** * - * @param scene [description] + * @param scene The Scene to which this Matter World instance belongs. * @param config [description] */ constructor(scene: Phaser.Scene, config: object); /** - * [description] + * The Scene to which this Matter World instance belongs. */ scene: Phaser.Scene; /** - * [description] + * An instance of the MatterJS Engine. */ engine: MatterJS.Engine; @@ -44652,7 +60836,7 @@ declare namespace Phaser { walls: object; /** - * [description] + * A flag that toggles if the world is enabled or not. */ enabled: boolean; @@ -44699,17 +60883,17 @@ declare namespace Phaser { autoUpdate: boolean; /** - * [description] + * A flag that controls if the debug graphics will be drawn to or not. */ drawDebug: boolean; /** - * [description] + * An instance of the Graphics object the debug bodies are drawn to, if enabled. */ debugGraphic: Phaser.GameObjects.Graphics; /** - * [description] + * The default configuration values. */ defaults: object; @@ -44754,30 +60938,30 @@ declare namespace Phaser { createDebugGraphic(): Phaser.GameObjects.Graphics; /** - * [description] + * Sets the world's gravity and gravity scale to 0. */ disableGravity(): Phaser.Physics.Matter.World; /** - * [description] - * @param x [description] Default 0. - * @param y [description] Default 1. + * Sets the world's gravity + * @param x The world gravity x component. Default 0. + * @param y The world gravity y component. Default 1. * @param scale [description] */ setGravity(x?: number, y?: number, scale?: number): Phaser.Physics.Matter.World; /** - * [description] - * @param x [description] - * @param y [description] - * @param width [description] - * @param height [description] - * @param options [description] + * Creates a rectangle Matter body and adds it to the world. + * @param x The horizontal position of the body in the world. + * @param y The vertical position of the body in the world. + * @param width The width of the body. + * @param height The height of the body. + * @param options Optional Matter configuration object. */ create(x: number, y: number, width: number, height: number, options: object): MatterJS.Body; /** - * [description] + * Adds an object to the world. * @param object Can be single or an array, and can be a body, composite or constraint */ add(object: object | object[]): Phaser.Physics.Matter.World; @@ -44835,8 +61019,8 @@ declare namespace Phaser { /** * [description] - * @param time [description] - * @param delta [description] + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(time: number, delta: number): void; @@ -44875,11 +61059,6 @@ declare namespace Phaser { */ update30Hz(): number; - /** - * [description] - */ - postUpdate(): void; - /** * [description] * @param path [description] @@ -44888,12 +61067,16 @@ declare namespace Phaser { fromPath(path: string, points: any[]): any[]; /** - * [description] + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. */ shutdown(): void; /** - * [description] + * Will remove all Matter physics event listeners and clear the matter physics world, + * engine and any debug graphics, if any. + * + * After destroying the world it cannot be re-used again. */ destroy(): void; @@ -44947,8 +61130,9 @@ declare namespace Phaser { * It will never be called again on this instance. * In here you can set-up whatever you need for this plugin to run. * If a plugin is set to automatically start then `BasePlugin.start` will be called immediately after this. + * @param data A value specified by the user, if any, from the `data` property of the plugin's configuration object (if started at game boot) or passed in the PluginManager's `install` method (if started manually). */ - init(): void; + init(data?: any): void; /** * Called by the PluginManager when this plugin is started. @@ -45023,6 +61207,86 @@ declare namespace Phaser { */ var DefaultScene: any[]; + namespace PluginCache { + /** + * Static method called directly by the Core internal Plugins. + * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) + * Plugin is the object to instantiate to create the plugin + * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) + * @param key A reference used to get this plugin from the plugin cache. + * @param plugin The plugin to be stored. Should be the core object, not instantiated. + * @param mapping If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param custom Core Scene plugin or a Custom Scene plugin? Default false. + */ + function register(key: string, plugin: Function, mapping: string, custom?: boolean): void; + + /** + * Stores a custom plugin in the global plugin cache. + * The key must be unique, within the scope of the cache. + * @param key A reference used to get this plugin from the plugin cache. + * @param plugin The plugin to be stored. Should be the core object, not instantiated. + * @param mapping If this plugin is to be injected into the Scene Systems, this is the property key map used. + * @param data A value to be passed to the plugin's `init` method. + */ + function registerCustom(key: string, plugin: Function, mapping: string, data: any): void; + + /** + * Checks if the given key is already being used in the core plugin cache. + * @param key The key to check for. + */ + function hasCore(key: string): boolean; + + /** + * Checks if the given key is already being used in the custom plugin cache. + * @param key The key to check for. + */ + function hasCustom(key: string): boolean; + + /** + * Returns the core plugin object from the cache based on the given key. + * @param key The key of the core plugin to get. + */ + function getCore(key: string): CorePluginContainer; + + /** + * Returns the custom plugin object from the cache based on the given key. + * @param key The key of the custom plugin to get. + */ + function getCustom(key: string): CustomPluginContainer; + + /** + * Returns an object from the custom cache based on the given key that can be instantiated. + * @param key The key of the custom plugin to get. + */ + function getCustomClass(key: string): Function; + + /** + * Removes a core plugin based on the given key. + * @param key The key of the core plugin to remove. + */ + function remove(key: string): void; + + /** + * Removes a custom plugin based on the given key. + * @param key The key of the custom plugin to remove. + */ + function removeCustom(key: string): void; + + /** + * Removes all Core Plugins. + * + * This includes all of the internal system plugins that Phaser needs, like the Input Plugin and Loader Plugin. + * So be sure you only call this if you do not wish to run Phaser again. + */ + function destroyCorePlugins(): void; + + /** + * Removes all Custom Plugins. + */ + function destroyCustomPlugins(): void; + + } + /** * The PluginManager is responsible for installing and adding plugins to Phaser. * @@ -45033,8 +61297,8 @@ declare namespace Phaser { * * There are two types of plugin: * - * 1) A Global Plugin - * 2) A Scene Plugin + * 1. A Global Plugin + * 2. A Scene Plugin * * A Global Plugin is a plugin that lives within the Plugin Manager rather than a Scene. You can get * access to it by calling `PluginManager.get` and providing a key. Any Scene that requests a plugin in @@ -45048,9 +61312,9 @@ declare namespace Phaser { * * You can add a plugin to Phaser in three different ways: * - * 1) Preload it - * 2) Include it in your source code and install it via the Game Config - * 3) Include it in your source code and install it within a Scene + * 1. Preload it + * 2. Include it in your source code and install it via the Game Config + * 3. Include it in your source code and install it within a Scene * * For examples of all of these approaches please see the Phaser 3 Examples Repo `plugins` folder. * @@ -45150,8 +61414,9 @@ declare namespace Phaser { * @param plugin The plugin code. This should be the non-instantiated version. * @param start Automatically start the plugin running? This is always `true` if you provide a mapping value. Default false. * @param mapping If this plugin is injected into the Phaser.Scene class, this is the property key to use. + * @param data A value passed to the plugin's `init` method. */ - install(key: string, plugin: Function, start?: boolean, mapping?: string): void; + install(key: string, plugin: Function, start?: boolean, mapping?: string, data?: any): Phaser.Plugins.BasePlugin; /** * Gets an index of a global plugin based on the given key. @@ -45299,7 +61564,8 @@ declare namespace Phaser { /** * Destroys this Plugin Manager and all associated plugins. * It will iterate all plugins found and call their `destroy` methods. - * Note that the PluginCache is NOT cleared by this as it doesn't hold any plugin instances. + * + * The PluginCache will remove all custom plugins. */ destroy(): void; @@ -45318,18 +61584,6 @@ declare namespace Phaser { */ constructor(scene: Phaser.Scene, pluginManager: Phaser.Plugins.PluginManager); - /** - * A reference to the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - */ - protected scene: Phaser.Scene; - - /** - * A reference to the Scene Systems of the Scene that has installed this plugin. - * This property is only set when the plugin is instantiated and added to the Scene, not before. - */ - protected systems: Phaser.Scenes.Systems; - /** * This method is called when the Scene boots. It is only ever called once. * @@ -45377,79 +61631,150 @@ declare namespace Phaser { */ SKIP_CHECK, /** - * Normal blend mode. + * Normal blend mode. For Canvas and WebGL. + * This is the default setting and draws new shapes on top of the existing canvas content. */ NORMAL, /** - * Add blend mode. + * Add blend mode. For Canvas and WebGL. + * Where both shapes overlap the color is determined by adding color values. */ ADD, /** - * Multiply blend mode. + * Multiply blend mode. For Canvas and WebGL. + * The pixels are of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. */ MULTIPLY, /** - * Screen blend mode. + * Screen blend mode. For Canvas and WebGL. + * The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) */ SCREEN, /** - * Overlay blend mode. + * Overlay blend mode. For Canvas only. + * A combination of multiply and screen. Dark parts on the base layer become darker, and light parts become lighter. */ OVERLAY, /** - * Darken blend mode. + * Darken blend mode. For Canvas only. + * Retains the darkest pixels of both layers. */ DARKEN, /** - * Lighten blend mode. + * Lighten blend mode. For Canvas only. + * Retains the lightest pixels of both layers. */ LIGHTEN, /** - * Color Dodge blend mode. + * Color Dodge blend mode. For Canvas only. + * Divides the bottom layer by the inverted top layer. */ COLOR_DODGE, /** - * Color Burn blend mode. + * Color Burn blend mode. For Canvas only. + * Divides the inverted bottom layer by the top layer, and then inverts the result. */ COLOR_BURN, /** - * Hard Light blend mode. + * Hard Light blend mode. For Canvas only. + * A combination of multiply and screen like overlay, but with top and bottom layer swapped. */ HARD_LIGHT, /** - * Soft Light blend mode. + * Soft Light blend mode. For Canvas only. + * A softer version of hard-light. Pure black or white does not result in pure black or white. */ SOFT_LIGHT, /** - * Difference blend mode. + * Difference blend mode. For Canvas only. + * Subtracts the bottom layer from the top layer or the other way round to always get a positive value. */ DIFFERENCE, /** - * Exclusion blend mode. + * Exclusion blend mode. For Canvas only. + * Like difference, but with lower contrast. */ EXCLUSION, /** - * Hue blend mode. + * Hue blend mode. For Canvas only. + * Preserves the luma and chroma of the bottom layer, while adopting the hue of the top layer. */ HUE, /** - * Saturation blend mode. + * Saturation blend mode. For Canvas only. + * Preserves the luma and hue of the bottom layer, while adopting the chroma of the top layer. */ SATURATION, /** - * Color blend mode. + * Color blend mode. For Canvas only. + * Preserves the luma of the bottom layer, while adopting the hue and chroma of the top layer. */ COLOR, /** - * Luminosity blend mode. + * Luminosity blend mode. For Canvas only. + * Preserves the hue and chroma of the bottom layer, while adopting the luma of the top layer. */ LUMINOSITY, + /** + * Alpha erase blend mode. For Canvas and WebGL. + */ + ERASE, + /** + * Source-in blend mode. For Canvas only. + * The new shape is drawn only where both the new shape and the destination canvas overlap. Everything else is made transparent. + */ + SOURCE_IN, + /** + * Source-out blend mode. For Canvas only. + * The new shape is drawn where it doesn't overlap the existing canvas content. + */ + SOURCE_OUT, + /** + * Source-out blend mode. For Canvas only. + * The new shape is only drawn where it overlaps the existing canvas content. + */ + SOURCE_ATOP, + /** + * Destination-over blend mode. For Canvas only. + * New shapes are drawn behind the existing canvas content. + */ + DESTINATION_OVER, + /** + * Destination-in blend mode. For Canvas only. + * The existing canvas content is kept where both the new shape and existing canvas content overlap. Everything else is made transparent. + */ + DESTINATION_IN, + /** + * Destination-out blend mode. For Canvas only. + * The existing content is kept where it doesn't overlap the new shape. + */ + DESTINATION_OUT, + /** + * Destination-out blend mode. For Canvas only. + * The existing canvas is only kept where it overlaps the new shape. The new shape is drawn behind the canvas content. + */ + DESTINATION_ATOP, + /** + * Lighten blend mode. For Canvas only. + * Where both shapes overlap the color is determined by adding color values. + */ + LIGHTER, + /** + * Copy blend mode. For Canvas only. + * Only the new shape is shown. + */ + COPY, + /** + * xor blend mode. For Canvas only. + * Shapes are made transparent where both overlap and drawn normal everywhere else. + */ + XOR, } namespace Renderer { namespace Canvas { /** - * [description] + * The Canvas Renderer is responsible for managing 2D canvas rendering contexts, including the one used by the Game's canvas. It tracks the internal state of a given context and can renderer textured Game Objects to it, taking into account alpha, blending, and scaling. */ class CanvasRenderer { /** @@ -45464,135 +61789,124 @@ declare namespace Phaser { game: Phaser.Game; /** - * [description] + * A constant which allows the renderer to be easily identified as a Canvas Renderer. */ type: integer; /** - * [description] + * The total number of Game Objects which were rendered in a frame. */ drawCount: number; /** - * [description] + * The width of the canvas being rendered to. */ - width: number; + width: integer; /** - * [description] + * The height of the canvas being rendered to. */ - height: number; + height: integer; /** - * [description] + * The local configuration settings of the CanvasRenderer. */ - config: RendererConfig; + config: object; /** - * [description] + * The scale mode which should be used by the CanvasRenderer. */ scaleMode: integer; /** - * [description] + * The canvas element which the Game uses. */ gameCanvas: HTMLCanvasElement; /** - * [description] + * The canvas context used to render all Cameras in all Scenes during the game loop. */ gameContext: CanvasRenderingContext2D; /** - * [description] + * The canvas context currently used by the CanvasRenderer for all rendering operations. */ currentContext: CanvasRenderingContext2D; /** - * Map to the required function. - */ - drawImage: Function; - - /** - * [description] - */ - blitImage: Function; - - /** - * [description] + * The blend modes supported by the Canvas Renderer. + * + * This object maps the {@link Phaser.BlendModes} to canvas compositing operations. */ blendModes: any[]; /** - * [description] - */ - currentAlpha: number; - - /** - * [description] - */ - currentBlendMode: number; - - /** - * [description] + * The scale mode currently in use by the Canvas Renderer. */ currentScaleMode: number; /** - * [description] + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. */ - snapshotCallback: SnapshotCallback; + snapshotState: SnapshotState; /** - * [description] - */ - snapshotType: string; - - /** - * [description] - */ - snapshotEncoder: number; - - /** - * [description] + * Prepares the game canvas for rendering. */ init(): void; /** - * Resize the main game canvas. - * @param width [description] - * @param height [description] + * The event handler that manages the `resize` event dispatched by the Scale Manager. + * @param gameSize The default Game Size object. This is the un-modified game dimensions. + * @param baseSize The base Size object. The game dimensions multiplied by the resolution. The canvas width / height values match this. + * @param displaySize The display Size object. The size of the canvas style width / height attributes. + * @param resolution The Scale Manager resolution setting. */ - resize(width: integer, height: integer): void; + onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size, displaySize: Phaser.Structs.Size, resolution?: number): void; /** - * [description] - * @param callback [description] + * Resize the main game canvas. + * @param width The new width of the renderer. + * @param height The new height of the renderer. + */ + resize(width?: number, height?: number): void; + + /** + * A NOOP method for handling lost context. Intentionally empty. + * @param callback Ignored parameter. */ onContextLost(callback: Function): void; /** - * [description] - * @param callback [description] + * A NOOP method for handling restored context. Intentionally empty. + * @param callback Ignored parameter. */ onContextRestored(callback: Function): void; /** - * [description] + * Resets the transformation matrix of the current context to the identity matrix, thus resetting any transformation. */ resetTransform(): void; /** - * [description] - * @param blendMode [description] + * Sets the blend mode (compositing operation) of the current context. + * @param blendMode The new blend mode which should be used. */ - setBlendMode(blendMode: number): number; + setBlendMode(blendMode: string): this; /** - * [description] - * @param alpha [description] + * Changes the Canvas Rendering Context that all draw operations are performed against. + * @param ctx The new Canvas Rendering Context to draw everything to. Leave empty to reset to the Game Canvas. */ - setAlpha(alpha: number): number; + setContext(ctx?: CanvasRenderingContext2D): this; + + /** + * Sets the global alpha of the current context. + * @param alpha The new alpha to use, where 0 is fully transparent and 1 is fully opaque. + */ + setAlpha(alpha: number): this; /** * Called at the start of the render loop. @@ -45601,72 +61915,138 @@ declare namespace Phaser { /** * Renders the Scene to the given Camera. - * @param scene [description] - * @param children [description] - * @param interpolationPercentage [description] - * @param camera [description] + * @param scene The Scene to render. + * @param children The Game Objects within the Scene to be rendered. + * @param interpolationPercentage The interpolation percentage to apply. Currently unused. + * @param camera The Scene Camera to render with. */ render(scene: Phaser.Scene, children: Phaser.GameObjects.DisplayList, interpolationPercentage: number, camera: Phaser.Cameras.Scene2D.Camera): void; /** - * [description] + * Restores the game context's global settings and takes a snapshot if one is scheduled. + * + * The post-render step happens after all Cameras in all Scenes have been rendered. */ postRender(): void; /** - * [description] - * @param callback [description] - * @param type [description] - * @param encoderOptions [description] + * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. + * + * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets + * more expensive the larger the canvas size gets, so please be careful how you employ this in your game. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. */ - snapshot(callback: SnapshotCallback, type: string, encoderOptions: number): void; + snapshot(callback: SnapshotCallback, type?: string, encoderOptions?: number): this; /** - * [description] + * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * Snapshots work by creating an Image object from the canvas data, this is a blocking process, which gets + * more expensive the larger the canvas size gets, so please be careful how you employ this in your game. + * @param x The x coordinate to grab from. + * @param y The y coordinate to grab from. + * @param width The width of the area to grab. + * @param height The height of the area to grab. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + */ + snapshotArea(x: integer, y: integer, width: integer, height: integer, callback: SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then + * calling this method will override it. + * + * Unlike the other two snapshot methods, this one will return a `Color` object containing the color data for + * the requested pixel. It doesn't need to create an internal Canvas or Image object, so is a lot faster to execute, + * using less memory. + * @param x The x coordinate of the pixel to get. + * @param y The y coordinate of the pixel to get. + * @param callback The Function to invoke after the snapshot pixel data is extracted. + */ + snapshotPixel(x: integer, y: integer, callback: SnapshotCallback): this; + + /** + * Takes a Sprite Game Object, or any object that extends it, and draws it to the current context. + * @param sprite The texture based Game Object to draw. + * @param frame The frame to draw, doesn't have to be that owned by the Game Object. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(sprite: Phaser.GameObjects.GameObject, frame: Phaser.Textures.Frame, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Destroys all object references in the Canvas Renderer. */ destroy(): void; } /** - * No scaling, anchor, rotation or effects, literally draws the frame directly to the canvas. - * @param dx The x coordinate to render the Frame to. - * @param dy The y coordinate to render the Frame to. - * @param frame The Frame to render. - */ - function BlitImage(dx: number, dy: number, frame: Phaser.Textures.Frame): void; - - /** - * [description] - * @param src [description] - * @param camera [description] - * @param parentMatrix [description] - */ - function DrawImage(src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] + * Returns an array which maps the default blend modes to supported Canvas blend modes. + * + * If the browser doesn't support a blend mode, it will default to the normal `source-over` blend mode. */ function GetBlendModes(): any[]; + /** + * Takes a reference to the Canvas Renderer, a Canvas Rendering Context, a Game Object, a Camera and a parent matrix + * and then performs the following steps: + * + * 1. Checks the alpha of the source combined with the Camera alpha. If 0 or less it aborts. + * 2. Takes the Camera and Game Object matrix and multiplies them, combined with the parent matrix if given. + * 3. Sets the blend mode of the context to be that used by the Game Object. + * 4. Sets the alpha value of the context to be that used by the Game Object combined with the Camera. + * 5. Saves the context state. + * 6. Sets the final matrix values into the context via setTransform. + * + * This function is only meant to be used internally. Most of the Canvas Renderer classes use it. + * @param renderer A reference to the current active Canvas renderer. + * @param ctx The canvas context to set the transform on. + * @param src The Game Object being rendered. Can be any type that extends the base class. + * @param camera The Camera that is rendering the Game Object. + * @param parentMatrix A parent transform matrix to apply to the Game Object before rendering. + */ + function SetTransform(renderer: Phaser.Renderer.Canvas.CanvasRenderer, ctx: CanvasRenderingContext2D, src: Phaser.GameObjects.GameObject, camera: Phaser.Cameras.Scene2D.Camera, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): boolean; + } namespace Snapshot { /** - * [description] - * @param canvas [description] - * @param type [description] Default 'image/png'. - * @param encoderOptions [description] Default 0.92. + * Takes a snapshot of an area from the current frame displayed by a canvas. + * + * This is then copied to an Image object. When this loads, the results are sent + * to the callback provided in the Snapshot Configuration object. + * @param sourceCanvas The canvas to take a snapshot of. + * @param config The snapshot configuration object. */ - function Canvas(canvas: HTMLCanvasElement, type?: string, encoderOptions?: number): HTMLImageElement; + function Canvas(sourceCanvas: HTMLCanvasElement, config: SnapshotState): void; /** - * [description] - * @param sourceCanvas [description] - * @param type [description] Default 'image/png'. - * @param encoderOptions [description] Default 0.92. + * Takes a snapshot of an area from the current frame displayed by a WebGL canvas. + * + * This is then copied to an Image object. When this loads, the results are sent + * to the callback provided in the Snapshot Configuration object. + * @param sourceCanvas The canvas to take a snapshot of. + * @param config The snapshot configuration object. */ - function WebGL(sourceCanvas: HTMLCanvasElement, type?: string, encoderOptions?: number): HTMLImageElement; + function WebGL(sourceCanvas: HTMLCanvasElement, config: SnapshotState): void; } @@ -45712,7 +62092,7 @@ declare namespace Phaser { * Called every time the pipeline needs to be used. * It binds all necessary resources. */ - onBind(): Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline; + onBind(): this; /** * [description] @@ -45720,7 +62100,7 @@ declare namespace Phaser { * @param height [description] * @param resolution [description] */ - resize(width: number, height: number, resolution: number): Phaser.Renderer.WebGL.Pipelines.BitmapMaskPipeline; + resize(width: number, height: number, resolution: number): this; /** * Binds necessary resources and renders the mask to a separated framebuffer. @@ -45742,281 +62122,6 @@ declare namespace Phaser { } - /** - * The FlatTintPipeline is used for rendering flat colored shapes. - * Mostly used by the Graphics game object. - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - */ - class FlatTintPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config Used for overriding shader an pipeline properties if extending this pipeline. - */ - constructor(config: object); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewF32: Float32Array; - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewU32: Uint32Array; - - /** - * Used internally to draw triangles - */ - tempTriangle: any[]; - - /** - * Used internally by for triangulating a polyong - */ - polygonCache: any[]; - - /** - * [description] - */ - onBind(): Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline; - - /** - * [description] - * @param width [description] - * @param height [description] - * @param resolution [description] - */ - resize(width: number, height: number, resolution: number): Phaser.Renderer.WebGL.Pipelines.FlatTintPipeline; - - /** - * Pushes a rectangle into the vertex batch - * @param srcX Graphics horizontal component for translation - * @param srcY Graphics vertical component for translation - * @param srcScaleX Graphics horizontal component for scale - * @param srcScaleY Graphics vertical component for scale - * @param srcRotation Graphics rotation - * @param x Horiztonal top left coordinate of the rectangle - * @param y Vertical top left coordinate of the rectangle - * @param width Width of the rectangle - * @param height Height of the rectangle - * @param fillColor RGB color packed as a uint - * @param fillAlpha Alpha represented as float - * @param a1 Matrix stack top a component - * @param b1 Matrix stack top b component - * @param c1 Matrix stack top c component - * @param d1 Matrix stack top d component - * @param e1 Matrix stack top e component - * @param f1 Matrix stack top f component - * @param currentMatrix Parent matrix, generally used by containers - */ - batchFillRect(srcX: number, srcY: number, srcScaleX: number, srcScaleY: number, srcRotation: number, x: number, y: number, width: number, height: number, fillColor: integer, fillAlpha: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, currentMatrix: Float32Array): void; - - /** - * [description] - * @param srcX Graphics horizontal component for translation - * @param srcY Graphics vertical component for translation - * @param srcScaleX Graphics horizontal component for scale - * @param srcScaleY Graphics vertical component for scale - * @param srcRotation Graphics rotation - * @param x0 Point 0 x coordinate - * @param y0 Point 0 y coordinate - * @param x1 Point 1 x coordinate - * @param y1 Point 1 y coordinate - * @param x2 Point 2 x coordinate - * @param y2 Point 2 y coordinate - * @param fillColor RGB color packed as a uint - * @param fillAlpha Alpha represented as float - * @param a1 Matrix stack top a component - * @param b1 Matrix stack top b component - * @param c1 Matrix stack top c component - * @param d1 Matrix stack top d component - * @param e1 Matrix stack top e component - * @param f1 Matrix stack top f component - * @param currentMatrix Parent matrix, generally used by containers - */ - batchFillTriangle(srcX: number, srcY: number, srcScaleX: number, srcScaleY: number, srcRotation: number, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, fillColor: integer, fillAlpha: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, currentMatrix: Float32Array): void; - - /** - * [description] - * @param srcX Graphics horizontal component for translation - * @param srcY Graphics vertical component for translation - * @param srcScaleX Graphics horizontal component for scale - * @param srcScaleY Graphics vertical component for scale - * @param srcRotation Graphics rotation - * @param x0 [description] - * @param y0 [description] - * @param x1 [description] - * @param y1 [description] - * @param x2 [description] - * @param y2 [description] - * @param lineWidth Size of the line as a float value - * @param lineColor RGB color packed as a uint - * @param lineAlpha Alpha represented as float - * @param a Matrix stack top a component - * @param b Matrix stack top b component - * @param c Matrix stack top c component - * @param d Matrix stack top d component - * @param e Matrix stack top e component - * @param f Matrix stack top f component - * @param currentMatrix Parent matrix, generally used by containers - */ - batchStrokeTriangle(srcX: number, srcY: number, srcScaleX: number, srcScaleY: number, srcRotation: number, x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, lineWidth: number, lineColor: integer, lineAlpha: number, a: number, b: number, c: number, d: number, e: number, f: number, currentMatrix: Float32Array): void; - - /** - * [description] - * @param srcX Graphics horizontal component for translation - * @param srcY Graphics vertical component for translation - * @param srcScaleX Graphics horizontal component for scale - * @param srcScaleY Graphics vertical component for scale - * @param srcRotation Graphics rotation - * @param path Collection of points that represent the path - * @param fillColor RGB color packed as a uint - * @param fillAlpha Alpha represented as float - * @param a1 Matrix stack top a component - * @param b1 Matrix stack top b component - * @param c1 Matrix stack top c component - * @param d1 Matrix stack top d component - * @param e1 Matrix stack top e component - * @param f1 Matrix stack top f component - * @param currentMatrix Parent matrix, generally used by containers - */ - batchFillPath(srcX: number, srcY: number, srcScaleX: number, srcScaleY: number, srcRotation: number, path: number, fillColor: integer, fillAlpha: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, currentMatrix: Float32Array): void; - - /** - * [description] - * @param srcX Graphics horizontal component for translation - * @param srcY Graphics vertical component for translation - * @param srcScaleX Graphics horizontal component for scale - * @param srcScaleY Graphics vertical component for scale - * @param srcRotation Graphics rotation - * @param path [description] - * @param lineWidth [description] - * @param lineColor RGB color packed as a uint - * @param lineAlpha Alpha represented as float - * @param a Matrix stack top a component - * @param b Matrix stack top b component - * @param c Matrix stack top c component - * @param d Matrix stack top d component - * @param e Matrix stack top e component - * @param f Matrix stack top f component - * @param isLastPath Indicates if the path should be closed - * @param currentMatrix Parent matrix, generally used by containers - */ - batchStrokePath(srcX: number, srcY: number, srcScaleX: number, srcScaleY: number, srcRotation: number, path: any[], lineWidth: number, lineColor: integer, lineAlpha: number, a: number, b: number, c: number, d: number, e: number, f: number, isLastPath: boolean, currentMatrix: Float32Array): void; - - /** - * [description] - * @param srcX Graphics horizontal component for translation - * @param srcY Graphics vertical component for translation - * @param srcScaleX Graphics horizontal component for scale - * @param srcScaleY Graphics vertical component for scale - * @param srcRotation Graphics rotation - * @param ax X coordinate to the start of the line - * @param ay Y coordinate to the start of the line - * @param bx X coordinate to the end of the line - * @param by Y coordinate to the end of the line - * @param aLineWidth Width of the start of the line - * @param bLineWidth Width of the end of the line - * @param aLineColor RGB color packed as a uint - * @param bLineColor RGB color packed as a uint - * @param lineAlpha Alpha represented as float - * @param a1 Matrix stack top a component - * @param b1 Matrix stack top b component - * @param c1 Matrix stack top c component - * @param d1 Matrix stack top d component - * @param e1 Matrix stack top e component - * @param f1 Matrix stack top f component - * @param currentMatrix Parent matrix, generally used by containers - */ - batchLine(srcX: number, srcY: number, srcScaleX: number, srcScaleY: number, srcRotation: number, ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, aLineColor: integer, bLineColor: integer, lineAlpha: number, a1: number, b1: number, c1: number, d1: number, e1: number, f1: number, currentMatrix: Float32Array): void; - - /** - * [description] - * @param graphics [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchGraphics(graphics: Phaser.GameObjects.Graphics, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param tilemap [description] - * @param camera [description] - */ - drawStaticTilemapLayer(tilemap: Phaser.Tilemaps.StaticTilemapLayer, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param emitterManager [description] - * @param camera [description] - */ - drawEmitterManager(emitterManager: Phaser.GameObjects.Particles.ParticleEmitterManager, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param blitter [description] - * @param camera [description] - */ - drawBlitter(blitter: Phaser.GameObjects.Blitter, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param sprite [description] - * @param camera [description] - */ - batchSprite(sprite: Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param mesh [description] - * @param camera [description] - */ - batchMesh(mesh: Phaser.GameObjects.Mesh, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param bitmapText [description] - * @param camera [description] - */ - batchBitmapText(bitmapText: Phaser.GameObjects.BitmapText, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param bitmapText [description] - * @param camera [description] - */ - batchDynamicBitmapText(bitmapText: Phaser.GameObjects.DynamicBitmapText, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param text [description] - * @param camera [description] - */ - batchText(text: Phaser.GameObjects.Text, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param tilemapLayer [description] - * @param camera [description] - */ - batchDynamicTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer, camera: Phaser.Cameras.Scene2D.Camera): void; - - /** - * [description] - * @param tileSprite [description] - * @param camera [description] - */ - batchTileSprite(tileSprite: Phaser.GameObjects.TileSprite, camera: Phaser.Cameras.Scene2D.Camera): void; - - } - /** * ForwardDiffuseLightPipeline implements a forward rendering approach for 2D lights. * This pipeline extends TextureTintPipeline so it implements all it's rendering functions @@ -46025,246 +62130,16 @@ declare namespace Phaser { class ForwardDiffuseLightPipeline extends Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline { /** * - * @param config [description] + * @param config The configuration of the pipeline, same as the {@link Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline}. The fragment shader will be replaced with the lighting shader. */ constructor(config: object); /** * This function sets all the needed resources for each camera pass. - * @param scene [description] - * @param camera [description] + * @param scene The Scene being rendered. + * @param camera The Scene Camera being rendered with. */ - onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): Phaser.Renderer.WebGL.Pipelines.ForwardDiffuseLightPipeline; - - /** - * [description] - * @param emitterManager [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - drawEmitterManager(emitterManager: Phaser.GameObjects.Particles.ParticleEmitterManager, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param blitter [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - drawBlitter(blitter: Phaser.GameObjects.Blitter, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param sprite [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchSprite(sprite: Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param mesh [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchMesh(mesh: Phaser.GameObjects.Mesh, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param bitmapText [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchBitmapText(bitmapText: Phaser.GameObjects.BitmapText, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param bitmapText [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchDynamicBitmapText(bitmapText: Phaser.GameObjects.DynamicBitmapText, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param text [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchText(text: Phaser.GameObjects.Text, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param tilemapLayer [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchDynamicTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * [description] - * @param tileSprite [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchTileSprite(tileSprite: Phaser.GameObjects.TileSprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - } - - /** - * TextureTintPipeline implements the rendering infrastructure - * for displaying textured objects - * The config properties are: - * - game: Current game instance. - * - renderer: Current WebGL renderer. - * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. - * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). - * - vertShader: Source for vertex shader as a string. - * - fragShader: Source for fragment shader as a string. - * - vertexCapacity: The amount of vertices that shall be allocated - * - vertexSize: The size of a single vertex in bytes. - */ - class TextureTintPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { - /** - * - * @param config [description] - */ - constructor(config: object); - - /** - * Float32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewF32: Float32Array; - - /** - * Uint32 view of the array buffer containing the pipeline's vertices. - */ - vertexViewU32: Uint32Array; - - /** - * Size of the batch. - */ - maxQuads: integer; - - /** - * Collection of batch information - */ - batches: any[]; - - /** - * Assigns a texture to the current batch. If a texture is already set it creates - * a new batch object. - * @param texture WebGLTexture that will be assigned to the current batch. - * @param textureUnit Texture unit to which the texture needs to be bound. - */ - setTexture2D(texture: WebGLTexture, textureUnit: integer): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; - - /** - * Creates a new batch object and pushes it to a batch array. - * The batch object contains information relevant to the current - * vertex batch like the offset in the vertex buffer, vertex count and - * the textures used by that batch. - */ - pushBatch(): void; - - /** - * Binds, uploads resources and processes all batches generating draw calls. - */ - flush(): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; - - /** - * Called every time the pipeline needs to be used. - * It binds all necessary resources. - */ - onBind(): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; - - /** - * [description] - * @param width [description] - * @param height [description] - * @param resolution [description] - */ - resize(width: number, height: number, resolution: number): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; - - /** - * Renders immediately a static tilemap. This function won't use - * the batching functionality of the pipeline. - * @param tilemap [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - drawStaticTilemapLayer(tilemap: Phaser.Tilemaps.StaticTilemapLayer, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Renders contents of a ParticleEmitterManager. It'll batch all particles if possible. - * @param emitterManager [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - drawEmitterManager(emitterManager: Phaser.GameObjects.Particles.ParticleEmitterManager, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches blitter game object - * @param blitter [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - drawBlitter(blitter: Phaser.GameObjects.Blitter, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches Sprite game object - * @param sprite [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchSprite(sprite: Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches Mesh game object - * @param mesh [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchMesh(mesh: Phaser.GameObjects.Mesh, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches BitmapText game object - * @param bitmapText [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchBitmapText(bitmapText: Phaser.GameObjects.BitmapText, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches DynamicBitmapText game object - * @param bitmapText [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchDynamicBitmapText(bitmapText: Phaser.GameObjects.DynamicBitmapText, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches Text game object - * @param text [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchText(text: Phaser.GameObjects.Text, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches DynamicTilemapLayer game object - * @param tilemapLayer [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchDynamicTilemapLayer(tilemapLayer: Phaser.Tilemaps.DynamicTilemapLayer, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; - - /** - * Batches TileSprite game object - * @param tileSprite [description] - * @param camera [description] - * @param parentTransformMatrix [description] - */ - batchTileSprite(tileSprite: Phaser.GameObjects.TileSprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): this; /** * Generic function for batching a textured quad @@ -46293,35 +62168,341 @@ declare namespace Phaser { * @param tintTR Tint for top right * @param tintBL Tint for bottom left * @param tintBR Tint for bottom right + * @param tintEffect The tint effect (0 for additive, 1 for replacement) * @param uOffset Horizontal offset on texture coordinate * @param vOffset Vertical offset on texture coordinate * @param camera Current used camera * @param parentTransformMatrix Parent container */ - batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: integer, textureHeight: integer, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: integer, tintTR: integer, tintBL: integer, tintBR: integer, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: integer, textureHeight: integer, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: integer, tintTR: integer, tintBL: integer, tintBR: integer, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; /** - * Immediately draws a texture with no batching. - * @param texture [description] - * @param srcX [description] - * @param srcY [description] - * @param tint [description] - * @param alpha [description] - * @param frameX [description] - * @param frameY [description] - * @param frameWidth [description] - * @param frameHeight [description] - * @param transformMatrix [description] - * @param parentTransformMatrix [description] + * Sets the Game Objects normal map as the active texture. + * @param gameObject The Game Object to update. */ - drawTexture(texture: WebGLTexture, srcX: number, srcY: number, tint: number, alpha: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; + setNormalMap(gameObject: Phaser.GameObjects.GameObject): void; /** - * [description] - * @param graphics [description] - * @param camera [description] + * Rotates the normal map vectors inversely by the given angle. + * Only works in 2D space. + * @param rotation The angle of rotation in radians. */ - batchGraphics(graphics: Phaser.GameObjects.Graphics, camera: Phaser.Cameras.Scene2D.Camera): void; + setNormalMapRotation(rotation: number): void; + + /** + * Takes a Sprite Game Object, or any object that extends it, which has a normal texture and adds it to the batch. + * @param sprite The texture-based Game Object to add to the batch. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(sprite: Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + } + + /** + * TextureTintPipeline implements the rendering infrastructure + * for displaying textured objects + * The config properties are: + * - game: Current game instance. + * - renderer: Current WebGL renderer. + * - topology: This indicates how the primitives are rendered. The default value is GL_TRIANGLES. + * Here is the full list of rendering primitives (https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants). + * - vertShader: Source for vertex shader as a string. + * - fragShader: Source for fragment shader as a string. + * - vertexCapacity: The amount of vertices that shall be allocated + * - vertexSize: The size of a single vertex in bytes. + */ + class TextureTintPipeline extends Phaser.Renderer.WebGL.WebGLPipeline { + /** + * + * @param config The configuration options for this Texture Tint Pipeline, as described above. + */ + constructor(config: object); + + /** + * Float32 view of the array buffer containing the pipeline's vertices. + */ + vertexViewF32: Float32Array; + + /** + * Uint32 view of the array buffer containing the pipeline's vertices. + */ + vertexViewU32: Uint32Array; + + /** + * Size of the batch. + */ + maxQuads: integer; + + /** + * Collection of batch information + */ + batches: any[]; + + /** + * Called every time the pipeline needs to be used. + * It binds all necessary resources. + */ + onBind(): this; + + /** + * Resizes this pipeline and updates the projection. + * @param width The new width. + * @param height The new height. + * @param resolution The resolution. + */ + resize(width: number, height: number, resolution: number): this; + + /** + * Assigns a texture to the current batch. If a different texture is already set it creates a new batch object. + * @param texture WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + setTexture2D(texture?: WebGLTexture, unit?: integer): Phaser.Renderer.WebGL.Pipelines.TextureTintPipeline; + + /** + * Checks if the current batch has the same texture and texture unit, or if we need to create a new batch. + * @param texture WebGLTexture that will be assigned to the current batch. If not given uses blankTexture. + * @param unit Texture unit to which the texture needs to be bound. + */ + requireTextureBatch(texture: WebGLTexture, unit: integer): boolean; + + /** + * Creates a new batch object and pushes it to a batch array. + * The batch object contains information relevant to the current + * vertex batch like the offset in the vertex buffer, vertex count and + * the textures used by that batch. + * @param texture Optional WebGLTexture that will be assigned to the created batch. + * @param unit Texture unit to which the texture needs to be bound. + */ + pushBatch(texture: WebGLTexture, unit: integer): void; + + /** + * Uploads the vertex data and emits a draw call for the current batch of vertices. + */ + flush(): this; + + /** + * Takes a Sprite Game Object, or any object that extends it, and adds it to the batch. + * @param sprite The texture based Game Object to add to the batch. + * @param camera The Camera to use for the rendering transform. + * @param parentTransformMatrix The transform matrix of the parent container, if set. + */ + batchSprite(sprite: Phaser.GameObjects.Image | Phaser.GameObjects.Sprite, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 6 vertices in the following arrangement: + * + * ``` + * 0----3 + * |\ B| + * | \ | + * | \ | + * | A \| + * | \ + * 1----2 + * ``` + * + * Where tx0/ty0 = 0, tx1/ty1 = 1, tx2/ty2 = 2 and tx3/ty3 = 3 + * @param x0 The top-left x position. + * @param y0 The top-left y position. + * @param x1 The bottom-left x position. + * @param y1 The bottom-left y position. + * @param x2 The bottom-right x position. + * @param y2 The bottom-right y position. + * @param x3 The top-right x position. + * @param y3 The top-right y position. + * @param u0 UV u0 value. + * @param v0 UV v0 value. + * @param u1 UV u1 value. + * @param v1 UV v1 value. + * @param tintTL The top-left tint color value. + * @param tintTR The top-right tint color value. + * @param tintBL The bottom-left tint color value. + * @param tintBR The bottom-right tint color value. + * @param tintEffect The tint effect for the shader to use. + * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + batchQuad(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintBR: number, tintEffect: number | boolean, texture?: WebGLTexture, unit?: integer): boolean; + + /** + * Adds the vertices data into the batch and flushes if full. + * + * Assumes 3 vertices in the following arrangement: + * + * ``` + * 0 + * |\ + * | \ + * | \ + * | \ + * | \ + * 1-----2 + * ``` + * @param x1 The bottom-left x position. + * @param y1 The bottom-left y position. + * @param x2 The bottom-right x position. + * @param y2 The bottom-right y position. + * @param x3 The top-right x position. + * @param y3 The top-right y position. + * @param u0 UV u0 value. + * @param v0 UV v0 value. + * @param u1 UV u1 value. + * @param v1 UV v1 value. + * @param tintTL The top-left tint color value. + * @param tintTR The top-right tint color value. + * @param tintBL The bottom-left tint color value. + * @param tintEffect The tint effect for the shader to use. + * @param texture WebGLTexture that will be assigned to the current batch if a flush occurs. + * @param unit Texture unit to which the texture needs to be bound. Default 0. + */ + batchTri(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, u0: number, v0: number, u1: number, v1: number, tintTL: number, tintTR: number, tintBL: number, tintEffect: number | boolean, texture?: WebGLTexture, unit?: integer): boolean; + + /** + * Generic function for batching a textured quad using argument values instead of a Game Object. + * @param gameObject Source GameObject. + * @param texture Raw WebGLTexture associated with the quad. + * @param textureWidth Real texture width. + * @param textureHeight Real texture height. + * @param srcX X coordinate of the quad. + * @param srcY Y coordinate of the quad. + * @param srcWidth Width of the quad. + * @param srcHeight Height of the quad. + * @param scaleX X component of scale. + * @param scaleY Y component of scale. + * @param rotation Rotation of the quad. + * @param flipX Indicates if the quad is horizontally flipped. + * @param flipY Indicates if the quad is vertically flipped. + * @param scrollFactorX By which factor is the quad affected by the camera horizontal scroll. + * @param scrollFactorY By which factor is the quad effected by the camera vertical scroll. + * @param displayOriginX Horizontal origin in pixels. + * @param displayOriginY Vertical origin in pixels. + * @param frameX X coordinate of the texture frame. + * @param frameY Y coordinate of the texture frame. + * @param frameWidth Width of the texture frame. + * @param frameHeight Height of the texture frame. + * @param tintTL Tint for top left. + * @param tintTR Tint for top right. + * @param tintBL Tint for bottom left. + * @param tintBR Tint for bottom right. + * @param tintEffect The tint effect. + * @param uOffset Horizontal offset on texture coordinate. + * @param vOffset Vertical offset on texture coordinate. + * @param camera Current used camera. + * @param parentTransformMatrix Parent container. + * @param skipFlip Skip the renderTexture check. Default false. + */ + batchTexture(gameObject: Phaser.GameObjects.GameObject, texture: WebGLTexture, textureWidth: integer, textureHeight: integer, srcX: number, srcY: number, srcWidth: number, srcHeight: number, scaleX: number, scaleY: number, rotation: number, flipX: boolean, flipY: boolean, scrollFactorX: number, scrollFactorY: number, displayOriginX: number, displayOriginY: number, frameX: number, frameY: number, frameWidth: number, frameHeight: number, tintTL: integer, tintTR: integer, tintBL: integer, tintBR: integer, tintEffect: number, uOffset: number, vOffset: number, camera: Phaser.Cameras.Scene2D.Camera, parentTransformMatrix: Phaser.GameObjects.Components.TransformMatrix, skipFlip?: boolean): void; + + /** + * Adds a Texture Frame into the batch for rendering. + * @param frame The Texture Frame to be rendered. + * @param x The horizontal position to render the texture at. + * @param y The vertical position to render the texture at. + * @param tint The tint color. + * @param alpha The alpha value. + * @param transformMatrix The Transform Matrix to use for the texture. + * @param parentTransformMatrix A parent Transform Matrix. + */ + batchTextureFrame(frame: Phaser.Textures.Frame, x: number, y: number, tint: number, alpha: number, transformMatrix: Phaser.GameObjects.Components.TransformMatrix, parentTransformMatrix?: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle has no transform values and isn't transformed into the local space. + * Used for directly batching untransformed rectangles, such as Camera background colors. + * @param x Horizontal top left coordinate of the rectangle. + * @param y Vertical top left coordinate of the rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param color Color of the rectangle to draw. + * @param alpha Alpha value of the rectangle to draw. + */ + drawFillRect(x: number, y: number, width: number, height: number, color: number, alpha: number): void; + + /** + * Pushes a filled rectangle into the vertex batch. + * Rectangle factors in the given transform matrices before adding to the batch. + * @param x Horizontal top left coordinate of the rectangle. + * @param y Vertical top left coordinate of the rectangle. + * @param width Width of the rectangle. + * @param height Height of the rectangle. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillRect(x: number, y: number, width: number, height: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a filled triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * @param x0 Point 0 x coordinate. + * @param y0 Point 0 y coordinate. + * @param x1 Point 1 x coordinate. + * @param y1 Point 1 y coordinate. + * @param x2 Point 2 x coordinate. + * @param y2 Point 2 y coordinate. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Pushes a stroked triangle into the vertex batch. + * Triangle factors in the given transform matrices before adding to the batch. + * The triangle is created from 3 lines and drawn using the `batchStrokePath` method. + * @param x0 Point 0 x coordinate. + * @param y0 Point 0 y coordinate. + * @param x1 Point 1 x coordinate. + * @param y1 Point 1 y coordinate. + * @param x2 Point 2 x coordinate. + * @param y2 Point 2 y coordinate. + * @param lineWidth The width of the line in pixels. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchStrokeTriangle(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, lineWidth: number, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and then passing it through Earcut, which + * creates a list of polygons. Each polygon is then added to the batch. + * + * The path is always automatically closed because it's filled. + * @param path Collection of points that represent the path. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchFillPath(path: any[], currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Adds the given path to the vertex batch for rendering. + * + * It works by taking the array of path data and calling `batchLine` for each section + * of the path. + * + * The path is optionally closed at the end. + * @param path Collection of points that represent the path. + * @param lineWidth The width of the line segments in pixels. + * @param pathOpen Indicates if the path should be closed or left open. + * @param currentMatrix The current transform. + * @param parentMatrix The parent transform. + */ + batchStrokePath(path: any[], lineWidth: number, pathOpen: boolean, currentMatrix: Phaser.GameObjects.Components.TransformMatrix, parentMatrix: Phaser.GameObjects.Components.TransformMatrix): void; + + /** + * Creates a quad and adds it to the vertex batch based on the given line values. + * @param ax X coordinate to the start of the line + * @param ay Y coordinate to the start of the line + * @param bx X coordinate to the end of the line + * @param by Y coordinate to the end of the line + * @param aLineWidth Width of the start of the line + * @param bLineWidth Width of the end of the line + * @param currentMatrix Parent matrix, generally used by containers + */ + batchLine(ax: number, ay: number, bx: number, by: number, aLineWidth: number, bLineWidth: number, currentMatrix: Float32Array): void; } @@ -46331,8 +62512,8 @@ declare namespace Phaser { /** * Packs four floats on a range from 0.0 to 1.0 into a single Uint32 * @param r Red component in a range from 0.0 to 1.0 - * @param g [description] - * @param b [description] + * @param g Green component in a range from 0.0 to 1.0 + * @param b Blue component in a range from 0.0 to 1.0 * @param a Alpha component in a range from 0.0 to 1.0 */ function getTintFromFloats(r: number, g: number, b: number, a: number): number; @@ -46370,12 +62551,12 @@ declare namespace Phaser { } /** - * WebGLPipeline is a class that describes the way elements will be rendererd - * in WebGL, specially focused on batching vertices (batching is not provided). - * Pipelines are mostly used for describing 2D rendering passes but it's - * flexible enough to be used for any type of rendering including 3D. + * WebGLPipeline is a class that describes the way elements will be rendererd + * in WebGL, specially focused on batching vertices (batching is not provided). + * Pipelines are mostly used for describing 2D rendering passes but it's + * flexible enough to be used for any type of rendering including 3D. * Internally WebGLPipeline will handle things like compiling shaders, - * creating vertex buffers, assigning primitive topology and binding + * creating vertex buffers, assigning primitive topology and binding * vertex attributes. * * The config properties are: @@ -46390,7 +62571,7 @@ declare namespace Phaser { * - vertexSize: The size of a single vertex in bytes. * - vertices: An optional buffer of vertices * - attributes: An array describing the vertex attributes - * + * * The vertex attributes properties are: * - name : String - Name of the attribute in the vertex shader * - size : integer - How many components describe the attribute. For ex: vec3 = size of 3, float = size of 1 @@ -46403,7 +62584,7 @@ declare namespace Phaser { class WebGLPipeline { /** * - * @param config [description] + * @param config The configuration object for this WebGL Pipeline, as described above. */ constructor(config: object); @@ -46413,12 +62594,12 @@ declare namespace Phaser { name: string; /** - * [description] + * The Game which owns this WebGL Pipeline. */ game: Phaser.Game; /** - * [description] + * The canvas which this WebGL Pipeline renders to. */ view: HTMLCanvasElement; @@ -46438,7 +62619,7 @@ declare namespace Phaser { height: number; /** - * [description] + * The WebGL context this WebGL Pipeline uses. */ gl: WebGLRenderingContext; @@ -46453,7 +62634,7 @@ declare namespace Phaser { vertexCapacity: integer; /** - * [description] + * The WebGL Renderer which owns this WebGL Pipeline. */ renderer: Phaser.Renderer.WebGL.WebGLRenderer; @@ -46510,6 +62691,14 @@ declare namespace Phaser { */ active: boolean; + /** + * Called when the Game has fully booted and the Renderer has finished setting up. + * + * By this stage all Game level systems are now in place and you can perform any final + * tasks that the pipeline may need that relied on game systems such as the Texture Manager. + */ + boot(): void; + /** * Adds a description of vertex attribute to the pipeline * @param name Name of the vertex attribute @@ -46518,7 +62707,7 @@ declare namespace Phaser { * @param normalized Is the value normalized to a range * @param offset Byte offset to the beginning of the first element in the vertex */ - addAttribute(name: string, size: integer, type: integer, normalized: boolean, offset: integer): Phaser.Renderer.WebGL.WebGLPipeline; + addAttribute(name: string, size: integer, type: integer, normalized: boolean, offset: integer): this; /** * Check if the current batch of vertices is full. @@ -46527,144 +62716,171 @@ declare namespace Phaser { /** * Resizes the properties used to describe the viewport - * @param width [description] - * @param height [description] - * @param resolution [description] + * @param width The new width of this WebGL Pipeline. + * @param height The new height of this WebGL Pipeline. + * @param resolution The resolution this WebGL Pipeline should be resized to. */ - resize(width: number, height: number, resolution: number): Phaser.Renderer.WebGL.WebGLPipeline; + resize(width: number, height: number, resolution: number): this; /** * Binds the pipeline resources, including programs, vertex buffers and binds attributes */ - bind(): Phaser.Renderer.WebGL.WebGLPipeline; + bind(): this; /** - * [description] + * Set whenever this WebGL Pipeline is bound to a WebGL Renderer. + * + * This method is called every time the WebGL Pipeline is attempted to be bound, even if it already is the current pipeline. */ - onBind(): Phaser.Renderer.WebGL.WebGLPipeline; + onBind(): this; /** - * [description] + * Called before each frame is rendered, but after the canvas has been cleared. */ - onPreRender(): Phaser.Renderer.WebGL.WebGLPipeline; + onPreRender(): this; /** - * [description] - * @param scene [description] - * @param camera [description] + * Called before a Scene's Camera is rendered. + * @param scene The Scene being rendered. + * @param camera The Scene Camera being rendered with. */ - onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): Phaser.Renderer.WebGL.WebGLPipeline; + onRender(scene: Phaser.Scene, camera: Phaser.Cameras.Scene2D.Camera): this; /** - * [description] + * Called after each frame has been completely rendered and snapshots have been taken. */ - onPostRender(): Phaser.Renderer.WebGL.WebGLPipeline; + onPostRender(): this; /** * Uploads the vertex data and emits a draw call * for the current batch of vertices. */ - flush(): Phaser.Renderer.WebGL.WebGLPipeline; + flush(): this; /** - * [description] + * Removes all object references in this WebGL Pipeline and removes its program from the WebGL context. */ - destroy(): Phaser.Renderer.WebGL.WebGLPipeline; + destroy(): this; /** * Set a uniform value of the current pipeline program. - * @param name [description] - * @param x [description] + * @param name The name of the uniform to look-up and modify. + * @param x The new value of the `float` uniform. */ - setFloat1(name: string, x: number): Phaser.Renderer.WebGL.WebGLPipeline; + setFloat1(name: string, x: number): this; /** * Set a uniform value of the current pipeline program. - * @param name [description] - * @param x [description] - * @param y [description] + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `vec2` uniform. + * @param y The new Y component of the `vec2` uniform. */ - setFloat2(name: string, x: number, y: number): Phaser.Renderer.WebGL.WebGLPipeline; + setFloat2(name: string, x: number, y: number): this; /** * Set a uniform value of the current pipeline program. - * @param name [description] - * @param x [description] - * @param y [description] - * @param z [description] + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `vec3` uniform. + * @param y The new Y component of the `vec3` uniform. + * @param z The new Z component of the `vec3` uniform. */ - setFloat3(name: string, x: number, y: number, z: number): Phaser.Renderer.WebGL.WebGLPipeline; + setFloat3(name: string, x: number, y: number, z: number): this; /** * Set a uniform value of the current pipeline program. - * @param name Name of the uniform + * @param name The name of the uniform to look-up and modify. * @param x X component of the uniform * @param y Y component of the uniform * @param z Z component of the uniform * @param w W component of the uniform */ - setFloat4(name: string, x: number, y: number, z: number, w: number): Phaser.Renderer.WebGL.WebGLPipeline; + setFloat4(name: string, x: number, y: number, z: number, w: number): this; /** * Set a uniform value of the current pipeline program. - * @param name [description] - * @param x [description] + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. */ - setInt1(name: string, x: integer): Phaser.Renderer.WebGL.WebGLPipeline; + setFloat1v(name: string, arr: Float32Array): this; /** * Set a uniform value of the current pipeline program. - * @param name [description] - * @param x [description] - * @param y [description] + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. */ - setInt2(name: string, x: integer, y: integer): Phaser.Renderer.WebGL.WebGLPipeline; + setFloat2v(name: string, arr: Float32Array): this; /** * Set a uniform value of the current pipeline program. - * @param name [description] - * @param x [description] - * @param y [description] - * @param z [description] + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. */ - setInt3(name: string, x: integer, y: integer, z: integer): Phaser.Renderer.WebGL.WebGLPipeline; + setFloat3v(name: string, arr: Float32Array): this; /** * Set a uniform value of the current pipeline program. - * @param name Name of the uniform + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat4v(name: string, arr: Float32Array): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new value of the `int` uniform. + */ + setInt1(name: string, x: integer): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `ivec2` uniform. + * @param y The new Y component of the `ivec2` uniform. + */ + setInt2(name: string, x: integer, y: integer): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component of the `ivec3` uniform. + * @param y The new Y component of the `ivec3` uniform. + * @param z The new Z component of the `ivec3` uniform. + */ + setInt3(name: string, x: integer, y: integer, z: integer): this; + + /** + * Set a uniform value of the current pipeline program. + * @param name The name of the uniform to look-up and modify. * @param x X component of the uniform * @param y Y component of the uniform * @param z Z component of the uniform * @param w W component of the uniform */ - setInt4(name: string, x: integer, y: integer, z: integer, w: integer): Phaser.Renderer.WebGL.WebGLPipeline; + setInt4(name: string, x: integer, y: integer, z: integer, w: integer): this; /** * Set a uniform value of the current pipeline program. - * [description] - * @param name [description] - * @param transpose [description] - * @param matrix [description] + * @param name The name of the uniform to look-up and modify. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat2` uniform. */ - setMatrix2(name: string, transpose: boolean, matrix: Float32Array): Phaser.Renderer.WebGL.WebGLPipeline; + setMatrix2(name: string, transpose: boolean, matrix: Float32Array): this; /** * Set a uniform value of the current pipeline program. - * [description] - * [description] - * @param name [description] - * @param transpose [description] - * @param matrix [description] + * @param name The name of the uniform to look-up and modify. + * @param transpose Whether to transpose the matrix. Should be `false`. + * @param matrix The new values for the `mat3` uniform. */ - setMatrix3(name: string, transpose: boolean, matrix: Float32Array): Phaser.Renderer.WebGL.WebGLPipeline; + setMatrix3(name: string, transpose: boolean, matrix: Float32Array): this; /** * Set a uniform value of the current pipeline program. - * @param name Name of the uniform + * @param name The name of the uniform to look-up and modify. * @param transpose Should the matrix be transpose * @param matrix Matrix data */ - setMatrix4(name: string, transpose: boolean, matrix: Float32Array): Phaser.Renderer.WebGL.WebGLPipeline; + setMatrix4(name: string, transpose: boolean, matrix: Float32Array): this; } @@ -46674,58 +62890,62 @@ declare namespace Phaser { * any context change that happens for WebGL rendering inside of Phaser. This means * if raw webgl functions are called outside the WebGLRenderer of the Phaser WebGL * rendering ecosystem they might pollute the current WebGLRenderingContext state producing - * unexpected behaviour. It's recommended that WebGL interaction is done through + * unexpected behavior. It's recommended that WebGL interaction is done through * WebGLRenderer and/or WebGLPipeline. */ class WebGLRenderer { /** * - * @param game [description] + * @param game The Game instance which owns this WebGL Renderer. */ constructor(game: Phaser.Game); /** - * [description] + * The local configuration settings of this WebGL Renderer. */ - config: RendererConfig; + config: object; /** - * [description] + * The Game instance which owns this WebGL Renderer. */ game: Phaser.Game; /** - * [description] + * A constant which allows the renderer to be easily identified as a WebGL Renderer. */ type: integer; /** - * [description] + * The width of the canvas being rendered to. + * This is populated in the onResize event handler. */ - width: number; + width: integer; /** - * [description] + * The height of the canvas being rendered to. + * This is populated in the onResize event handler. */ - height: number; + height: integer; /** - * [description] + * The canvas which this WebGL Renderer draws to. */ canvas: HTMLCanvasElement; /** - * [description] + * An array of functions to invoke if the WebGL context is lost. */ lostContextCallbacks: WebGLContextCallback[]; /** - * [description] + * An array of functions to invoke if the WebGL context is restored. */ restoredContextCallbacks: WebGLContextCallback[]; /** - * [description] + * An array of blend modes supported by the WebGL Renderer. + * + * This array includes the default blend modes as well as any custom blend modes added through {@link #addBlendMode}. */ blendModes: any[]; @@ -46735,7 +62955,7 @@ declare namespace Phaser { nativeTextures: any[]; /** - * [description] + * Set to `true` if the WebGL context of the renderer is lost. */ contextLost: boolean; @@ -46745,7 +62965,9 @@ declare namespace Phaser { pipelines: object; /** - * [description] + * Details about the currently scheduled snapshot. + * + * If a non-null `callback` is set in this object, a snapshot of the canvas will be taken after the current frame is fully rendered. */ snapshotState: SnapshotState; @@ -46799,18 +63021,13 @@ declare namespace Phaser { */ currentScissor: Uint32Array; - /** - * Index to the scissor stack top - */ - currentScissorIdx: number; - /** * Stack of scissor data */ scissorStack: Uint32Array; /** - * [description] + * The underlying WebGL context of the renderer. */ gl: WebGLRenderingContext; @@ -46835,32 +63052,57 @@ declare namespace Phaser { compression: any[]; /** - * Creates a new WebGLRenderingContext and initializes all internal - * state. - * @param config [description] + * Cached drawing buffer height to reduce gl calls. */ - init(config: object): Phaser.Renderer.WebGL.WebGLRenderer; + readonly drawingBufferHeight: number; /** - * [description] - * @param width [description] - * @param height [description] + * A blank 32x32 transparent texture, as used by the Graphics system where needed. + * This is set in the `boot` method. */ - resize(width: number, height: number): Phaser.Renderer.WebGL.WebGLRenderer; + readonly blankTexture: WebGLTexture; /** - * [description] - * @param callback [description] - * @param target [description] + * A default Camera used in calls when no other camera has been provided. */ - onContextRestored(callback: WebGLContextCallback, target: object): Phaser.Renderer.WebGL.WebGLRenderer; + defaultCamera: Phaser.Cameras.Scene2D.BaseCamera; /** - * [description] - * @param callback [description] - * @param target [description] + * Creates a new WebGLRenderingContext and initializes all internal state. + * @param config The configuration object for the renderer. */ - onContextLost(callback: WebGLContextCallback, target: object): Phaser.Renderer.WebGL.WebGLRenderer; + init(config: object): this; + + /** + * The event handler that manages the `resize` event dispatched by the Scale Manager. + * @param gameSize The default Game Size object. This is the un-modified game dimensions. + * @param baseSize The base Size object. The game dimensions multiplied by the resolution. The canvas width / height values match this. + * @param displaySize The display Size object. The size of the canvas style width / height attributes. + * @param resolution The Scale Manager resolution setting. + */ + onResize(gameSize: Phaser.Structs.Size, baseSize: Phaser.Structs.Size, displaySize: Phaser.Structs.Size, resolution?: number): void; + + /** + * Resizes the drawing buffer to match that required by the Scale Manager. + * @param width The new width of the renderer. + * @param height The new height of the renderer. + * @param resolution The new resolution of the renderer. + */ + resize(width?: number, height?: number, resolution?: number): this; + + /** + * Adds a callback to be invoked when the WebGL context has been restored by the browser. + * @param callback The callback to be invoked on context restoration. + * @param target The context of the callback. + */ + onContextRestored(callback: WebGLContextCallback, target: object): this; + + /** + * Adds a callback to be invoked when the WebGL context has been lost by the browser. + * @param callback The callback to be invoked on context loss. + * @param target The context of the callback. + */ + onContextLost(callback: WebGLContextCallback, target: object): this; /** * Checks if a WebGL extension is supported @@ -46870,7 +63112,7 @@ declare namespace Phaser { /** * Loads a WebGL extension - * @param extensionName [description] + * @param extensionName The name of the extension to load. */ getExtension(extensionName: string): object; @@ -46881,144 +63123,173 @@ declare namespace Phaser { /** * Checks if a pipeline is present in the current WebGLRenderer - * @param pipelineName Name of the pipeline + * @param pipelineName The name of the pipeline. */ hasPipeline(pipelineName: string): boolean; /** * Returns the pipeline by name if the pipeline exists - * @param pipelineName [description] + * @param pipelineName The name of the pipeline. */ getPipeline(pipelineName: string): Phaser.Renderer.WebGL.WebGLPipeline; /** - * Removes a pipeline by name - * @param pipelineName [description] + * Removes a pipeline by name. + * @param pipelineName The name of the pipeline to be removed. */ - removePipeline(pipelineName: string): Phaser.Renderer.WebGL.WebGLRenderer; + removePipeline(pipelineName: string): this; /** * Adds a pipeline instance into the collection of pipelines - * @param pipelineName [description] - * @param pipelineInstance Pipeline instance must extend WebGLPipeline + * @param pipelineName A unique string-based key for the pipeline. + * @param pipelineInstance A pipeline instance which must extend WebGLPipeline. */ addPipeline(pipelineName: string, pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Renderer.WebGL.WebGLPipeline; /** - * Sets the current scissor state - * @param x [description] - * @param y [description] - * @param w [description] - * @param h [description] + * Pushes a new scissor state. This is used to set nested scissor states. + * @param x The x position of the scissor. + * @param y The y position of the scissor. + * @param width The width of the scissor. + * @param height The height of the scissor. + * @param drawingBufferHeight Optional drawingBufferHeight override value. */ - setScissor(x: integer, y: integer, w: integer, h: integer): Phaser.Renderer.WebGL.WebGLRenderer; + pushScissor(x: integer, y: integer, width: integer, height: integer, drawingBufferHeight?: integer): integer[]; /** - * Pushes a new scissor state. This is used to set nested scissor states. - * @param x [description] - * @param y [description] - * @param w [description] - * @param h [description] + * Sets the current scissor state. + * @param x The x position of the scissor. + * @param y The y position of the scissor. + * @param width The width of the scissor. + * @param height The height of the scissor. + * @param drawingBufferHeight Optional drawingBufferHeight override value. */ - pushScissor(x: integer, y: integer, w: integer, h: integer): Phaser.Renderer.WebGL.WebGLRenderer; + setScissor(x: integer, y: integer, width: integer, height: integer, drawingBufferHeight?: integer): void; /** * Pops the last scissor state and sets it. */ - popScissor(): Phaser.Renderer.WebGL.WebGLRenderer; + popScissor(): void; /** * Binds a WebGLPipeline and sets it as the current pipeline to be used. - * @param pipelineInstance [description] + * @param pipelineInstance The pipeline instance to be activated. + * @param gameObject The Game Object that invoked this pipeline, if any. */ - setPipeline(pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline): Phaser.Renderer.WebGL.WebGLPipeline; + setPipeline(pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline, gameObject?: Phaser.GameObjects.GameObject): Phaser.Renderer.WebGL.WebGLPipeline; /** - * [description] - * @param blendModeId [description] + * Use this to reset the gl context to the state that Phaser requires to continue rendering. + * Calling this will: + * + * * Disable `DEPTH_TEST`, `CULL_FACE` and `STENCIL_TEST`. + * * Clear the depth buffer and stencil buffers. + * * Reset the viewport size. + * * Reset the blend mode. + * * Bind a blank texture as the active texture on texture unit zero. + * * Rebinds the given pipeline instance. + * + * You should call this having previously called `clearPipeline` and then wishing to return + * control to Phaser again. + * @param pipelineInstance The pipeline instance to be activated. */ - setBlendMode(blendModeId: integer): Phaser.Renderer.WebGL.WebGLRenderer; + rebindPipeline(pipelineInstance: Phaser.Renderer.WebGL.WebGLPipeline): void; /** - * [description] - * @param func [description] - * @param equation [description] + * Flushes the current WebGLPipeline being used and then clears it, along with the + * the current shader program and vertex buffer. Then resets the blend mode to NORMAL. + * Call this before jumping to your own gl context handler, and then call `rebindPipeline` when + * you wish to return control to Phaser again. + */ + clearPipeline(): void; + + /** + * Sets the blend mode to the value given. + * + * If the current blend mode is different from the one given, the pipeline is flushed and the new + * blend mode is enabled. + * @param blendModeId The blend mode to be set. Can be a `BlendModes` const or an integer value. + * @param force Force the blend mode to be set, regardless of the currently set blend mode. Default false. + */ + setBlendMode(blendModeId: integer, force?: boolean): boolean; + + /** + * Creates a new custom blend mode for the renderer. + * @param func An array containing the WebGL functions to use for the source and the destination blending factors, respectively. See the possible constants for {@link WebGLRenderingContext#blendFunc()}. + * @param equation The equation to use for combining the RGB and alpha components of a new pixel with a rendered one. See the possible constants for {@link WebGLRenderingContext#blendEquation()}. */ addBlendMode(func: Function, equation: Function): integer; /** - * [description] - * @param index [description] - * @param func [description] - * @param equation [description] + * Updates the function bound to a given custom blend mode. + * @param index The index of the custom blend mode. + * @param func The function to use for the blend mode. + * @param equation The equation to use for the blend mode. */ - updateBlendMode(index: integer, func: Function, equation: Function): Phaser.Renderer.WebGL.WebGLRenderer; + updateBlendMode(index: integer, func: Function, equation: Function): this; /** - * [description] - * @param index [description] + * Removes a custom blend mode from the renderer. + * Any Game Objects still using this blend mode will error, so be sure to clear them first. + * @param index The index of the custom blend mode to be removed. */ - removeBlendMode(index: integer): Phaser.Renderer.WebGL.WebGLRenderer; + removeBlendMode(index: integer): this; /** - * Binds a texture at a texture unit. If a texture is already + * Binds a texture at a texture unit. If a texture is already * bound to that unit it will force a flush on the current pipeline. - * @param texture The WebGL texture that needs to be bound - * @param textureUnit The texture unit to which the texture will be bound + * @param texture The WebGL texture that needs to be bound. + * @param textureUnit The texture unit to which the texture will be bound. + * @param flush Will the current pipeline be flushed if this is a new texture, or not? Default true. */ - setTexture2D(texture: WebGLTexture, textureUnit: integer): Phaser.Renderer.WebGL.WebGLRenderer; + setTexture2D(texture: WebGLTexture, textureUnit: integer, flush?: boolean): this; /** - * Binds a framebuffer. If there was another framebuffer already bound - * it will force a pipeline flush. - * @param framebuffer The framebuffer that needs to be bound + * Binds a framebuffer. If there was another framebuffer already bound it will force a pipeline flush. + * @param framebuffer The framebuffer that needs to be bound. + * @param updateScissor If a framebuffer is given, set the gl scissor to match the frame buffer size? Or, if `null` given, pop the scissor from the stack. Default false. */ - setFramebuffer(framebuffer: WebGLFramebuffer): Phaser.Renderer.WebGL.WebGLRenderer; + setFramebuffer(framebuffer: WebGLFramebuffer, updateScissor?: boolean): this; /** - * Binds a program. If there was another program already bound - * it will force a pipeline flush - * @param program The program that needs to be bound + * Binds a program. If there was another program already bound it will force a pipeline flush. + * @param program The program that needs to be bound. */ - setProgram(program: WebGLProgram): Phaser.Renderer.WebGL.WebGLRenderer; + setProgram(program: WebGLProgram): this; /** - * Bounds a vertex buffer. If there is a vertex buffer already bound - * it'll force a pipeline flush. - * @param vertexBuffer The buffer that needs to be bound + * Bounds a vertex buffer. If there is a vertex buffer already bound it'll force a pipeline flush. + * @param vertexBuffer The buffer that needs to be bound. */ - setVertexBuffer(vertexBuffer: WebGLBuffer): Phaser.Renderer.WebGL.WebGLRenderer; + setVertexBuffer(vertexBuffer: WebGLBuffer): this; /** - * Bounds a index buffer. If there is a index buffer already bound - * it'll force a pipeline flush. - * @param indexBuffer The buffer the needs to be bound + * Bounds a index buffer. If there is a index buffer already bound it'll force a pipeline flush. + * @param indexBuffer The buffer the needs to be bound. */ - setIndexBuffer(indexBuffer: WebGLBuffer): Phaser.Renderer.WebGL.WebGLRenderer; + setIndexBuffer(indexBuffer: WebGLBuffer): this; /** - * Creates a texture from an image source. If the source is not valid - * it creates an empty texture - * @param source [description] - * @param width [description] - * @param height [description] - * @param scaleMode [description] + * Creates a texture from an image source. If the source is not valid it creates an empty texture. + * @param source The source of the texture. + * @param width The width of the texture. + * @param height The height of the texture. + * @param scaleMode The scale mode to be used by the texture. */ createTextureFromSource(source: object, width: integer, height: integer, scaleMode: integer): WebGLTexture; /** - * A wrapper for creating a WebGLTexture. If not pixel data is passed - * it will create an empty texture. - * @param mipLevel Mip level of the texture - * @param minFilter Filtering of the texture - * @param magFilter Filtering of the texture - * @param wrapT Wrapping mode of the texture - * @param wrapS Wrapping mode of the texture - * @param format Which format does the texture use - * @param pixels pixel data - * @param width Width of the texture in pixels - * @param height Height of the texture in pixels - * @param pma Does the texture hace premultiplied alpha. + * A wrapper for creating a WebGLTexture. If no pixel data is passed it will create an empty texture. + * @param mipLevel Mip level of the texture. + * @param minFilter Filtering of the texture. + * @param magFilter Filtering of the texture. + * @param wrapT Wrapping mode of the texture. + * @param wrapS Wrapping mode of the texture. + * @param format Which format does the texture use. + * @param pixels pixel data. + * @param width Width of the texture in pixels. + * @param height Height of the texture in pixels. + * @param pma Does the texture have premultiplied alpha? */ createTexture2D(mipLevel: integer, minFilter: integer, magFilter: integer, wrapT: integer, wrapS: integer, format: integer, pixels: object, width: integer, height: integer, pma: boolean): WebGLTexture; @@ -47047,46 +63318,46 @@ declare namespace Phaser { /** * Wrapper for creating a vertex buffer. - * @param initialDataOrSize It's either ArrayBuffer or an integer indicating the size of the vbo - * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW + * @param initialDataOrSize Either ArrayBuffer or an integer indicating the size of the vbo. + * @param bufferUsage How the buffer is used. gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW. */ createIndexBuffer(initialDataOrSize: ArrayBuffer, bufferUsage: integer): WebGLBuffer; /** - * [description] - * @param texture [description] + * Removes the given texture from the nativeTextures array and then deletes it from the GPU. + * @param texture The WebGL Texture to be deleted. */ - deleteTexture(texture: WebGLTexture): Phaser.Renderer.WebGL.WebGLRenderer; + deleteTexture(texture: WebGLTexture): this; /** - * Wrapper for deleting a raw WebGLFramebuffer - * @param framebuffer [description] + * Deletes a WebGLFramebuffer from the GL instance. + * @param framebuffer The Framebuffer to be deleted. */ - deleteFramebuffer(framebuffer: WebGLFramebuffer): Phaser.Renderer.WebGL.WebGLRenderer; + deleteFramebuffer(framebuffer: WebGLFramebuffer): this; /** - * [description] - * @param program [description] + * Deletes a WebGLProgram from the GL instance. + * @param program The shader program to be deleted. */ - deleteProgram(program: WebGLProgram): Phaser.Renderer.WebGL.WebGLRenderer; + deleteProgram(program: WebGLProgram): this; /** - * Wrapper for deleting a vertex or index buffer - * @param vertexBuffer [description] + * Deletes a WebGLBuffer from the GL instance. + * @param vertexBuffer The WebGLBuffer to be deleted. */ - deleteBuffer(vertexBuffer: WebGLBuffer): Phaser.Renderer.WebGL.WebGLRenderer; + deleteBuffer(vertexBuffer: WebGLBuffer): this; /** - * Handles any clipping needed by the camera and renders the background - * color if a color is visible. - * @param camera [description] + * Controls the pre-render operations for the given camera. + * Handles any clipping needed by the camera and renders the background color if a color is visible. + * @param camera The Camera to pre-render. */ preRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; /** - * Renders the foreground camera effects like flash and fading. - * It resets the current scissor state. - * @param camera [description] + * Controls the post-render operations for the given camera. + * Renders the foreground camera effects like flash and fading. It resets the current scissor state. + * @param camera The Camera to post-render. */ postRenderCamera(camera: Phaser.Cameras.Scene2D.Camera): void; @@ -47096,143 +63367,232 @@ declare namespace Phaser { preRender(): void; /** - * [description] - * @param scene [description] - * @param children [description] - * @param interpolationPercentage [description] - * @param camera [description] + * The core render step for a Scene Camera. + * + * Iterates through the given Game Object's array and renders them with the given Camera. + * + * This is called by the `CameraManager.render` method. The Camera Manager instance belongs to a Scene, and is invoked + * by the Scene Systems.render method. + * + * This method is not called if `Camera.visible` is `false`, or `Camera.alpha` is zero. + * @param scene The Scene to render. + * @param children The Game Object's within the Scene to be rendered. + * @param interpolationPercentage The interpolation percentage to apply. Currently un-used. + * @param camera The Scene Camera to render with. */ render(scene: Phaser.Scene, children: Phaser.GameObjects.GameObject, interpolationPercentage: number, camera: Phaser.Cameras.Scene2D.Camera): void; /** - * [description] + * The post-render step happens after all Cameras in all Scenes have been rendered. */ postRender(): void; /** - * [description] - * @param callback [description] - * @param type [description] - * @param encoderOptions [description] + * Schedules a snapshot of the entire game viewport to be taken after the current frame is rendered. + * + * To capture a specific area see the `snapshotArea` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. + * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, + * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, + * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. */ - snapshot(callback: SnapshotCallback, type: string, encoderOptions: number): Phaser.Renderer.WebGL.WebGLRenderer; + snapshot(callback: SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given area of the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific pixel, see `snapshotPixel`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotPixel`, for example, then + * calling this method will override it. + * + * Snapshots work by using the WebGL `readPixels` feature to grab every pixel from the frame buffer into an ArrayBufferView. + * It then parses this, copying the contents to a temporary Canvas and finally creating an Image object from it, + * which is the image returned to the callback provided. All in all, this is a computationally expensive and blocking process, + * which gets more expensive the larger the canvas size gets, so please be careful how you employ this in your game. + * @param x The x coordinate to grab from. + * @param y The y coordinate to grab from. + * @param width The width of the area to grab. + * @param height The height of the area to grab. + * @param callback The Function to invoke after the snapshot image is created. + * @param type The format of the image to create, usually `image/png` or `image/jpeg`. Default 'image/png'. + * @param encoderOptions The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. Default 0.92. + */ + snapshotArea(x: integer, y: integer, width: integer, height: integer, callback: SnapshotCallback, type?: string, encoderOptions?: number): this; + + /** + * Schedules a snapshot of the given pixel from the game viewport to be taken after the current frame is rendered. + * + * To capture the whole game viewport see the `snapshot` method. To capture a specific area, see `snapshotArea`. + * + * Only one snapshot can be active _per frame_. If you have already called `snapshotArea`, for example, then + * calling this method will override it. + * + * Unlike the other two snapshot methods, this one will return a `Color` object containing the color data for + * the requested pixel. It doesn't need to create an internal Canvas or Image object, so is a lot faster to execute, + * using less memory. + * @param x The x coordinate of the pixel to get. + * @param y The y coordinate of the pixel to get. + * @param callback The Function to invoke after the snapshot pixel data is extracted. + */ + snapshotPixel(x: integer, y: integer, callback: SnapshotCallback): this; + + /** + * Creates a WebGL Texture based on the given canvas element. + * @param srcCanvas The Canvas element that will be used to populate the texture. + * @param dstTexture Is this going to replace an existing texture? If so, pass it here. + * @param noRepeat Should this canvas never be allowed to set REPEAT? (such as for Text objects) Default false. + */ + canvasToTexture(srcCanvas: HTMLCanvasElement, dstTexture?: WebGLTexture, noRepeat?: boolean): WebGLTexture; + + /** + * Sets the minification and magnification filter for a texture. + * @param texture The texture to set the filter for. + * @param filter The filter to set. 0 for linear filtering, 1 for nearest neighbor (blocky) filtering. + */ + setTextureFilter(texture: integer, filter: integer): this; /** * [description] - * @param srcCanvas [description] - * @param dstTexture [description] - */ - canvasToTexture(srcCanvas: HTMLCanvasElement, dstTexture?: WebGLTexture): WebGLTexture; - - /** - * [description] - * @param texture [description] - * @param filter [description] - */ - setTextureFilter(texture: integer, filter: integer): Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * [description] - * @param program [description] - * @param name [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param x [description] */ - setFloat1(program: WebGLProgram, name: string, x: number): Phaser.Renderer.WebGL.WebGLRenderer; + setFloat1(program: WebGLProgram, name: string, x: number): this; /** * [description] - * @param program [description] - * @param name [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param x [description] * @param y [description] */ - setFloat2(program: WebGLProgram, name: string, x: number, y: number): Phaser.Renderer.WebGL.WebGLRenderer; + setFloat2(program: WebGLProgram, name: string, x: number, y: number): this; /** * [description] - * @param program [description] - * @param name [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param x [description] * @param y [description] * @param z [description] */ - setFloat3(program: WebGLProgram, name: string, x: number, y: number, z: number): Phaser.Renderer.WebGL.WebGLRenderer; + setFloat3(program: WebGLProgram, name: string, x: number, y: number, z: number): this; /** * Sets uniform of a WebGLProgram - * @param program Target program - * @param name Name of the uniform + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param x X component * @param y Y component * @param z Z component * @param w W component */ - setFloat4(program: WebGLProgram, name: string, x: number, y: number, z: number, w: number): Phaser.Renderer.WebGL.WebGLRenderer; + setFloat4(program: WebGLProgram, name: string, x: number, y: number, z: number, w: number): this; /** - * [description] - * @param program [description] - * @param name [description] + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat1v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat2v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat3v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param arr The new value to be used for the uniform variable. + */ + setFloat4v(program: WebGLProgram, name: string, arr: Float32Array): this; + + /** + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param x [description] */ - setInt1(program: WebGLProgram, name: string, x: integer): Phaser.Renderer.WebGL.WebGLRenderer; + setInt1(program: WebGLProgram, name: string, x: integer): this; /** - * [description] - * @param program [description] - * @param name [description] - * @param x [description] - * @param y [description] + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component + * @param y The new Y component */ - setInt2(program: WebGLProgram, name: string, x: integer, y: integer): Phaser.Renderer.WebGL.WebGLRenderer; + setInt2(program: WebGLProgram, name: string, x: integer, y: integer): this; /** - * [description] - * @param program [description] - * @param name [description] - * @param x [description] - * @param y [description] - * @param z [description] + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param x The new X component + * @param y The new Y component + * @param z The new Z component */ - setInt3(program: WebGLProgram, name: string, x: integer, y: integer, z: integer): Phaser.Renderer.WebGL.WebGLRenderer; + setInt3(program: WebGLProgram, name: string, x: integer, y: integer, z: integer): this; /** - * Sets uniform of a WebGLProgram - * @param program Target Program - * @param name Name of the uniform + * Sets the value of a uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param x X component * @param y Y component * @param z Z component * @param w W component */ - setInt4(program: WebGLProgram, name: string, x: integer, y: integer, z: integer, w: integer): Phaser.Renderer.WebGL.WebGLRenderer; + setInt4(program: WebGLProgram, name: string, x: integer, y: integer, z: integer, w: integer): this; + + /** + * Sets the value of a 2x2 matrix uniform variable in the given WebGLProgram. + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. + * @param transpose The value indicating whether to transpose the matrix. Must be false. + * @param matrix The new matrix value. + */ + setMatrix2(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; /** * [description] - * @param program [description] - * @param name [description] + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param transpose [description] * @param matrix [description] */ - setMatrix2(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): Phaser.Renderer.WebGL.WebGLRenderer; - - /** - * [description] - * @param program [description] - * @param name [description] - * @param transpose [description] - * @param matrix [description] - */ - setMatrix3(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): Phaser.Renderer.WebGL.WebGLRenderer; + setMatrix3(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; /** * Sets uniform of a WebGLProgram - * @param program Target program - * @param name Name of the uniform + * @param program The target WebGLProgram from which the uniform location will be looked-up. + * @param name The name of the uniform to look-up and modify. * @param transpose Is the matrix transposed * @param matrix Matrix data */ - setMatrix4(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): Phaser.Renderer.WebGL.WebGLRenderer; + setMatrix4(program: WebGLProgram, name: string, transpose: boolean, matrix: Float32Array): this; /** * Returns the maximum number of texture units that can be used in a fragment shader. @@ -47247,7 +63607,7 @@ declare namespace Phaser { getMaxTextureSize(): integer; /** - * [description] + * Destroy this WebGLRenderer, cleaning up all related resources such as pipelines, native textures, etc. */ destroy(): void; @@ -47275,6 +63635,808 @@ declare namespace Phaser { NEAREST, } + namespace Scale { + /** + * Phaser Scale Manager constants for centering the game canvas. + */ + namespace Center { + /** + * The game canvas is not centered within the parent by Phaser. + * You can still center it yourself via CSS. + */ + var NO_CENTER: any; + + /** + * The game canvas is centered both horizontally and vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + var CENTER_BOTH: any; + + /** + * The game canvas is centered horizontally within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + var CENTER_HORIZONTALLY: any; + + /** + * The game canvas is centered both vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + var CENTER_VERTICALLY: any; + + } + + /** + * Phaser Scale Manager constants for centering the game canvas. + * + * To find out what each mode does please see [Phaser.Scale.Center]{@link Phaser.Scale.Center}. + */ + type CenterType = ()=>void; + + /** + * Phaser Scale Manager constants for orientation. + */ + namespace Orientation { + /** + * A landscape orientation. + */ + var LANDSCAPE: any; + + /** + * A portrait orientation. + */ + var PORTRAIT: any; + + } + + /** + * Phaser Scale Manager constants for orientation. + * + * To find out what each mode does please see [Phaser.Scale.Orientation]{@link Phaser.Scale.Orientation}. + */ + type OrientationType = ()=>void; + + /** + * Phaser Scale Manager constants for the different scale modes available. + */ + namespace ScaleModes { + /** + * No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it + * again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need + * to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working. + */ + var NONE: any; + + /** + * The height is automatically adjusted based on the width. + */ + var WIDTH_CONTROLS_HEIGHT: any; + + /** + * The width is automatically adjusted based on the height. + */ + var HEIGHT_CONTROLS_WIDTH: any; + + /** + * The width and height are automatically adjusted to fit inside the given target area, + * while keeping the aspect ratio. Depending on the aspect ratio there may be some space + * inside the area which is not covered. + */ + var FIT: any; + + /** + * The width and height are automatically adjusted to make the size cover the entire target + * area while keeping the aspect ratio. This may extend further out than the target size. + */ + var ENVELOP: any; + + /** + * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. + */ + var RESIZE: any; + + } + + /** + * Phaser Scale Manager constants for the different scale modes available. + * + * To find out what each mode does please see [Phaser.Scale.ScaleModes]{@link Phaser.Scale.ScaleModes}. + */ + type ScaleModeType = ()=>void; + + /** + * Phaser Scale Manager constants for zoom modes. + */ + namespace Zoom { + /** + * The game canvas will not be zoomed by Phaser. + */ + var NO_ZOOM: any; + + /** + * The game canvas will be 2x zoomed by Phaser. + */ + var ZOOM_2X: any; + + /** + * The game canvas will be 4x zoomed by Phaser. + */ + var ZOOM_4X: any; + + /** + * Calculate the zoom value based on the maximum multiplied game size that will + * fit into the parent, or browser window if no parent is set. + */ + var MAX_ZOOM: any; + + } + + /** + * Phaser Scale Manager constants for zoom modes. + * + * To find out what each mode does please see [Phaser.Scale.Zoom]{@link Phaser.Scale.Zoom}. + */ + type ZoomType = ()=>void; + + namespace Events { + /** + * The Scale Manager Resize Event. + */ + const ENTER_FULLSCREEN: any; + + /** + * The Scale Manager Resize Event. + */ + const FULLSCREEN_UNSUPPORTED: any; + + /** + * The Scale Manager Resize Event. + */ + const LEAVE_FULLSCREEN: any; + + /** + * The Scale Manager Resize Event. + */ + const ORIENTATION_CHANGE: any; + + /** + * The Scale Manager Resize Event. + * + * This event is dispatched whenever the Scale Manager detects a resize event from the browser. + * It sends three parameters to the callback, each of them being Size components. You can read + * the `width`, `height`, `aspectRatio` and other properties of these components to help with + * scaling your own game content. + */ + const RESIZE: any; + + } + + /** + * The Scale Manager handles the scaling, resizing and alignment of the game canvas. + * + * The way scaling is handled is by setting the game canvas to a fixed size, which is defined in the + * game configuration. You also define the parent container in the game config. If no parent is given, + * it will default to using the document body. The Scale Manager will then look at the available space + * within the _parent_ and scale the canvas accordingly. Scaling is handled by setting the canvas CSS + * width and height properties, leaving the width and height of the canvas element itself untouched. + * Scaling is therefore achieved by keeping the core canvas the same size and 'stretching' + * it via its CSS properties. This gives the same result and speed as using the `transform-scale` CSS + * property, without the need for browser prefix handling. + * + * The calculations for the scale are heavily influenced by the bounding parent size, which is the computed + * dimensions of the canvas's parent. The CSS rules of the parent element play an important role in the + * operation of the Scale Manager. For example, if the parent has no defined width or height, then actions + * like auto-centering will fail to achieve the required result. The Scale Manager works in tandem with the + * CSS you set-up on the page hosting your game, rather than taking control of it. + * + * #### Parent and Display canvas containment guidelines: + * + * - Style the Parent element (of the game canvas) to control the Parent size and thus the games size and layout. + * + * - The Parent element's CSS styles should _effectively_ apply maximum (and minimum) bounding behavior. + * + * - The Parent element should _not_ apply a padding as this is not accounted for. + * If a padding is required apply it to the Parent's parent or apply a margin to the Parent. + * If you need to add a border, margin or any other CSS around your game container, then use a parent element and + * apply the CSS to this instead, otherwise you'll be constantly resizing the shape of the game container. + * + * - The Display canvas layout CSS styles (i.e. margins, size) should not be altered / specified as + * they may be updated by the Scale Manager. + * + * #### Scale Modes + * + * The way the scaling is handled is determined by the `scaleMode` property. The default is `NO_SCALE`, + * which prevents Phaser from scaling or touching the canvas, or its parent, at all. In this mode, you are + * responsible for all scaling. The other scaling modes afford you automatic scaling. + * + * If you wish to scale your game so that it always fits into the available space within the parent, you + * should use the scale mode `FIT`. Look at the documentation for other scale modes to see what options are + * available. Here is a basic config showing how to set this scale mode: + * + * ```javascript + * scale: { + * parent: 'yourgamediv', + * mode: Phaser.Scale.FIT, + * width: 800, + * height: 600 + * } + * ``` + * + * Place the `scale` config object within your game config. + * + * If you wish for the canvas to be resized directly, so that the canvas itself fills the available space + * (i.e. it isn't scaled, it's resized) then use the `RESIZE` scale mode. This will give you a 1:1 mapping + * of canvas pixels to game size. In this mode CSS isn't used to scale the canvas, it's literally adjusted + * to fill all available space within the parent. You should be extremely careful about the size of the + * canvas you're creating when doing this, as the larger the area, the more work the GPU has to do and it's + * very easy to hit fill-rate limits quickly. + * + * For complex, custom-scaling requirements, you should probably consider using the `RESIZE` scale mode, + * with your own limitations in place re: canvas dimensions and managing the scaling with the game scenes + * yourself. For the vast majority of games, however, the `FIT` mode is likely to be the most used. + * + * Please appreciate that the Scale Manager cannot perform miracles. All it does is scale your game canvas + * as best it can, based on what it can infer from its surrounding area. There are all kinds of environments + * where it's up to you to guide and help the canvas position itself, especially when built into rendering + * frameworks like React and Vue. If your page requires meta tags to prevent user scaling gestures, or such + * like, then it's up to you to ensure they are present in the html. + * + * #### Centering + * + * You can also have the game canvas automatically centered. Again, this relies heavily on the parent being + * properly configured and styled, as the centering offsets are based entirely on the available space + * within the parent element. Centering is disabled by default, or can be applied horizontally, vertically, + * or both. Here's an example: + * + * ```javascript + * scale: { + * parent: 'yourgamediv', + * autoCenter: Phaser.Scale.CENTER_BOTH, + * width: 800, + * height: 600 + * } + * ``` + * + * #### Fullscreen API + * + * If the browser supports it, you can send your game into fullscreen mode. In this mode, the game will fill + * the entire display, removing all browser UI and anything else present on the screen. It will remain in this + * mode until your game either disables it, or until the user tabs out or presses ESCape if on desktop. It's a + * great way to achieve a desktop-game like experience from the browser, but it does require a modern browser + * to handle it. Some mobile browsers also support this. + */ + class ScaleManager extends Phaser.Events.EventEmitter { + /** + * + * @param game A reference to the Phaser.Game instance. + */ + constructor(game: Phaser.Game); + + /** + * A reference to the Phaser.Game instance. + */ + readonly game: Phaser.Game; + + /** + * A reference to the HTML Canvas Element that Phaser uses to render the game. + */ + canvas: HTMLCanvasElement; + + /** + * The DOM bounds of the canvas element. + */ + canvasBounds: Phaser.Geom.Rectangle; + + /** + * The parent object of the Canvas. Often a div, or the browser window, or nothing in non-browser environments. + * + * This is set in the Game Config as the `parent` property. If undefined (or just not present), it will default + * to use the document body. If specifically set to `null` Phaser will ignore all parent operations. + */ + parent: any; + + /** + * Is the parent element the browser window? + */ + parentIsWindow: boolean; + + /** + * The Parent Size component. + */ + parentSize: Phaser.Structs.Size; + + /** + * The Game Size component. + * + * The un-modified game size, as requested in the game config (the raw width / height), + * as used for world bounds, cameras, etc + */ + gameSize: Phaser.Structs.Size; + + /** + * The Base Size component. + * + * The modified game size, which is the gameSize * resolution, used to set the canvas width and height + * (but not the CSS style) + */ + baseSize: Phaser.Structs.Size; + + /** + * The Display Size component. + * + * The size used for the canvas style, factoring in the scale mode, parent and other values. + */ + displaySize: Phaser.Structs.Size; + + /** + * The game scale mode. + */ + scaleMode: Phaser.Scale.ScaleModeType; + + /** + * The canvas resolution. + * + * This is hard-coded to a value of 1 in the 3.16 release of Phaser and will be enabled at a later date. + */ + resolution: number; + + /** + * The game zoom factor. + * + * This value allows you to multiply your games base size by the given zoom factor. + * This is then used when calculating the display size, even in `NO_SCALE` situations. + * If you don't want Phaser to touch the canvas style at all, this value should be 1. + * + * Can also be set to `MAX_ZOOM` in which case the zoom value will be derived based + * on the game size and available space within the parent. + */ + zoom: number; + + /** + * The scale factor between the baseSize and the canvasBounds. + */ + displayScale: Phaser.Math.Vector2; + + /** + * If set, the canvas sizes will be automatically passed through Math.floor. + * This results in rounded pixel display values, which is important for performance on legacy + * and low powered devices, but at the cost of not achieving a 'perfect' fit in some browser windows. + */ + autoRound: boolean; + + /** + * Automatically center the canvas within the parent? The different centering modes are: + * + * 1. No centering. + * 2. Center both horizontally and vertically. + * 3. Center horizontally. + * 4. Center vertically. + * + * Please be aware that in order to center the game canvas, you must have specified a parent + * that has a size set, or the canvas parent is the document.body. + */ + autoCenter: Phaser.Scale.CenterType; + + /** + * The current device orientation. + * + * Orientation events are dispatched via the Device Orientation API, typically only on mobile browsers. + */ + orientation: Phaser.Scale.OrientationType; + + /** + * A reference to the Device.Fullscreen object. + */ + fullscreen: Phaser.Device.Fullscreen; + + /** + * The DOM Element which is sent into fullscreen mode. + */ + fullscreenTarget: any; + + /** + * The dirty state of the Scale Manager. + * Set if there is a change between the parent size and the current size. + */ + dirty: boolean; + + /** + * How many milliseconds should elapse before checking if the browser size has changed? + * + * Most modern browsers dispatch a 'resize' event, which the Scale Manager will listen for. + * However, older browsers fail to do this, or do it consistently, so we fall back to a + * more traditional 'size check' based on a time interval. You can control how often it is + * checked here. + */ + resizeInterval: integer; + + /** + * Called _before_ the canvas object is created and added to the DOM. + */ + protected preBoot(): void; + + /** + * The Boot handler is called by Phaser.Game when it first starts up. + * The renderer is available by now and the canvas has been added to the DOM. + */ + protected boot(): void; + + /** + * Parses the game configuration to set-up the scale defaults. + * @param config The Game configuration object. + */ + protected parseConfig(config: GameConfig): void; + + /** + * Determines the parent element of the game canvas, if any, based on the game configuration. + * @param config The Game configuration object. + */ + getParent(config: GameConfig): void; + + /** + * Calculates the size of the parent bounds and updates the `parentSize` component, if the canvas has a dom parent. + */ + getParentBounds(): boolean; + + /** + * Attempts to lock the orientation of the web browser using the Screen Orientation API. + * + * This API is only available on modern mobile browsers. + * See https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation for details. + * @param orientation The orientation you'd like to lock the browser in. Should be an API string such as 'landscape', 'landscape-primary', 'portrait', etc. + */ + lockOrientation(orientation: string): boolean; + + /** + * This method will set the size of the Parent Size component, which is used in scaling + * and centering calculations. You only need to call this method if you have explicitly + * disabled the use of a parent in your game config, but still wish to take advantage of + * other Scale Manager features. + * @param width The new width of the parent. + * @param height The new height of the parent. + */ + setParentSize(width: number, height: number): this; + + /** + * This method will set a new size for your game. + * @param width The new width of the game. + * @param height The new height of the game. + */ + setGameSize(width: number, height: number): this; + + /** + * Call this to modify the size of the Phaser canvas element directly. + * You should only use this if you are using the `NO_SCALE` scale mode, + * it will update all internal components completely. + * + * If all you want to do is change the size of the parent, see the `setParentSize` method. + * + * If all you want is to change the base size of the game, but still have the Scale Manager + * manage all the scaling, then see the `setGameSize` method. + * + * This method will set the `gameSize`, `baseSize` and `displaySize` components to the given + * dimensions. It will then resize the canvas width and height to the values given, by + * directly setting the properties. Finally, if you have set the Scale Manager zoom value + * to anything other than 1 (the default), it will set the canvas CSS width and height to + * be the given size multiplied by the zoom factor (the canvas pixel size remains untouched). + * + * If you have enabled `autoCenter`, it is then passed to the `updateCenter` method and + * the margins are set, allowing the canvas to be centered based on its parent element + * alone. Finally, the `displayScale` is adjusted and the RESIZE event dispatched. + * @param width The new width of the game. + * @param height The new height of the game. + */ + resize(width: number, height: number): this; + + /** + * Sets the zoom value of the Scale Manager. + * @param value The new zoom value of the game. + */ + setZoom(value: integer): this; + + /** + * Sets the zoom to be the maximum possible based on the _current_ parent size. + */ + setMaxZoom(): this; + + /** + * Refreshes the internal scale values, bounds sizes and orientation checks. + * + * Once finished, dispatches the resize event. + * + * This is called automatically by the Scale Manager when the browser window size changes, + * as long as it is using a Scale Mode other than 'NONE'. + */ + refresh(): this; + + /** + * Internal method that checks the current screen orientation, only if the internal check flag is set. + * + * If the orientation has changed it updates the orientation property and then dispatches the orientation change event. + */ + updateOrientation(): void; + + /** + * Internal method that manages updating the size components based on the scale mode. + */ + updateScale(): void; + + /** + * Calculates and returns the largest possible zoom factor, based on the current + * parent and game sizes. If the parent has no dimensions (i.e. an unstyled div), + * or is smaller than the un-zoomed game, then this will return a value of 1 (no zoom) + */ + getMaxZoom(): integer; + + /** + * Calculates and updates the canvas CSS style in order to center it within the + * bounds of its parent. If you have explicitly set parent to be `null` in your + * game config then this method will likely give incorrect results unless you have called the + * `setParentSize` method first. + * + * It works by modifying the canvas CSS `marginLeft` and `marginTop` properties. + * + * If they have already been set by your own style sheet, or code, this will overwrite them. + * + * To prevent the Scale Manager from centering the canvas, either do not set the + * `autoCenter` property in your game config, or make sure it is set to `NO_CENTER`. + */ + updateCenter(): void; + + /** + * Updates the `canvasBounds` rectangle to match the bounding client rectangle of the + * canvas element being used to track input events. + */ + updateBounds(): void; + + /** + * Transforms the pageX value into the scaled coordinate space of the Scale Manager. + * @param pageX The DOM pageX value. + */ + transformX(pageX: number): number; + + /** + * Transforms the pageY value into the scaled coordinate space of the Scale Manager. + * @param pageY The DOM pageY value. + */ + transformY(pageY: number): number; + + /** + * Sends a request to the browser to ask it to go in to full screen mode, using the {@link https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API Fullscreen API}. + * + * If the browser does not support this, a `FULLSCREEN_UNSUPPORTED` event will be emitted. + * + * This method _must_ be called from a user-input gesture, such as `pointerdown`. You cannot launch + * games fullscreen without this, as most browsers block it. Games within an iframe will also be blocked + * from fullscreen unless the iframe has the `allowfullscreen` attribute. + * + * Performing an action that navigates to another page, or opens another tab, will automatically cancel + * fullscreen mode, as will the user pressing the ESC key. To cancel fullscreen mode from your game, i.e. + * from clicking an icon, call the `stopFullscreen` method. + * + * A browser can only send one DOM element into fullscreen. You can control which element this is by + * setting the `fullscreenTarget` property in your game config, or changing the property in the Scale Manager. + * Note that the game canvas _must_ be a child of the target. If you do not give a target, Phaser will + * automatically create a blank `
` element and move the canvas into it, before going fullscreen. + * When it leaves fullscreen, the div will be removed. + * @param fullscreenOptions The FullscreenOptions dictionary is used to provide configuration options when entering full screen. + */ + startFullscreen(fullscreenOptions?: object): void; + + /** + * An internal method that gets the target element that is used when entering fullscreen mode. + */ + getFullscreenTarget(): object; + + /** + * Calling this method will cancel fullscreen mode, if the browser has entered it. + */ + stopFullscreen(): void; + + /** + * Toggles the fullscreen mode. If already in fullscreen, calling this will cancel it. + * If not in fullscreen, this will request the browser to enter fullscreen mode. + * + * If the browser does not support this, a `FULLSCREEN_UNSUPPORTED` event will be emitted. + * + * This method _must_ be called from a user-input gesture, such as `pointerdown`. You cannot launch + * games fullscreen without this, as most browsers block it. Games within an iframe will also be blocked + * from fullscreen unless the iframe has the `allowfullscreen` attribute. + * @param fullscreenOptions The FullscreenOptions dictionary is used to provide configuration options when entering full screen. + */ + toggleFullscreen(fullscreenOptions?: object): void; + + /** + * An internal method that starts the different DOM event listeners running. + */ + startListeners(): void; + + /** + * Triggered when a fullscreenchange event is dispatched by the DOM. + */ + onFullScreenChange(): void; + + /** + * Triggered when a fullscreenerror event is dispatched by the DOM. + */ + onFullScreenError(): void; + + /** + * Internal method, called automatically by the game step. + * Monitors the elapsed time and resize interval to see if a parent bounds check needs to take place. + * @param time The time value from the most recent Game step. Typically a high-resolution timer value, or Date.now(). + * @param delta The delta value since the last frame. This is smoothed to avoid delta spikes by the TimeStep class. + */ + step(time: number, delta: number): void; + + /** + * Stops all DOM event listeners. + */ + stopListeners(): void; + + /** + * Destroys this Scale Manager, releasing all references to external resources. + * Once destroyed, the Scale Manager cannot be used again. + */ + destroy(): void; + + /** + * Is the browser currently in fullscreen mode or not? + */ + readonly isFullscreen: boolean; + + /** + * The game width. + * + * This is typically the size given in the game configuration. + */ + readonly width: number; + + /** + * The game height. + * + * This is typically the size given in the game configuration. + */ + readonly height: number; + + /** + * Is the device in a portrait orientation as reported by the Orientation API? + * This value is usually only available on mobile devices. + */ + readonly isPortrait: boolean; + + /** + * Is the device in a landscape orientation as reported by the Orientation API? + * This value is usually only available on mobile devices. + */ + readonly isLandscape: boolean; + + /** + * Are the game dimensions portrait? (i.e. taller than they are wide) + * + * This is different to the device itself being in a portrait orientation. + */ + readonly isGamePortrait: boolean; + + /** + * Are the game dimensions landscape? (i.e. wider than they are tall) + * + * This is different to the device itself being in a landscape orientation. + */ + readonly isGameLandscape: boolean; + + } + + /** + * The game canvas is not centered within the parent by Phaser. + * You can still center it yourself via CSS. + */ + var NO_CENTER: any; + + /** + * The game canvas is centered both horizontally and vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + var CENTER_BOTH: any; + + /** + * The game canvas is centered horizontally within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + var CENTER_HORIZONTALLY: any; + + /** + * The game canvas is centered both vertically within the parent. + * To do this, the parent has to have a bounds that can be calculated and not be empty. + * + * Centering is achieved by setting the margin left and top properties of the + * game canvas, and does not factor in any other CSS styles you may have applied. + */ + var CENTER_VERTICALLY: any; + + /** + * A landscape orientation. + */ + var LANDSCAPE: any; + + /** + * A portrait orientation. + */ + var PORTRAIT: any; + + /** + * No scaling happens at all. The canvas is set to the size given in the game config and Phaser doesn't change it + * again from that point on. If you change the canvas size, either via CSS, or directly via code, then you need + * to call the Scale Managers `resize` method to give the new dimensions, or input events will stop working. + */ + var NONE: any; + + /** + * The height is automatically adjusted based on the width. + */ + var WIDTH_CONTROLS_HEIGHT: any; + + /** + * The width is automatically adjusted based on the height. + */ + var HEIGHT_CONTROLS_WIDTH: any; + + /** + * The width and height are automatically adjusted to fit inside the given target area, + * while keeping the aspect ratio. Depending on the aspect ratio there may be some space + * inside the area which is not covered. + */ + var FIT: any; + + /** + * The width and height are automatically adjusted to make the size cover the entire target + * area while keeping the aspect ratio. This may extend further out than the target size. + */ + var ENVELOP: any; + + /** + * The Canvas is resized to fit all available _parent_ space, regardless of aspect ratio. + */ + var RESIZE: any; + + /** + * The game canvas will not be zoomed by Phaser. + */ + var NO_ZOOM: any; + + /** + * The game canvas will be 2x zoomed by Phaser. + */ + var ZOOM_2X: any; + + /** + * The game canvas will be 4x zoomed by Phaser. + */ + var ZOOM_4X: any; + + /** + * Calculate the zoom value based on the maximum multiplied game size that will + * fit into the parent, or browser window if no parent is set. + */ + var MAX_ZOOM: any; + + } + namespace Scenes { /** * Scene state. @@ -47326,6 +64488,277 @@ declare namespace Phaser { */ var DESTROYED: integer; + namespace Events { + /** + * The Scene Systems Boot Event. + * + * This event is dispatched by a Scene during the Scene Systems boot process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.scene.events.on('boot', listener)`. + */ + const BOOT: any; + + /** + * The Scene Systems Destroy Event. + * + * This event is dispatched by a Scene during the Scene Systems destroy process. + * + * Listen to it from a Scene using `this.scene.events.on('destroy', listener)`. + * + * You should destroy any resources that may be in use by your Scene in this event handler. + */ + const DESTROY: any; + + /** + * The Scene Systems Pause Event. + * + * This event is dispatched by a Scene when it is paused, either directly via the `pause` method, or as an + * action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('pause', listener)`. + */ + const PAUSE: any; + + /** + * The Scene Systems Post Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('postupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const POST_UPDATE: any; + + /** + * The Scene Systems Pre Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('preupdate', listener)`. + * + * A Scene will only run its step if it is active. + */ + const PRE_UPDATE: any; + + /** + * The Scene Systems Ready Event. + * + * This event is dispatched by a Scene during the Scene Systems start process. + * By this point in the process the Scene is now fully active and rendering. + * This event is meant for your game code to use, as all plugins have responded to the earlier 'start' event. + * + * Listen to it from a Scene using `this.scene.events.on('ready', listener)`. + */ + const READY: any; + + /** + * The Scene Systems Render Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('render', listener)`. + * + * A Scene will only render if it is visible and active. + * By the time this event is dispatched, the Scene will have already been rendered. + */ + const RENDER: any; + + /** + * The Scene Systems Resume Event. + * + * This event is dispatched by a Scene when it is resumed from a paused state, either directly via the `resume` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('resume', listener)`. + */ + const RESUME: any; + + /** + * The Scene Systems Shutdown Event. + * + * This event is dispatched by a Scene during the Scene Systems shutdown process. + * + * Listen to it from a Scene using `this.scene.events.on('shutdown', listener)`. + * + * You should free-up any resources that may be in use by your Scene in this event handler, on the understanding + * that the Scene may, at any time, become active again. A shutdown Scene is not 'destroyed', it's simply not + * currently active. Use the [DESTROY]{@linkcode Phaser.Scenes.Events#event:DESTROY} event to completely clear resources. + */ + const SHUTDOWN: any; + + /** + * The Scene Systems Sleep Event. + * + * This event is dispatched by a Scene when it is sent to sleep, either directly via the `sleep` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('sleep', listener)`. + */ + const SLEEP: any; + + /** + * The Scene Systems Start Event. + * + * This event is dispatched by a Scene during the Scene Systems start process. Primarily used by Scene Plugins. + * + * Listen to it from a Scene using `this.scene.events.on('start', listener)`. + */ + const START: any; + + /** + * The Scene Transition Complete Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens when the transition process has completed. This occurs when the duration timer equals or exceeds the duration + * of the transition. + * + * Listen to it from a Scene using `this.scene.events.on('transitioncomplete', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_COMPLETE: any; + + /** + * The Scene Transition Init Event. + * + * This event is dispatched by the Target Scene of a transition. + * + * It happens immediately after the `Scene.init` method is called. If the Scene does not have an `init` method, + * this event is not dispatched. + * + * Listen to it from a Scene using `this.scene.events.on('transitioninit', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_INIT: any; + + /** + * The Scene Transition Out Event. + * + * This event is dispatched by a Scene when it initiates a transition to another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('transitionout', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_OUT: any; + + /** + * The Scene Transition Start Event. + * + * This event is dispatched by the Target Scene of a transition, only if that Scene was not asleep. + * + * It happens immediately after the `Scene.create` method is called. If the Scene does not have a `create` method, + * this event is dispatched anyway. + * + * If the Target Scene was sleeping then the [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} event is + * dispatched instead of this event. + * + * Listen to it from a Scene using `this.scene.events.on('transitionstart', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_START: any; + + /** + * The Scene Transition Wake Event. + * + * This event is dispatched by the Target Scene of a transition, only if that Scene was asleep before + * the transition began. If the Scene was not asleep the [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} event is dispatched instead. + * + * Listen to it from a Scene using `this.scene.events.on('transitionwake', listener)`. + * + * The Scene Transition event flow is as follows: + * + * 1. [TRANSITION_OUT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_OUT} - the Scene that started the transition will emit this event. + * 2. [TRANSITION_INIT]{@linkcode Phaser.Scenes.Events#event:TRANSITION_INIT} - the Target Scene will emit this event if it has an `init` method. + * 3. [TRANSITION_START]{@linkcode Phaser.Scenes.Events#event:TRANSITION_START} - the Target Scene will emit this event after its `create` method is called, OR ... + * 4. [TRANSITION_WAKE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_WAKE} - the Target Scene will emit this event if it was asleep and has been woken-up to be transitioned to. + * 5. [TRANSITION_COMPLETE]{@linkcode Phaser.Scenes.Events#event:TRANSITION_COMPLETE} - the Target Scene will emit this event when the transition finishes. + */ + const TRANSITION_WAKE: any; + + /** + * The Scene Systems Update Event. + * + * This event is dispatched by a Scene during the main game loop step. + * + * The event flow for a single step of a Scene is as follows: + * + * 1. [PRE_UPDATE]{@linkcode Phaser.Scenes.Events#event:PRE_UPDATE} + * 2. [UPDATE]{@linkcode Phaser.Scenes.Events#event:UPDATE} + * 3. The `Scene.update` method is called, if it exists + * 4. [POST_UPDATE]{@linkcode Phaser.Scenes.Events#event:POST_UPDATE} + * 5. [RENDER]{@linkcode Phaser.Scenes.Events#event:RENDER} + * + * Listen to it from a Scene using `this.scene.events.on('update', listener)`. + * + * A Scene will only run its step if it is active. + */ + const UPDATE: any; + + /** + * The Scene Systems Wake Event. + * + * This event is dispatched by a Scene when it is woken from sleep, either directly via the `wake` method, + * or as an action from another Scene. + * + * Listen to it from a Scene using `this.scene.events.on('wake', listener)`. + */ + const WAKE: any; + + } + /** * Builds an array of which physics plugins should be activated for the given Scene. * @param sys The scene system to get the physics systems of. @@ -47334,7 +64767,7 @@ declare namespace Phaser { /** * Builds an array of which plugins (not including physics plugins) should be activated for the given Scene. - * @param sys [description] + * @param sys The Scene Systems object to check for plugins. */ function GetScenePlugins(sys: Phaser.Scenes.Systems): any[]; @@ -47377,6 +64810,12 @@ declare namespace Phaser { */ readonly isBooted: boolean; + /** + * Do any of the Cameras in any of the Scenes require a custom viewport? + * If not we can skip scissor tests. + */ + customViewports: number; + /** * Process the Scene operations queue. */ @@ -47408,7 +64847,7 @@ declare namespace Phaser { * The Scene is removed from the local scenes array, it's key is cleared from the keys * cache and Scene.Systems.destroy is then called on it. * - * If the SceneManager is processing the Scenes when this method is called it wil + * If the SceneManager is processing the Scenes when this method is called it will * queue the operation for the next update sequence. * @param scene The Scene to be removed. */ @@ -47421,19 +64860,22 @@ declare namespace Phaser { */ update(time: number, delta: number): void; - /** - * Informs the Scenes of the Game being resized. - * @param width The new width of the game. - * @param height The new height of the game. - */ - resize(width: number, height: number): void; - /** * Renders the Scenes. * @param renderer The renderer to use. */ render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; + /** + * Returns an array of all the current Scenes being managed by this Scene Manager. + * + * You can filter the output by the active state of the Scene and choose to have + * the array returned in normal or reversed order. + * @param isActive Only include Scene's that are currently active? Default true. + * @param inReverse Return the array of Scenes in reverse? Default false. + */ + getScenes(isActive?: boolean, inReverse?: boolean): Phaser.Scene[]; + /** * Retrieves a Scene. * @param key The Scene to retrieve. @@ -47461,26 +64903,30 @@ declare namespace Phaser { /** * Pauses the given Scene. * @param key The Scene to pause. + * @param data An optional data object that will be passed to the Scene and emitted by its pause event. */ - pause(key: string): Phaser.Scenes.SceneManager; + pause(key: string, data?: object): Phaser.Scenes.SceneManager; /** * Resumes the given Scene. * @param key The Scene to resume. + * @param data An optional data object that will be passed to the Scene and emitted by its resume event. */ - resume(key: string): Phaser.Scenes.SceneManager; + resume(key: string, data?: object): Phaser.Scenes.SceneManager; /** * Puts the given Scene to sleep. * @param key The Scene to put to sleep. + * @param data An optional data object that will be passed to the Scene and emitted by its sleep event. */ - sleep(key: string): Phaser.Scenes.SceneManager; + sleep(key: string, data?: object): Phaser.Scenes.SceneManager; /** * Awakens the given Scene. * @param key The Scene to wake up. + * @param data An optional data object that will be passed to the Scene and emitted by its wake event. */ - wake(key: string): Phaser.Scenes.SceneManager; + wake(key: string, data?: object): Phaser.Scenes.SceneManager; /** * Runs the given Scene, but does not change the state of this Scene. @@ -47491,7 +64937,7 @@ declare namespace Phaser { * Use this if you wish to open a modal Scene by calling `pause` on the current * Scene, then `run` on the modal Scene. * @param key The Scene to run. - * @param data A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param data A data object that will be passed to the Scene on start, wake, or resume. */ run(key: string, data?: object): Phaser.Scenes.SceneManager; @@ -47638,7 +65084,7 @@ declare namespace Phaser { * @param key The Scene to start. * @param data The Scene data. */ - start(key: string, data?: object): Phaser.Scenes.ScenePlugin; + start(key?: string, data?: object): Phaser.Scenes.ScenePlugin; /** * Restarts this Scene. @@ -47658,16 +65104,16 @@ declare namespace Phaser { * * This Scene can either be sent to sleep at the end of the transition, or stopped. The default is to stop. * - * There are also 5 transition related events: This scene will emit the event `transitionto` when + * There are also 5 transition related events: This scene will emit the event `transitionout` when * the transition begins, which is typically the frame after calling this method. * * The target Scene will emit the event `transitioninit` when that Scene's `init` method is called. * It will then emit the event `transitionstart` when its `create` method is called. * If the Scene was sleeping and has been woken up, it will emit the event `transitionwake` instead of these two, - * as the Scenes `init` and `create` methods are not invoked when a sleep wakes up. + * as the Scenes `init` and `create` methods are not invoked when a Scene wakes up. * * When the duration of the transition has elapsed it will emit the event `transitioncomplete`. - * These events are all cleared of listeners when the Scene shuts down, but not if it is sent to sleep. + * These events are cleared of all listeners when the Scene shuts down, but not if it is sent to sleep. * * It's important to understand that the duration of the transition begins the moment you call this method. * If the Scene you are transitioning to includes delayed processes, such as waiting for files to load, the @@ -47677,15 +65123,16 @@ declare namespace Phaser { * override this understand that until the target Scene completes it might never be unlocked for input events. * @param config The transition configuration object. */ - transition(config: Phaser.Scenes.ScenePlugin.SceneTransitionConfig): boolean; + transition(config: SceneTransitionConfig): boolean; /** * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. * @param key The Scene key. * @param sceneConfig The config for the Scene. * @param autoStart Whether to start the Scene after it's added. + * @param data Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. */ - add(key: string, sceneConfig: Phaser.Scene | Phaser.Scenes.Settings.Config | Function, autoStart: boolean): Phaser.Scenes.ScenePlugin; + add(key: string, sceneConfig: Phaser.Scene | Phaser.Scenes.Settings.Config | Function, autoStart: boolean, data?: object): Phaser.Scenes.ScenePlugin; /** * Launch the given Scene and run it in parallel with this one. @@ -47703,33 +65150,37 @@ declare namespace Phaser { * Use this if you wish to open a modal Scene by calling `pause` on the current * Scene, then `run` on the modal Scene. * @param key The Scene to run. - * @param data A data object that will be passed to the Scene that is run _only if the Scene isn't asleep or paused_. + * @param data A data object that will be passed to the Scene and emitted in its ready, wake, or resume events. */ run(key: string, data?: object): Phaser.Scenes.ScenePlugin; /** * Pause the Scene - this stops the update step from happening but it still renders. * @param key The Scene to pause. + * @param data An optional data object that will be passed to the Scene and emitted in its pause event. */ - pause(key: string): Phaser.Scenes.ScenePlugin; + pause(key?: string, data?: object): Phaser.Scenes.ScenePlugin; /** * Resume the Scene - starts the update loop again. * @param key The Scene to resume. + * @param data An optional data object that will be passed to the Scene and emitted in its resume event. */ - resume(key: string): Phaser.Scenes.ScenePlugin; + resume(key?: string, data?: object): Phaser.Scenes.ScenePlugin; /** * Makes the Scene sleep (no update, no render) but doesn't shutdown. * @param key The Scene to put to sleep. + * @param data An optional data object that will be passed to the Scene and emitted in its sleep event. */ - sleep(key: string): Phaser.Scenes.ScenePlugin; + sleep(key?: string, data?: object): Phaser.Scenes.ScenePlugin; /** * Makes the Scene wake-up (starts update and render) * @param key The Scene to wake up. + * @param data An optional data object that will be passed to the Scene and emitted in its wake event. */ - wake(key: string): Phaser.Scenes.ScenePlugin; + wake(key?: string, data?: object): Phaser.Scenes.ScenePlugin; /** * Makes this Scene sleep then starts the Scene given. @@ -47741,14 +65192,15 @@ declare namespace Phaser { * Shutdown the Scene, clearing display list, timers, etc. * @param key The Scene to stop. */ - stop(key: string): Phaser.Scenes.ScenePlugin; + stop(key?: string): Phaser.Scenes.ScenePlugin; /** * Sets the active state of the given Scene. - * @param value The active value. - * @param key The Scene to set the active state for. + * @param value If `true` the Scene will be resumed. If `false` it will be paused. + * @param key The Scene to set the active state of. + * @param data An optional data object that will be passed to the Scene and emitted with its events. */ - setActive(value: boolean, key?: string): Phaser.Scenes.ScenePlugin; + setActive(value: boolean, key?: string, data?: object): Phaser.Scenes.ScenePlugin; /** * Sets the visible state of the given Scene. @@ -47761,19 +65213,19 @@ declare namespace Phaser { * Checks if the given Scene is sleeping or not? * @param key The Scene to check. */ - isSleeping(key: string): boolean; + isSleeping(key?: string): boolean; /** * Checks if the given Scene is active or not? * @param key The Scene to check. */ - isActive(key: string): boolean; + isActive(key?: string): boolean; /** * Checks if the given Scene is visible or not? * @param key The Scene to check. */ - isVisible(key: string): boolean; + isVisible(key?: string): boolean; /** * Swaps the position of two scenes in the Scenes list. @@ -47812,19 +65264,19 @@ declare namespace Phaser { * queue the operation for the next update sequence. * @param key The Scene to be removed. */ - remove(key: string | Phaser.Scene): Phaser.Scenes.SceneManager; + remove(key?: string | Phaser.Scene): Phaser.Scenes.SceneManager; /** * Moves a Scene up one position in the Scenes list. * @param key The Scene to move. */ - moveUp(key: string): Phaser.Scenes.ScenePlugin; + moveUp(key?: string): Phaser.Scenes.ScenePlugin; /** * Moves a Scene down one position in the Scenes list. * @param key The Scene to move. */ - moveDown(key: string): Phaser.Scenes.ScenePlugin; + moveDown(key?: string): Phaser.Scenes.ScenePlugin; /** * Brings a Scene to the top of the Scenes list. @@ -47832,7 +65284,7 @@ declare namespace Phaser { * This means it will render above all other Scenes. * @param key The Scene to move. */ - bringToTop(key: string): Phaser.Scenes.ScenePlugin; + bringToTop(key?: string): Phaser.Scenes.ScenePlugin; /** * Sends a Scene to the back of the Scenes list. @@ -47840,7 +65292,7 @@ declare namespace Phaser { * This means it will render below all other Scenes. * @param key The Scene to move. */ - sendToBack(key: string): Phaser.Scenes.ScenePlugin; + sendToBack(key?: string): Phaser.Scenes.ScenePlugin; /** * Retrieve a Scene. @@ -47859,23 +65311,23 @@ declare namespace Phaser { namespace Settings { type Config = { /** - * [description] + * The unique key of this Scene. Must be unique within the entire Game instance. */ key?: string; /** - * [description] + * Does the Scene start as active or not? An active Scene updates each step. */ active?: boolean; /** - * [description] + * Does the Scene start as visible or not? A visible Scene renders each step. */ visible?: boolean; /** - * [description] + * An optional Loader Packfile to be loaded before the Scene begins. */ pack?: false | Phaser.Loader.FileTypes.PackFileConfig; /** - * [description] + * An optional Camera configuration object. */ cameras?: InputJSONCameraObject | InputJSONCameraObject[]; /** @@ -47887,89 +65339,89 @@ declare namespace Phaser { */ mapAdd?: {[key: string]: string}; /** - * [description] + * The physics configuration object for the Scene. */ physics?: object; /** - * [description] + * The loader configuration object for the Scene. */ loader?: object; /** - * [description] + * The plugin configuration object for the Scene. */ plugins?: false | any; }; type Object = { /** - * [description] + * The current status of the Scene. Maps to the Scene constants. */ status: number; /** - * [description] + * The unique key of this Scene. Unique within the entire Game instance. */ key: string; /** - * [description] + * The active state of this Scene. An active Scene updates each step. */ active: boolean; /** - * [description] + * The visible state of this Scene. A visible Scene renders each step. */ visible: boolean; /** - * [description] + * Has the Scene finished booting? */ isBooted: boolean; /** - * [description] + * Is the Scene in a state of transition? */ isTransition: boolean; /** - * [description] + * The Scene this Scene is transitioning from, if set. */ transitionFrom: Phaser.Scene; /** - * [description] + * The duration of the transition, if set. */ transitionDuration: integer; /** - * [description] + * Is this Scene allowed to receive input during transitions? */ transitionAllowInput: boolean; /** - * [description] + * a data bundle passed to this Scene from the Scene Manager. */ data: object; /** - * [description] + * The Loader Packfile to be loaded before the Scene begins. */ pack: false | Phaser.Loader.FileTypes.PackFileConfig; /** - * [description] + * The Camera configuration object. */ cameras: InputJSONCameraObject | InputJSONCameraObject[]; /** - * [description] + * The Scene's Injection Map. */ map: {[key: string]: string}; /** - * [description] + * The physics configuration object for the Scene. */ physics: object; /** - * [description] + * The loader configuration object for the Scene. */ loader: object; /** - * [description] + * The plugin configuration object for the Scene. */ plugins: false | any; }; /** - * Takes a Scene configuration object and returns a fully formed Systems object. - * @param config [description] + * Takes a Scene configuration object and returns a fully formed System Settings object. + * @param config The Scene configuration object used to create this Scene Settings. */ function create(config: string | Phaser.Scenes.Settings.Config): Phaser.Scenes.Settings.Object; @@ -47991,22 +65443,27 @@ declare namespace Phaser { constructor(scene: Phaser.Scene, config: string | Phaser.Scenes.Settings.Config); /** - * [description] + * A reference to the Scene that these Systems belong to. */ scene: Phaser.Scene; /** - * [description] + * A reference to the Phaser Game instance. */ game: Phaser.Game; /** - * [description] + * The Facebook Instant Games Plugin. + */ + facebook: Phaser.FacebookInstantGamesPlugin; + + /** + * The Scene Configuration object, as passed in when creating the Scene. */ config: string | Phaser.Scenes.Settings.Config; /** - * [description] + * The Scene Settings. This is the parsed output based on the Scene configuration. */ settings: Phaser.Scenes.Settings.Object; @@ -48016,72 +65473,127 @@ declare namespace Phaser { canvas: HTMLCanvasElement; /** - * [description] + * A reference to the Canvas Rendering Context being used by the renderer. */ context: CanvasRenderingContext2D; /** - * [description] + * A reference to the global Animations Manager. + * + * In the default set-up you can access this from within a Scene via the `this.anims` property. */ anims: Phaser.Animations.AnimationManager; /** - * [description] + * A reference to the global Cache. The Cache stores all files bought in to Phaser via + * the Loader, with the exception of images. Images are stored in the Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.cache` property. */ cache: Phaser.Cache.CacheManager; /** - * [description] + * A reference to the global Plugins Manager. + * + * In the default set-up you can access this from within a Scene via the `this.plugins` property. */ plugins: Phaser.Plugins.PluginManager; /** - * [description] + * A reference to the global registry. This is a game-wide instance of the Data Manager, allowing + * you to exchange data between Scenes via a universal and shared point. + * + * In the default set-up you can access this from within a Scene via the `this.registry` property. */ registry: Phaser.Data.DataManager; /** - * [description] + * A reference to the global Scale Manager. + * + * In the default set-up you can access this from within a Scene via the `this.scale` property. + */ + scale: Phaser.Scale.ScaleManager; + + /** + * A reference to the global Sound Manager. + * + * In the default set-up you can access this from within a Scene via the `this.sound` property. */ sound: Phaser.Sound.BaseSoundManager; /** - * [description] + * A reference to the global Texture Manager. + * + * In the default set-up you can access this from within a Scene via the `this.textures` property. */ textures: Phaser.Textures.TextureManager; /** - * [description] + * A reference to the Scene's Game Object Factory. + * + * Use this to quickly and easily create new Game Object's. + * + * In the default set-up you can access this from within a Scene via the `this.add` property. */ add: Phaser.GameObjects.GameObjectFactory; /** - * [description] + * A reference to the Scene's Camera Manager. + * + * Use this to manipulate and create Cameras for this specific Scene. + * + * In the default set-up you can access this from within a Scene via the `this.cameras` property. */ cameras: Phaser.Cameras.Scene2D.CameraManager; /** - * [description] + * A reference to the Scene's Display List. + * + * Use this to organize the children contained in the display list. + * + * In the default set-up you can access this from within a Scene via the `this.children` property. */ displayList: Phaser.GameObjects.DisplayList; /** - * [description] + * A reference to the Scene's Event Manager. + * + * Use this to listen for Scene specific events, such as `pause` and `shutdown`. + * + * In the default set-up you can access this from within a Scene via the `this.events` property. */ events: Phaser.Events.EventEmitter; /** - * [description] + * A reference to the Scene's Game Object Creator. + * + * Use this to quickly and easily create new Game Object's. The difference between this and the + * Game Object Factory, is that the Creator just creates and returns Game Object instances, it + * doesn't then add them to the Display List or Update List. + * + * In the default set-up you can access this from within a Scene via the `this.make` property. */ make: Phaser.GameObjects.GameObjectCreator; /** - * [description] + * A reference to the Scene Manager Plugin. + * + * Use this to manipulate both this and other Scene's in your game, for example to launch a parallel Scene, + * or pause or resume a Scene, or switch from this Scene to another. + * + * In the default set-up you can access this from within a Scene via the `this.scene` property. */ scenePlugin: Phaser.Scenes.ScenePlugin; /** - * [description] + * A reference to the Scene's Update List. + * + * Use this to organize the children contained in the update list. + * + * The Update List is responsible for managing children that need their `preUpdate` methods called, + * in order to process so internal components, such as Sprites with Animations. + * + * In the default set-up there is no reference to this from within the Scene itself. */ updateList: Phaser.GameObjects.UpdateList; @@ -48102,9 +65614,9 @@ declare namespace Phaser { step(time: number, delta: number): void; /** - * Called automatically by the Scene Manager. Instructs the Scene to render itself via - * its Camera Manager to the renderer given. - * @param renderer [description] + * Called automatically by the Scene Manager. + * Instructs the Scene to render itself via its Camera Manager to the renderer given. + * @param renderer The renderer that invoked the render call. */ render(renderer: Phaser.Renderer.Canvas.CanvasRenderer | Phaser.Renderer.WebGL.WebGLRenderer): void; @@ -48121,13 +65633,15 @@ declare namespace Phaser { /** * Pause this Scene. * A paused Scene still renders, it just doesn't run ANY of its update handlers or systems. + * @param data A data object that will be passed in the 'pause' event. */ - pause(): Phaser.Scenes.Systems; + pause(data?: object): Phaser.Scenes.Systems; /** * Resume this Scene from a paused state. + * @param data A data object that will be passed in the 'resume' event. */ - resume(): Phaser.Scenes.Systems; + resume(data?: object): Phaser.Scenes.Systems; /** * Send this Scene to sleep. @@ -48136,13 +65650,15 @@ declare namespace Phaser { * or have any of its systems or children removed, meaning it can be re-activated at any point and * will carry on from where it left off. It also keeps everything in memory and events and callbacks * from other Scenes may still invoke changes within it, so be careful what is left active. + * @param data A data object that will be passed in the 'sleep' event. */ - sleep(): Phaser.Scenes.Systems; + sleep(data?: object): Phaser.Scenes.Systems; /** * Wake-up this Scene if it was previously asleep. + * @param data A data object that will be passed in the 'wake' event. */ - wake(): Phaser.Scenes.Systems; + wake(data?: object): Phaser.Scenes.Systems; /** * Is this Scene sleeping? @@ -48154,6 +65670,11 @@ declare namespace Phaser { */ isActive(): boolean; + /** + * Is this Scene paused? + */ + isPaused(): boolean; + /** * Is this Scene currently transitioning out to, or in from another Scene? */ @@ -48177,16 +65698,18 @@ declare namespace Phaser { /** * Sets the visible state of this Scene. * An invisible Scene will not render, but will still process updates. - * @param value [description] + * @param value `true` to render this Scene, otherwise `false`. */ setVisible(value: boolean): Phaser.Scenes.Systems; /** * Set the active state of this Scene. + * * An active Scene will run its core update loop. * @param value If `true` the Scene will be resumed, if previously paused. If `false` it will be paused. + * @param data A data object that will be passed in the 'resume' or 'pause' events. */ - setActive(value: boolean): Phaser.Scenes.Systems; + setActive(value: boolean, data?: object): Phaser.Scenes.Systems; /** * Start this Scene running and rendering. @@ -48195,29 +65718,22 @@ declare namespace Phaser { */ start(data: object): void; - /** - * Called automatically by the SceneManager if the Game resizes. - * Dispatches an event you can respond to in your game code. - * @param width The new width of the game. - * @param height The new height of the game. - */ - resize(width: number, height: number): void; - /** * Shutdown this Scene and send a shutdown event to all of its systems. * A Scene that has been shutdown will not run its update loop or render, but it does * not destroy any of its plugins or references. It is put into hibernation for later use. * If you don't ever plan to use this Scene again, then it should be destroyed instead * to free-up resources. + * @param data A data object that will be passed in the 'shutdown' event. */ - shutdown(): void; + shutdown(data?: object): void; } } /** - * [description] + * A base Phaser.Scene class which you could extend for your own use. */ class Scene { /** @@ -48279,12 +65795,6 @@ declare namespace Phaser { */ cameras: Phaser.Cameras.Scene2D.CameraManager; - /** - * A scene level 3D Camera System. - * This property will only be available if defined in the Scene Injection Map. - */ - cameras3d: Phaser.Cameras.Sprite3D.CameraManager; - /** * A scene level Game Object Factory. * This property will only be available if defined in the Scene Injection Map. @@ -48363,10 +65873,22 @@ declare namespace Phaser { */ matter: Phaser.Physics.Matter.MatterPhysics; + /** + * A scene level Facebook Instant Games Plugin. + * This property will only be available if defined in the Scene Injection Map, the plugin is installed and configured. + */ + facebook: Phaser.FacebookInstantGamesPlugin; + + /** + * A reference to the global Scale Manager. + * This property will only be available if defined in the Scene Injection Map. + */ + scale: Phaser.Scale.ScaleManager; + /** * Should be overridden by your own Scenes. - * @param time [description] - * @param delta [description] + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(time: number, delta: number): void; @@ -48563,7 +66085,7 @@ declare namespace Phaser { * @param key Asset key for the sound. * @param config An optional config object containing default sound settings. */ - addAudioSprite(key: string, config?: SoundConfig): Phaser.Sound.BaseSound.AudioSpriteSound; + addAudioSprite(key: string, config?: SoundConfig): AudioSpriteSound; /** * Enables playing sound on the fly without the need to keep a reference to it. @@ -48675,6 +66197,305 @@ declare namespace Phaser { } + namespace Events { + /** + * The Sound Complete Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they complete playback. + * + * Listen to it from a Sound instance using `Sound.on('complete', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('complete', listener); + * music.play(); + * ``` + */ + const COMPLETE: any; + + /** + * The Sound Destroy Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are destroyed, either + * directly or via a Sound Manager. + * + * Listen to it from a Sound instance using `Sound.on('destroy', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('destroy', listener); + * music.destroy(); + * ``` + */ + const DESTROY: any; + + /** + * The Sound Detune Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their detune value changes. + * + * Listen to it from a Sound instance using `Sound.on('detune', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('detune', listener); + * music.play(); + * music.setDetune(200); + * ``` + */ + const DETUNE: any; + + /** + * The Sound Manager Global Detune Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `detune` property of the Sound Manager is changed, which globally + * adjusts the detuning of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('rate', listener)`. + */ + const GLOBAL_DETUNE: any; + + /** + * The Sound Manager Global Mute Event. + * + * This event is dispatched by the Sound Manager when its `mute` property is changed, either directly + * or via the `setMute` method. This changes the mute state of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('mute', listener)`. + */ + const GLOBAL_MUTE: any; + + /** + * The Sound Manager Global Rate Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `rate` property of the Sound Manager is changed, which globally + * adjusts the playback rate of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('rate', listener)`. + */ + const GLOBAL_RATE: any; + + /** + * The Sound Manager Global Volume Event. + * + * This event is dispatched by the Sound Manager when its `volume` property is changed, either directly + * or via the `setVolume` method. This changes the volume of all active sounds. + * + * Listen to it from a Scene using: `this.sound.on('volume', listener)`. + */ + const GLOBAL_VOLUME: any; + + /** + * The Sound Looped Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they loop during playback. + * + * Listen to it from a Sound instance using `Sound.on('looped', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('looped', listener); + * music.setLoop(true); + * music.play(); + * ``` + * + * This is not to be confused with the [LOOP]{@linkcode Phaser.Sound.Events#event:LOOP} event, which only emits when the loop state of a Sound is changed. + */ + const LOOPED: any; + + /** + * The Sound Loop Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their loop state is changed. + * + * Listen to it from a Sound instance using `Sound.on('loop', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('loop', listener); + * music.setLoop(true); + * ``` + * + * This is not to be confused with the [LOOPED]{@linkcode Phaser.Sound.Events#event:LOOPED} event, which emits each time a Sound loops during playback. + */ + const LOOP: any; + + /** + * The Sound Mute Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their mute state changes. + * + * Listen to it from a Sound instance using `Sound.on('mute', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('mute', listener); + * music.play(); + * music.setMute(true); + * ``` + */ + const MUTE: any; + + /** + * The Pause All Sounds Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `pauseAll` method is invoked and after all current Sounds + * have been paused. + * + * Listen to it from a Scene using: `this.sound.on('pauseall', listener)`. + */ + const PAUSE_ALL: any; + + /** + * The Sound Pause Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are paused. + * + * Listen to it from a Sound instance using `Sound.on('pause', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('pause', listener); + * music.play(); + * music.pause(); + * ``` + */ + const PAUSE: any; + + /** + * The Sound Play Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are played. + * + * Listen to it from a Sound instance using `Sound.on('play', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('play', listener); + * music.play(); + * ``` + */ + const PLAY: any; + + /** + * The Sound Rate Change Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their rate changes. + * + * Listen to it from a Sound instance using `Sound.on('rate', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('rate', listener); + * music.play(); + * music.setRate(0.5); + * ``` + */ + const RATE: any; + + /** + * The Resume All Sounds Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `resumeAll` method is invoked and after all current Sounds + * have been resumed. + * + * Listen to it from a Scene using: `this.sound.on('resumeall', listener)`. + */ + const RESUME_ALL: any; + + /** + * The Sound Resume Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are resumed from a paused state. + * + * Listen to it from a Sound instance using `Sound.on('resume', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('resume', listener); + * music.play(); + * music.pause(); + * music.resume(); + * ``` + */ + const RESUME: any; + + /** + * The Sound Seek Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are seeked to a new position. + * + * Listen to it from a Sound instance using `Sound.on('seek', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('seek', listener); + * music.play(); + * music.setSeek(5000); + * ``` + */ + const SEEK: any; + + /** + * The Stop All Sounds Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched when the `stopAll` method is invoked and after all current Sounds + * have been stopped. + * + * Listen to it from a Scene using: `this.sound.on('stopall', listener)`. + */ + const STOP_ALL: any; + + /** + * The Sound Stop Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when they are stopped. + * + * Listen to it from a Sound instance using `Sound.on('stop', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('stop', listener); + * music.play(); + * music.stop(); + * ``` + */ + const STOP: any; + + /** + * The Sound Manager Unlocked Event. + * + * This event is dispatched by the Base Sound Manager, or more typically, an instance of the Web Audio Sound Manager, + * or the HTML5 Audio Manager. It is dispatched during the update loop when the Sound Manager becomes unlocked. For + * Web Audio this is on the first user gesture on the page. + * + * Listen to it from a Scene using: `this.sound.on('unlocked', listener)`. + */ + const UNLOCKED: any; + + /** + * The Sound Volume Event. + * + * This event is dispatched by both Web Audio and HTML5 Audio Sound objects when their volume changes. + * + * Listen to it from a Sound instance using `Sound.on('volume', listener)`, i.e.: + * + * ```javascript + * var music = this.sound.add('key'); + * music.on('volume', listener); + * music.play(); + * music.setVolume(0.5); + * ``` + */ + const VOLUME: any; + + } + /** * HTML5 Audio implementation of the sound. */ @@ -49152,12 +66973,12 @@ declare namespace Phaser { namespace Structs { /** - * [description] + * List is a generic implementation of an ordered list which contains utility methods for retrieving, manipulating, and iterating items. */ class List { /** * - * @param parent [description] + * @param parent The parent of this list. */ constructor(parent: any); @@ -49172,7 +66993,9 @@ declare namespace Phaser { list: T[]; /** - * [description] + * The index of the current element. + * + * This is used internally when iterating through the list with the {@link #first}, {@link #last}, {@link #get}, and {@link #previous} properties. */ position: integer; @@ -49192,39 +67015,39 @@ declare namespace Phaser { _sortKey: string; /** - * [description] - * @param child [description] + * Adds the given item to the end of the list. Each item must be unique. + * @param child The item, or array of items, to add to the list. * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. */ add(child: T, skipCallback?: boolean): T; /** - * [description] - * @param child [description] - * @param index [description] Default 0. + * Adds an item to list, starting at a specified index. Each item must be unique within the list. + * @param child The item, or array of items, to add to the list. + * @param index The index in the list at which the element(s) will be inserted. Default 0. * @param skipCallback Skip calling the List.addCallback if this child is added successfully. Default false. */ addAt(child: T, index?: integer, skipCallback?: boolean): T; /** - * [description] - * @param index [description] + * Retrieves the item at a given position inside the List. + * @param index The index of the item. */ getAt(index: integer): T; /** - * [description] - * @param child [description] + * Locates an item within the List and returns its index. + * @param child The item to locate. */ getIndex(child: T): integer; /** - * Sort the contents of this List so the items are in order based - * on the given property. For example, `sort('alpha')` would sort the List - * contents based on the value of their `alpha` property. + * Sort the contents of this List so the items are in order based on the given property. + * For example, `sort('alpha')` would sort the List contents based on the value of their `alpha` property. * @param property The property to lexically sort by. + * @param handler Provide your own custom handler function. Will receive 2 children which it should compare and return a boolean. */ - sort(property: string): T[]; + sort(property: string, handler?: Function): T[]; /** * Searches for the first instance of a child with its `name` @@ -49242,13 +67065,13 @@ declare namespace Phaser { getRandom(startIndex?: integer, length?: integer): T | null; /** - * [description] - * @param property [description] - * @param value [description] - * @param startIndex [description] Default 0. - * @param endIndex [description] + * Returns the first element in a given part of the List which matches a specific criterion. + * @param property The name of the property to test or a falsey value to have no criterion. + * @param value The value to test the `property` against, or `undefined` to allow any value and only check for existence. + * @param startIndex The position in the List to start the search at. Default 0. + * @param endIndex The position in the List to optionally stop the search at. It won't be checked. */ - getFirst(property: string, value: T, startIndex?: number, endIndex?: number): T | null; + getFirst(property: string, value: any, startIndex?: number, endIndex?: number): T | null; /** * Returns all children in this List. @@ -49272,44 +67095,44 @@ declare namespace Phaser { getAll(property?: string, value?: T, startIndex?: integer, endIndex?: integer): T[]; /** - * [description] - * @param property [description] - * @param value [description] + * Returns the total number of items in the List which have a property matching the given value. + * @param property The property to test on each item. + * @param value The value to test the property against. */ count(property: string, value: T): integer; /** - * [description] - * @param child1 [description] - * @param child2 [description] + * Swaps the positions of two items in the list. + * @param child1 The first item to swap. + * @param child2 The second item to swap. */ swap(child1: T, child2: T): void; /** - * [description] - * @param child [description] - * @param index [description] + * Moves an item in the List to a new position. + * @param child The item to move. + * @param index Moves an item in the List to a new position. */ moveTo(child: T, index: integer): T; /** - * [description] - * @param child [description] + * Removes one or many items from the List. + * @param child The item, or array of items, to remove. * @param skipCallback Skip calling the List.removeCallback. Default false. */ remove(child: T, skipCallback?: boolean): T; /** - * [description] - * @param index [description] + * Removes the item at the given position in the List. + * @param index The position to remove the item from. * @param skipCallback Skip calling the List.removeCallback. Default false. */ removeAt(index: integer, skipCallback?: boolean): T; /** - * [description] - * @param startIndex [description] Default 0. - * @param endIndex [description] + * Removes the items within the given range in the List. + * @param startIndex The index to start removing from. Default 0. + * @param endIndex The position to stop removing at. The item at this position won't be removed. * @param skipCallback Skip calling the List.removeCallback. Default false. */ removeBetween(startIndex?: integer, endIndex?: integer, skipCallback?: boolean): T[]; @@ -49322,25 +67145,25 @@ declare namespace Phaser { /** * Brings the given child to the top of this List. - * @param child [description] + * @param child The item to bring to the top of the List. */ bringToTop(child: T): T; /** * Sends the given child to the bottom of this List. - * @param child [description] + * @param child The item to send to the back of the list. */ sendToBack(child: T): T; /** * Moves the given child up one place in this group unless it's already at the top. - * @param child [description] + * @param child The item to move up. */ moveUp(child: T): T; /** * Moves the given child down one place in this group unless it's already at the bottom. - * @param child [description] + * @param child The item to move down. */ moveDown(child: T): T; @@ -49350,7 +67173,7 @@ declare namespace Phaser { reverse(): Phaser.Structs.List; /** - * [description] + * Shuffles the items in the list. */ shuffle(): Phaser.Structs.List; @@ -49362,15 +67185,15 @@ declare namespace Phaser { replace(oldChild: T, newChild: T): T; /** - * [description] - * @param child [description] + * Checks if an item exists within the List. + * @param child The item to check for the existence of. */ exists(child: T): boolean; /** * Sets the property `key` to the given value on all members of this List. - * @param property [description] - * @param value [description] + * @param property The name of the property to set. + * @param value The value to set the property to. * @param startIndex The first child index to start the search from. * @param endIndex The last child index to search up until. */ @@ -49379,174 +67202,195 @@ declare namespace Phaser { /** * Passes all children to the given callback. * @param callback The function to call. - * @param thisArg Value to use as `this` when executing callback. + * @param context Value to use as `this` when executing callback. * @param args Additional arguments that will be passed to the callback, after the child. */ - each(callback: EachListCallback, thisArg?: any, ...args: any[]): void; + each(callback: EachListCallback, context?: any, ...args: any[]): void; /** - * [description] + * Clears the List and recreates its internal array. */ shutdown(): void; /** - * [description] + * Destroys this List. */ destroy(): void; /** - * [description] + * The number of items inside the List. */ readonly length: integer; /** - * [description] + * The first item in the List or `null` for an empty List. */ - readonly first: integer; + readonly first: T; /** - * [description] + * The last item in the List, or `null` for an empty List. */ - readonly last: integer; + readonly last: T; /** - * [description] + * The next item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #first} or manually setting the {@link #position} to iterate the List. */ - readonly next: integer; + readonly next: T; /** - * [description] + * The previous item in the List, or `null` if the entire List has been traversed. + * + * This property can be read successively after reading {@link #last} or manually setting the {@link #position} to iterate the List backwards. */ - readonly previous: integer; + readonly previous: T; } /** * The keys of a Map can be arbitrary values. + * + * ```javascript * var map = new Map([ * [ 1, 'one' ], * [ 2, 'two' ], * [ 3, 'three' ] * ]); + * ``` */ class Map { /** * - * @param elements [description] + * @param elements An optional array of key-value pairs to populate this Map with. */ constructor(elements: V[]); /** - * [description] + * The entries in this Map. */ entries: {[key: string]: V}; /** - * [description] + * The number of key / value pairs in this Map. */ size: number; /** - * [description] - * @param key [description] - * @param value [description] + * Adds an element with a specified `key` and `value` to this Map. + * If the `key` already exists, the value will be replaced. + * @param key The key of the element to be added to this Map. + * @param value The value of the element to be added to this Map. */ set(key: K, value: V): Phaser.Structs.Map; /** - * [description] - * @param key [description] + * Returns the value associated to the `key`, or `undefined` if there is none. + * @param key The key of the element to return from the `Map` object. */ get(key: K): V; /** - * [description] + * Returns an `Array` of all the values stored in this Map. */ getArray(): V[]; /** - * [description] - * @param key [description] + * Returns a boolean indicating whether an element with the specified key exists or not. + * @param key The key of the element to test for presence of in this Map. */ has(key: K): boolean; /** - * [description] - * @param key [description] + * Delete the specified element from this Map. + * @param key The key of the element to delete from this Map. */ delete(key: K): Phaser.Structs.Map; /** - * [description] + * Delete all entries from this Map. */ clear(): Phaser.Structs.Map; /** - * [description] + * Returns all entries keys in this Map. */ keys(): K[]; /** - * [description] + * Returns an `Array` of all entries. */ values(): V[]; /** - * [description] + * Dumps the contents of this Map to the console via `console.group`. */ dump(): void; /** - * [description] - * @param callback [description] + * Passes all entries in this Map to the given callback. + * @param callback The callback which will receive the keys and entries held in this Map. */ each(callback: EachMapCallback): Phaser.Structs.Map; /** - * [description] - * @param value [description] + * Returns `true` if the value exists within this Map. Otherwise, returns `false`. + * @param value The value to search for. */ contains(value: V): boolean; /** - * Merges all new keys from the given Map into this one - * If it encounters a key that already exists it will be skipped - * unless override = true. - * @param map [description] - * @param override [description] Default false. + * Merges all new keys from the given Map into this one. + * If it encounters a key that already exists it will be skipped unless override is set to `true`. + * @param map The Map to merge in to this Map. + * @param override Set to `true` to replace values in this Map with those from the source map, or `false` to skip them. Default false. */ merge(map: Phaser.Structs.Map, override?: boolean): Phaser.Structs.Map; } /** - * [description] + * A Process Queue maintains three internal lists. + * + * The `pending` list is a selection of items which are due to be made 'active' in the next update. + * The `active` list is a selection of items which are considered active and should be updated. + * The `destroy` list is a selection of items that were active and are awaiting being destroyed in the next update. + * + * When new items are added to a Process Queue they are put in a pending data, rather than being added + * immediately the active list. Equally, items that are removed are put into the destroy list, rather than + * being destroyed immediately. This allows the Process Queue to carefully process each item at a specific, fixed + * time, rather than at the time of the request from the API. */ class ProcessQueue { /** - * [description] - * @param item [description] + * Adds a new item to the Process Queue. + * The item is added to the pending list and made active in the next update. + * @param item The item to add to the queue. */ add(item: T): Phaser.Structs.ProcessQueue; /** - * [description] - * @param item [description] + * Removes an item from the Process Queue. + * The item is added to the pending destroy and fully removed in the next update. + * @param item The item to be removed from the queue. */ remove(item: T): Phaser.Structs.ProcessQueue; /** - * [description] + * Update this queue. First it will process any items awaiting destruction, and remove them. + * + * Then it will check to see if there are any items pending insertion, and move them to an + * active state. Finally, it will return a list of active items for further processing. */ update(): T[]; /** - * [description] + * Returns the current list of active items. */ getActive(): T[]; /** - * [description] + * Immediately destroys this process queue, clearing all of its internal arrays and resetting the process totals. */ destroy(): void; @@ -49571,101 +67415,427 @@ declare namespace Phaser { class Set { /** * - * @param elements [description] + * @param elements An optional array of elements to insert into this Set. */ constructor(elements?: T[]); /** - * [description] + * The entries of this Set. Stored internally as an array. */ entries: T[]; /** - * [description] - * @param value [description] + * Inserts the provided value into this Set. If the value is already contained in this Set this method will have no effect. + * @param value The value to insert into this Set. */ set(value: T): Phaser.Structs.Set; /** - * [description] - * @param property [description] - * @param value [description] + * Get an element of this Set which has a property of the specified name, if that property is equal to the specified value. + * If no elements of this Set satisfy the condition then this method will return `null`. + * @param property The property name to check on the elements of this Set. + * @param value The value to check for. */ get(property: string, value: T): T; /** - * [description] + * Returns an array containing all the values in this Set. */ getArray(): T[]; /** - * [description] - * @param value [description] + * Removes the given value from this Set if this Set contains that value. + * @param value The value to remove from the Set. */ delete(value: T): Phaser.Structs.Set; /** - * [description] + * Dumps the contents of this Set to the console via `console.group`. */ dump(): void; /** - * For when you know this Set will be modified during the iteration. - * @param callback [description] - * @param callbackScope [description] + * Passes each value in this Set to the given callback. + * Use this function when you know this Set will be modified during the iteration, otherwise use `iterate`. + * @param callback The callback to be invoked and passed each value this Set contains. + * @param callbackScope The scope of the callback. */ - each(callback: EachSetCallback, callbackScope: any): Phaser.Structs.Set; + each(callback: EachSetCallback, callbackScope?: any): Phaser.Structs.Set; /** + * Passes each value in this Set to the given callback. * For when you absolutely know this Set won't be modified during the iteration. - * @param callback [description] - * @param callbackScope [description] + * @param callback The callback to be invoked and passed each value this Set contains. + * @param callbackScope The scope of the callback. */ - iterate(callback: EachSetCallback, callbackScope: any): Phaser.Structs.Set; + iterate(callback: EachSetCallback, callbackScope?: any): Phaser.Structs.Set; /** - * [description] - * @param callbackKey [description] + * Goes through each entry in this Set and invokes the given function on them, passing in the arguments. + * @param callbackKey The key of the function to be invoked on each Set entry. * @param args Additional arguments that will be passed to the callback, after the child. */ iterateLocal(callbackKey: string, ...args: any[]): Phaser.Structs.Set; /** - * [description] + * Clears this Set so that it no longer contains any values. */ clear(): Phaser.Structs.Set; /** - * [description] - * @param value [description] + * Returns `true` if this Set contains the given value, otherwise returns `false`. + * @param value The value to check for in this Set. */ contains(value: T): boolean; /** - * [description] - * @param set [description] + * Returns a new Set containing all values that are either in this Set or in the Set provided as an argument. + * @param set The Set to perform the union with. */ union(set: Phaser.Structs.Set): Phaser.Structs.Set; /** - * [description] - * @param set [description] + * Returns a new Set that contains only the values which are in this Set and that are also in the given Set. + * @param set The Set to intersect this set with. */ intersect(set: Phaser.Structs.Set): Phaser.Structs.Set; /** - * [description] - * @param set [description] + * Returns a new Set containing all the values in this Set which are *not* also in the given Set. + * @param set The Set to perform the difference with. */ difference(set: Phaser.Structs.Set): Phaser.Structs.Set; /** - * [description] + * The size of this Set. This is the number of entries within it. + * Changing the size will truncate the Set if the given value is smaller than the current size. + * Increasing the size larger than the current size has no effect. */ size: integer; } + /** + * The Size component allows you to set `width` and `height` properties and define the relationship between them. + * + * The component can automatically maintain the aspect ratios between the two values, and clamp them + * to a defined min-max range. You can also control the dominant axis. When dimensions are given to the Size component + * that would cause it to exceed its min-max range, the dimensions are adjusted based on the dominant axis. + */ + class Size { + /** + * + * @param width The width of the Size component. Default 0. + * @param height The height of the Size component. If not given, it will use the `width`. Default width. + * @param aspectMode The aspect mode of the Size component. Defaults to 0, no mode. Default 0. + * @param parent The parent of this Size component. Can be any object with public `width` and `height` properties. Dimensions are clamped to keep them within the parent bounds where possible. Default null. + */ + constructor(width?: number, height?: number, aspectMode?: integer, parent?: any); + + /** + * The aspect mode this Size component will use when calculating its dimensions. + * This property is read-only. To change it use the `setAspectMode` method. + */ + readonly aspectMode: integer; + + /** + * The proportional relationship between the width and height. + * + * This property is read-only and is updated automatically when either the `width` or `height` properties are changed, + * depending on the aspect mode. + */ + readonly aspectRatio: number; + + /** + * The minimum allowed width. + * Cannot be less than zero. + * This value is read-only. To change it see the `setMin` method. + */ + readonly minWidth: number; + + /** + * The minimum allowed height. + * Cannot be less than zero. + * This value is read-only. To change it see the `setMin` method. + */ + readonly minHeight: number; + + /** + * The maximum allowed width. + * This value is read-only. To change it see the `setMax` method. + */ + readonly maxWidth: number; + + /** + * The maximum allowed height. + * This value is read-only. To change it see the `setMax` method. + */ + readonly maxHeight: number; + + /** + * A Vector2 containing the horizontal and vertical snap values, which the width and height are snapped to during resizing. + * + * By default this is disabled. + * + * This property is read-only. To change it see the `setSnap` method. + */ + readonly snapTo: Phaser.Math.Vector2; + + /** + * Sets the aspect mode of this Size component. + * + * The aspect mode controls what happens when you modify the `width` or `height` properties, or call `setSize`. + * + * It can be a number from 0 to 4, or a Size constant: + * + * 0. NONE = Do not make the size fit the aspect ratio. Change the ratio when the size changes. + * 1. WIDTH_CONTROLS_HEIGHT = The height is automatically adjusted based on the width. + * 2. HEIGHT_CONTROLS_WIDTH = The width is automatically adjusted based on the height. + * 3. FIT = The width and height are automatically adjusted to fit inside the given target area, while keeping the aspect ratio. Depending on the aspect ratio there may be some space inside the area which is not covered. + * 4. ENVELOP = The width and height are automatically adjusted to make the size cover the entire target area while keeping the aspect ratio. This may extend further out than the target size. + * + * Calling this method automatically recalculates the `width` and the `height`, if required. + * @param value The aspect mode value. Default 0. + */ + setAspectMode(value?: integer): this; + + /** + * By setting a Snap To value when this Size component is modified its dimensions will automatically + * by snapped to the nearest grid slice, using floor. For example, if you have snap value of 16, + * and the width changes to 68, then it will snap down to 64 (the closest multiple of 16 when floored) + * + * Note that snapping takes place before adjustments by the parent, or the min / max settings. If these + * values are not multiples of the given snap values, then this can result in un-snapped dimensions. + * + * Call this method with no arguments to reset the snap values. + * + * Calling this method automatically recalculates the `width` and the `height`, if required. + * @param snapWidth The amount to snap the width to. If you don't want to snap the width, pass a value of zero. Default 0. + * @param snapHeight The amount to snap the height to. If not provided it will use the `snapWidth` value. If you don't want to snap the height, pass a value of zero. Default snapWidth. + */ + setSnap(snapWidth?: number, snapHeight?: number): this; + + /** + * Sets, or clears, the parent of this Size component. + * + * To clear the parent call this method with no arguments. + * + * The parent influences the maximum extents to which this Size compoent can expand, + * based on the aspect mode: + * + * NONE - The parent clamps both the width and height. + * WIDTH_CONTROLS_HEIGHT - The parent clamps just the width. + * HEIGHT_CONTROLS_WIDTH - The parent clamps just the height. + * FIT - The parent clamps whichever axis is required to ensure the size fits within it. + * ENVELOP - The parent is used to ensure the size fully envelops the parent. + * + * Calling this method automatically calls `setSize`. + * @param parent Sets the parent of this Size component. Don't provide a value to clear an existing parent. + */ + setParent(parent?: any): this; + + /** + * Set the minimum width and height values this Size component will allow. + * + * The minimum values can never be below zero, or greater than the maximum values. + * + * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. + * + * Note that based on the aspect mode, and if this Size component has a parent set or not, the minimums set here + * _can_ be exceed in some situations. + * @param width The minimum allowed width of the Size component. Default 0. + * @param height The minimum allowed height of the Size component. If not given, it will use the `width`. Default width. + */ + setMin(width?: number, height?: number): this; + + /** + * Set the maximum width and height values this Size component will allow. + * + * Setting this will automatically adjust both the `width` and `height` properties to ensure they are within range. + * + * Note that based on the aspect mode, and if this Size component has a parent set or not, the maximums set here + * _can_ be exceed in some situations. + * @param width The maximum allowed width of the Size component. Default Number.MAX_VALUE. + * @param height The maximum allowed height of the Size component. If not given, it will use the `width`. Default width. + */ + setMax(width?: number, height?: number): this; + + /** + * Sets the width and height of this Size component based on the aspect mode. + * + * If the aspect mode is 'none' then calling this method will change the aspect ratio, otherwise the current + * aspect ratio is honored across all other modes. + * + * If snapTo values have been set then the given width and height are snapped first, prior to any further + * adjustment via min/max values, or a parent. + * + * If minimum and/or maximum dimensions have been specified, the values given to this method will be clamped into + * that range prior to adjustment, but may still exceed them depending on the aspect mode. + * + * If this Size component has a parent set, and the aspect mode is `fit` or `envelop`, then the given sizes will + * be clamped to the range specified by the parent. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the `width`. Default width. + */ + setSize(width?: number, height?: number): this; + + /** + * Sets a new aspect ratio, overriding what was there previously. + * + * It then calls `setSize` immediately using the current dimensions. + * @param ratio The new aspect ratio. + */ + setAspectRatio(ratio: number): this; + + /** + * Sets a new width and height for this Size component and updates the aspect ratio based on them. + * + * It _doesn't_ change the `aspectMode` and still factors in size limits such as the min max and parent bounds. + * @param width The new width of the Size component. + * @param height The new height of the Size component. If not given, it will use the `width`. Default width. + */ + resize(width: number, height?: number): this; + + /** + * Takes a new width and passes it through the min/max clamp and then checks it doesn't exceed the parent width. + * @param value The value to clamp and check. + * @param checkParent Check the given value against the parent, if set. Default true. + */ + getNewWidth(value: number, checkParent?: boolean): number; + + /** + * Takes a new height and passes it through the min/max clamp and then checks it doesn't exceed the parent height. + * @param value The value to clamp and check. + * @param checkParent Check the given value against the parent, if set. Default true. + */ + getNewHeight(value: number, checkParent?: boolean): number; + + /** + * The current `width` and `height` are adjusted to fit inside the given dimensions, while keeping the aspect ratio. + * + * If `fit` is true there may be some space inside the target area which is not covered if its aspect ratio differs. + * If `fit` is false the size may extend further out than the target area if the aspect ratios differ. + * + * If this Size component has a parent set, then the width and height passed to this method will be clamped so + * it cannot exceed that of the parent. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the width value. + * @param fit Perform a `fit` (true) constraint, or an `envelop` (false) constraint. Default true. + */ + constrain(width?: number, height?: number, fit?: boolean): this; + + /** + * The current `width` and `height` are adjusted to fit inside the given dimensions, while keeping the aspect ratio. + * + * There may be some space inside the target area which is not covered if its aspect ratio differs. + * + * If this Size component has a parent set, then the width and height passed to this method will be clamped so + * it cannot exceed that of the parent. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the width value. + */ + fitTo(width?: number, height?: number): this; + + /** + * The current `width` and `height` are adjusted so that they fully envlop the given dimensions, while keeping the aspect ratio. + * + * The size may extend further out than the target area if the aspect ratios differ. + * + * If this Size component has a parent set, then the values are clamped so that it never exceeds the parent + * on the longest axis. + * @param width The new width of the Size component. Default 0. + * @param height The new height of the Size component. If not given, it will use the width value. + */ + envelop(width?: number, height?: number): this; + + /** + * Sets the width of this Size component. + * + * Depending on the aspect mode, changing the width may also update the height and aspect ratio. + * @param width The new width of the Size component. + */ + setWidth(width: number): this; + + /** + * Sets the height of this Size component. + * + * Depending on the aspect mode, changing the height may also update the width and aspect ratio. + * @param height The new height of the Size component. + */ + setHeight(height: number): this; + + /** + * Returns a string representation of this Size component. + */ + toString(): string; + + /** + * Copies the aspect mode, aspect ratio, width and height from this Size component + * to the given Size component. Note that the parent, if set, is not copied across. + * @param destination The Size component to copy the values to. + */ + copy(destination: Phaser.Structs.Size): Phaser.Structs.Size; + + /** + * Destroys this Size component. + * + * This clears the local properties and any parent object, if set. + * + * A destroyed Size component cannot be re-used. + */ + destroy(): void; + + /** + * The width of this Size component. + * + * This value is clamped to the range specified by `minWidth` and `maxWidth`, if enabled. + * + * A width can never be less than zero. + * + * Changing this value will automatically update the `height` if the aspect ratio lock is enabled. + * You can also use the `setWidth` and `getWidth` methods. + */ + width: number; + + /** + * The height of this Size component. + * + * This value is clamped to the range specified by `minHeight` and `maxHeight`, if enabled. + * + * A height can never be less than zero. + * + * Changing this value will automatically update the `width` if the aspect ratio lock is enabled. + * You can also use the `setHeight` and `getHeight` methods. + */ + height: number; + + /** + * Do not make the size fit the aspect ratio. Change the ratio when the size changes. + */ + static readonly NONE: integer; + + /** + * The height is automatically adjusted based on the width. + */ + static readonly WIDTH_CONTROLS_HEIGHT: integer; + + /** + * The width is automatically adjusted based on the height. + */ + static readonly HEIGHT_CONTROLS_WIDTH: integer; + + /** + * The width and height are automatically adjusted to fit inside the given target area, while keeping the aspect ratio. Depending on the aspect ratio there may be some space inside the area which is not covered. + */ + static readonly FIT: integer; + + /** + * The width and height are automatically adjusted to make the size cover the entire target area while keeping the aspect ratio. This may extend further out than the target size. + */ + static readonly ENVELOP: integer; + + } + } namespace Textures { @@ -49697,7 +67867,152 @@ declare namespace Phaser { * @param width The width of the canvas. * @param height The height of the canvas. */ - constructor(manager: Phaser.Textures.TextureManager, key: string, source: HTMLCanvasElement, width: integer, height: integer); + constructor(manager: Phaser.Textures.CanvasTexture, key: string, source: HTMLCanvasElement, width: integer, height: integer); + + /** + * The source Canvas Element. + */ + readonly canvas: HTMLCanvasElement; + + /** + * The 2D Canvas Rendering Context. + */ + readonly context: CanvasRenderingContext2D; + + /** + * The width of the Canvas. + * This property is read-only, if you wish to change it use the `setSize` method. + */ + readonly width: integer; + + /** + * The height of the Canvas. + * This property is read-only, if you wish to change it use the `setSize` method. + */ + readonly height: integer; + + /** + * The context image data. + * Use the `update` method to populate this when the canvas changes. + */ + imageData: ImageData; + + /** + * A Uint8ClampedArray view into the `buffer`. + * Use the `update` method to populate this when the canvas changes. + * Note that this is unavailable in some browsers, such as Epic Browser, due to their security restrictions. + */ + data: Uint8ClampedArray; + + /** + * An Uint32Array view into the `buffer`. + */ + pixels: Uint32Array; + + /** + * An ArrayBuffer the same size as the context ImageData. + */ + buffer: ArrayBuffer; + + /** + * This re-creates the `imageData` from the current context. + * It then re-builds the ArrayBuffer, the `data` Uint8ClampedArray reference and the `pixels` Int32Array. + * + * Warning: This is a very expensive operation, so use it sparingly. + */ + update(): Phaser.Textures.CanvasTexture; + + /** + * Draws the given Image or Canvas element to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * @param x The x coordinate to draw the source at. + * @param y The y coordinate to draw the source at. + * @param source The element to draw to this canvas. + */ + draw(x: integer, y: integer, source: HTMLImageElement | HTMLCanvasElement): Phaser.Textures.CanvasTexture; + + /** + * Draws the given texture frame to this CanvasTexture, then updates the internal + * ImageData buffer and arrays. + * @param key The unique string-based key of the Texture. + * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. + * @param x The x coordinate to draw the source at. Default 0. + * @param y The y coordinate to draw the source at. Default 0. + */ + drawFrame(key: string, frame?: string | integer, x?: integer, y?: integer): Phaser.Textures.CanvasTexture; + + /** + * Sets a pixel in the CanvasTexture to the given color and alpha values. + * + * This is an expensive operation to run in large quantities, so use sparingly. + * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param red The red color value. A number between 0 and 255. + * @param green The green color value. A number between 0 and 255. + * @param blue The blue color value. A number between 0 and 255. + * @param alpha The alpha value. A number between 0 and 255. Default 255. + */ + setPixel(x: integer, y: integer, red: integer, green: integer, blue: integer, alpha?: integer): this; + + /** + * Puts the ImageData into the context of this CanvasTexture at the given coordinates. + * @param imageData The ImageData to put at the given location. + * @param x The x coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate to put the imageData. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param dirtyX Horizontal position (x coordinate) of the top-left corner from which the image data will be extracted. Default 0. + * @param dirtyY Vertical position (x coordinate) of the top-left corner from which the image data will be extracted. Default 0. + * @param dirtyWidth Width of the rectangle to be painted. Defaults to the width of the image data. + * @param dirtyHeight Height of the rectangle to be painted. Defaults to the height of the image data. + */ + putData(imageData: ImageData, x: integer, y: integer, dirtyX?: integer, dirtyY?: integer, dirtyWidth?: integer, dirtyHeight?: integer): this; + + /** + * Gets an ImageData region from this CanvasTexture from the position and size specified. + * You can write this back using `CanvasTexture.putData`, or manipulate it. + * @param x The x coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the top-left of the area to get the ImageData from. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param width The width of the rectangle from which the ImageData will be extracted. Positive values are to the right, and negative to the left. + * @param height The height of the rectangle from which the ImageData will be extracted. Positive values are down, and negative are up. + */ + getData(x: integer, y: integer, width: integer, height: integer): ImageData; + + /** + * Get the color of a specific pixel from this texture and store it in a Color object. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param out A Color object to store the pixel values in. If not provided a new Color object will be created. + */ + getPixel(x: integer, y: integer, out?: Phaser.Display.Color): Phaser.Display.Color; + + /** + * Returns an array containing all of the pixels in the given region. + * + * If the requested region extends outside the bounds of this CanvasTexture, + * the region is truncated to fit. + * + * If you have drawn anything to this CanvasTexture since it was created you must call `CanvasTexture.update` to refresh the array buffer, + * otherwise this may return out of date color values, or worse - throw a run-time error as it tries to access an array element that doesn't exist. + * @param x The x coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the top-left of the region. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param width The width of the region to get. Must be an integer. + * @param height The height of the region to get. Must be an integer. If not given will be set to the `width`. + */ + getPixels(x: integer, y: integer, width: integer, height?: integer): PixelConfig[]; + + /** + * Returns the Image Data index for the given pixel in this CanvasTexture. + * + * The index can be used to read directly from the `this.data` array. + * + * The index points to the red value in the array. The subsequent 3 indexes + * point to green, blue and alpha respectively. + * @param x The x coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + * @param y The y coordinate of the pixel to get. Must lay within the dimensions of this CanvasTexture and be an integer. + */ + getIndex(x: integer, y: integer): integer; /** * This should be called manually if you are running under WebGL. @@ -49717,9 +68032,14 @@ declare namespace Phaser { getContext(): CanvasRenderingContext2D; /** - * Clears this Canvas Texture, resetting it back to transparent. + * Clears the given region of this Canvas Texture, resetting it back to transparent. + * If no region is given, the whole Canvas Texture is cleared. + * @param x The x coordinate of the top-left of the region to clear. Default 0. + * @param y The y coordinate of the top-left of the region to clear. Default 0. + * @param width The width of the region. + * @param height The height of the region. */ - clear(): Phaser.Textures.CanvasTexture; + clear(x?: integer, y?: integer, width?: integer, height?: integer): Phaser.Textures.CanvasTexture; /** * Changes the size of this Canvas Texture. @@ -49728,6 +68048,11 @@ declare namespace Phaser { */ setSize(width: integer, height?: integer): Phaser.Textures.CanvasTexture; + /** + * Destroys this Texture and releases references to its sources and frames. + */ + destroy(): void; + } /** @@ -49744,6 +68069,61 @@ declare namespace Phaser { NEAREST, } + namespace Events { + /** + * The Texture Add Event. + * + * This event is dispatched by the Texture Manager when a texture is added to it. + * + * Listen to this event from within a Scene using: `this.textures.on('addtexture', listener)`. + */ + const ADD: any; + + /** + * The Texture Load Error Event. + * + * This event is dispatched by the Texture Manager when a texture it requested to load failed. + * This only happens when base64 encoded textures fail. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onerror', listener)`. + */ + const ERROR: any; + + /** + * The Texture Load Event. + * + * This event is dispatched by the Texture Manager when a texture has finished loading on it. + * This only happens for base64 encoded textures. All other texture types are loaded via the Loader Plugin. + * + * Listen to this event from within a Scene using: `this.textures.on('onload', listener)`. + * + * This event is dispatched after the [ADD]{@linkcode Phaser.Textures.Events#event:ADD} event. + */ + const LOAD: any; + + /** + * This internal event signifies that the Texture Manager is now ready and the Game can continue booting. + * + * When a Phaser Game instance is booting for the first time, the Texture Manager has to wait on a couple of non-blocking + * async events before it's fully ready to carry on. When those complete the Texture Manager emits this event via the Game + * instance, which tells the Game to carry on booting. + */ + const READY: any; + + /** + * The Texture Remove Event. + * + * This event is dispatched by the Texture Manager when a texture is removed from it. + * + * Listen to this event from within a Scene using: `this.textures.on('removetexture', listener)`. + * + * If you have any Game Objects still using the removed texture, they will start throwing + * errors the next time they try to render. Be sure to clear all use of the texture in this event handler. + */ + const REMOVE: any; + + } + /** * A Frame is a section of a Texture. */ @@ -49781,6 +68161,11 @@ declare namespace Phaser { */ sourceIndex: integer; + /** + * A reference to the Texture Source WebGL Texture that this Frame is using. + */ + glTexture: WebGLTexture; + /** * X position within the source image to cut from. */ @@ -49880,6 +68265,26 @@ declare namespace Phaser { */ customData: object; + /** + * WebGL UV u0 value. + */ + u0: number; + + /** + * WebGL UV v0 value. + */ + v0: number; + + /** + * WebGL UV u1 value. + */ + u1: number; + + /** + * WebGL UV v1 value. + */ + v1: number; + /** * Sets the width, height, x and y of this Frame. * @@ -49903,6 +68308,31 @@ declare namespace Phaser { */ setTrim(actualWidth: number, actualHeight: number, destX: number, destY: number, destWidth: number, destHeight: number): Phaser.Textures.Frame; + /** + * Takes a crop data object and, based on the rectangular region given, calculates the + * required UV coordinates in order to crop this Frame for WebGL and Canvas rendering. + * + * This is called directly by the Game Object Texture Components `setCrop` method. + * Please use that method to crop a Game Object. + * @param crop The crop data object. This is the `GameObject._crop` property. + * @param x The x coordinate to start the crop from. Cannot be negative or exceed the Frame width. + * @param y The y coordinate to start the crop from. Cannot be negative or exceed the Frame height. + * @param width The width of the crop rectangle. Cannot exceed the Frame width. + * @param height The height of the crop rectangle. Cannot exceed the Frame height. + * @param flipX Does the parent Game Object have flipX set? + * @param flipY Does the parent Game Object have flipY set? + */ + setCropUVs(crop: object, x: number, y: number, width: number, height: number, flipX: boolean, flipY: boolean): object; + + /** + * Takes a crop data object and recalculates the UVs based on the dimensions inside the crop object. + * Called automatically by `setFrame`. + * @param crop The crop data object. This is the `GameObject._crop` property. + * @param flipX Does the parent Game Object have flipX set? + * @param flipY Does the parent Game Object have flipY set? + */ + updateCropUVs(crop: object, flipX: boolean, flipY: boolean): object; + /** * Updates the internal WebGL UV cache and the drawImage cache. */ @@ -49935,11 +68365,6 @@ declare namespace Phaser { */ readonly realHeight: number; - /** - * The UV data for this Frame. - */ - readonly uvs: object; - /** * The radius of the Frame (derived from sqrt(w * w + h * h) / 2) */ @@ -49990,7 +68415,7 @@ declare namespace Phaser { * @param width The width of the Texture. This is optional and automatically derived from the source images. * @param height The height of the Texture. This is optional and automatically derived from the source images. */ - constructor(manager: Phaser.Textures.TextureManager, key: string, source: HTMLImageElement[] | HTMLCanvasElement[], width?: number, height?: number); + constructor(manager: Phaser.Textures.TextureManager, key: string, source: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[], width?: number, height?: number); /** * A reference to the Texture Manager this Texture belongs to. @@ -50076,8 +68501,9 @@ declare namespace Phaser { /** * Returns an array of all the Frames in the given TextureSource. * @param sourceIndex The index of the TextureSource to get the Frames from. + * @param includeBase Include the `__BASE` Frame in the output array? Default false. */ - getFramesFromTextureSource(sourceIndex: integer): Phaser.Textures.Frame[]; + getFramesFromTextureSource(sourceIndex: integer, includeBase?: boolean): Phaser.Textures.Frame[]; /** * Returns an array with all of the names of the Frames in this Texture. @@ -50094,7 +68520,7 @@ declare namespace Phaser { * This will return the actual DOM Image or Canvas element. * @param name The string-based name, or integer based index, of the Frame to get from this Texture. */ - getSourceImage(name?: string | integer): HTMLImageElement | HTMLCanvasElement; + getSourceImage(name?: string | integer): HTMLImageElement | HTMLCanvasElement | Phaser.GameObjects.RenderTexture; /** * Given a Frame name, return the data source image it uses to render with. @@ -50112,7 +68538,7 @@ declare namespace Phaser { * equally apply to the normal map. * @param data The source image. */ - setDataSource(data: HTMLImageElement | HTMLCanvasElement): void; + setDataSource(data: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): void; /** * Sets the Filter Mode for this Texture. @@ -50144,52 +68570,26 @@ declare namespace Phaser { class TextureManager extends Phaser.Events.EventEmitter { /** * - * @param game [description] + * @param game The Phaser.Game instance this Texture Manager belongs to. */ constructor(game: Phaser.Game); /** - * The source Canvas Element. - */ - readonly canvas: HTMLCanvasElement; - - /** - * The width of the Canvas. - * This property is read-only, if you wish to change use `setSize`. - */ - readonly width: integer; - - /** - * The height of the Canvas. - * This property is read-only, if you wish to change use `setSize`. - */ - readonly height: integer; - - /** - * [description] + * The Game that this TextureManager belongs to. */ game: Phaser.Game; /** - * [description] + * The name of this manager. */ name: string; /** - * [description] + * An object that has all of textures that Texture Manager creates. + * Textures are assigned to keys so we can access to any texture that this object has directly by key value without iteration. */ list: object; - /** - * [description] - */ - boot(): void; - - /** - * [description] - */ - updatePending(): void; - /** * Checks the given texture key and throws a console.warn if the key is already in use, then returns false. * If you wish to avoid the console.warn then use `TextureManager.exists` instead. @@ -50214,7 +68614,18 @@ declare namespace Phaser { * @param key The unique string-based key of the Texture. * @param data The Base64 encoded data. */ - addBase64(key: string, data: any): void; + addBase64(key: string, data: any): this; + + /** + * Gets an existing texture frame and converts it into a base64 encoded image and returns the base64 data. + * + * You can also provide the image type and encoder options. + * @param key The unique string-based key of the Texture. + * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. + * @param type [description] Default 'image/png'. + * @param encoderOptions [description] Default 0.92. + */ + getBase64(key: string, frame?: string | integer, type?: string, encoderOptions?: number): string; /** * Adds a new Texture to the Texture Manager created from the given Image element. @@ -50222,14 +68633,22 @@ declare namespace Phaser { * @param source The source Image element. * @param dataSource An optional data Image element. */ - addImage(key: string, source: HTMLImageElement, dataSource?: HTMLImageElement): Phaser.Textures.Texture; + addImage(key: string, source: HTMLImageElement, dataSource?: HTMLImageElement | HTMLCanvasElement): Phaser.Textures.Texture; + + /** + * Adds a Render Texture to the Texture Manager using the given key. + * This allows you to then use the Render Texture as a normal texture for texture based Game Objects like Sprites. + * @param key The unique string-based key of the Texture. + * @param renderTexture The source Render Texture. + */ + addRenderTexture(key: string, renderTexture: Phaser.GameObjects.RenderTexture): Phaser.Textures.Texture; /** * Creates a new Texture using the given config values. * Generated textures consist of a Canvas element to which the texture data is drawn. * See the Phaser.Create function for the more direct way to create textures. * @param key The unique string-based key of the Texture. - * @param config [description] + * @param config The configuration object needed to generate the texture. */ generate(key: string, config: object): Phaser.Textures.Texture; @@ -50245,12 +68664,13 @@ declare namespace Phaser { createCanvas(key: string, width?: integer, height?: integer): Phaser.Textures.CanvasTexture; /** - * Creates a new Canvas Texture object from an existing Canvas element and adds - * it to this Texture Manager. + * Creates a new Canvas Texture object from an existing Canvas element + * and adds it to this Texture Manager, unless `skipCache` is true. * @param key The unique string-based key of the Texture. * @param source The Canvas element to form the base of the new Texture. + * @param skipCache Skip adding this Texture into the Cache? Default false. */ - addCanvas(key: string, source: HTMLCanvasElement): Phaser.Textures.CanvasTexture; + addCanvas(key: string, source: HTMLCanvasElement, skipCache?: boolean): Phaser.Textures.CanvasTexture; /** * Adds a new Texture Atlas to this Texture Manager. @@ -50260,7 +68680,7 @@ declare namespace Phaser { * @param data The Texture Atlas data. * @param dataSource An optional data Image element. */ - addAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement): Phaser.Textures.Texture; + addAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; /** * Adds a Texture Atlas to this Texture Manager. @@ -50271,7 +68691,7 @@ declare namespace Phaser { * @param data The Texture Atlas data/s. * @param dataSource An optional data Image element. */ - addAtlasJSONArray(key: string, source: HTMLImageElement | HTMLImageElement[], data: object | object[], dataSource?: HTMLImageElement): Phaser.Textures.Texture; + addAtlasJSONArray(key: string, source: HTMLImageElement | HTMLImageElement[], data: object | object[], dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; /** * Adds a Texture Atlas to this Texture Manager. @@ -50282,7 +68702,7 @@ declare namespace Phaser { * @param data The Texture Atlas data. * @param dataSource An optional data Image element. */ - addAtlasJSONHash(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement): Phaser.Textures.Texture; + addAtlasJSONHash(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; /** * Adds a Texture Atlas to this Texture Manager, where the atlas data is given @@ -50292,7 +68712,7 @@ declare namespace Phaser { * @param data The Texture Atlas XML data. * @param dataSource An optional data Image element. */ - addAtlasXML(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement): Phaser.Textures.Texture; + addAtlasXML(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; /** * Adds a Unity Texture Atlas to this Texture Manager. @@ -50302,7 +68722,7 @@ declare namespace Phaser { * @param data The Texture Atlas data. * @param dataSource An optional data Image element. */ - addUnityAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement): Phaser.Textures.Texture; + addUnityAtlas(key: string, source: HTMLImageElement, data: object, dataSource?: HTMLImageElement | HTMLCanvasElement | HTMLImageElement[] | HTMLCanvasElement[]): Phaser.Textures.Texture; /** * Adds a Sprite Sheet to this Texture Manager. @@ -50358,9 +68778,9 @@ declare namespace Phaser { /** * Takes a Texture key and Frame name and returns a reference to that Frame, if found. * @param key The unique string-based key of the Texture. - * @param frame The string or index of the Frame. + * @param frame The string-based name, or integer based index, of the Frame to get from the Texture. */ - getFrame(key: string, frame: string | integer): Phaser.Textures.Frame; + getFrame(key: string, frame?: string | integer): Phaser.Textures.Frame; /** * Returns an array with all of the keys of all Textures in this Texture Manager. @@ -50377,7 +68797,7 @@ declare namespace Phaser { * @param key The unique string-based key of the Texture. * @param frame The string or index of the Frame. */ - getPixel(x: integer, y: integer, key: string, frame: string | integer): Phaser.Display.Color; + getPixel(x: integer, y: integer, key: string, frame?: string | integer): Phaser.Display.Color; /** * Given a Texture and an `x` and `y` coordinate this method will return a value between 0 and 255 @@ -50388,16 +68808,28 @@ declare namespace Phaser { * @param key The unique string-based key of the Texture. * @param frame The string or index of the Frame. */ - getPixelAlpha(x: integer, y: integer, key: string, frame: string | integer): integer; + getPixelAlpha(x: integer, y: integer, key: string, frame?: string | integer): integer; /** * Sets the given Game Objects `texture` and `frame` properties so that it uses * the Texture and Frame specified in the `key` and `frame` arguments to this method. - * @param gameObject [description] + * @param gameObject The Game Object the texture would be set on. * @param key The unique string-based key of the Texture. * @param frame The string or index of the Frame. */ - setTexture(gameObject: Phaser.GameObjects.GameObject, key: string, frame: string | integer): Phaser.GameObjects.GameObject; + setTexture(gameObject: Phaser.GameObjects.GameObject, key: string, frame?: string | integer): Phaser.GameObjects.GameObject; + + /** + * Changes the key being used by a Texture to the new key provided. + * + * The old key is removed, allowing it to be re-used. + * + * Game Objects are linked to Textures by a reference to the Texture object, so + * all existing references will be retained. + * @param currentKey The current string-based key of the Texture you wish to rename. + * @param newKey The new unique string-based key to use for the Texture. + */ + renameTexture(currentKey: string, newKey: string): boolean; /** * Passes all Textures to the given callback. @@ -50438,10 +68870,17 @@ declare namespace Phaser { /** * The Texture this TextureSource belongs to. */ - texture: string; + texture: Phaser.Textures.Texture; /** - * The source image data. This is either an Image Element, or a Canvas Element. + * The source of the image data. + * This is either an Image Element, a Canvas Element or a RenderTexture. + */ + source: HTMLImageElement | HTMLCanvasElement | Phaser.GameObjects.RenderTexture; + + /** + * The image data. + * This is either an Image element or a Canvas element. */ image: HTMLImageElement | HTMLCanvasElement; @@ -50478,6 +68917,11 @@ declare namespace Phaser { */ isCanvas: boolean; + /** + * Is the source image a Render Texture? + */ + isRenderTexture: boolean; + /** * Are the source image dimensions a power of two? */ @@ -50524,25 +68968,26 @@ declare namespace Phaser { } /** - * A DynamicTilemapLayer is a game object that renders LayerData from a Tilemap. A - * DynamicTilemapLayer can only render tiles from a single tileset. + * A Dynamic Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. * - * A DynamicTilemapLayer trades some speed for being able to apply powerful effects. Unlike a - * StaticTilemapLayer, you can apply per-tile effects like tint or alpha, and you can change the - * tiles in a DynamicTilemapLayer. Use this over a StaticTilemapLayer when you need those - * features. + * A Dynamic Tilemap Layer trades some speed for being able to apply powerful effects. Unlike a + * Static Tilemap Layer, you can apply per-tile effects like tint or alpha, and you can change the + * tiles in a DynamicTilemapLayer. + * + * Use this over a Static Tilemap Layer when you need those features. */ class DynamicTilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.ScrollFactor, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible { /** * - * @param scene [description] + * @param scene The Scene to which this Game Object belongs. * @param tilemap The Tilemap this layer is a part of. * @param layerIndex The index of the LayerData associated with this layer. - * @param tileset The tileset used to render the tiles in this layer. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. * @param x The world x position where the top left of this layer will be placed. Default 0. * @param y The world y position where the top left of this layer will be placed. Default 0. */ - constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: Phaser.Tilemaps.Tileset, x?: number, y?: number); + constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); /** * Used internally by physics system to perform fast type checks. @@ -50566,9 +69011,11 @@ declare namespace Phaser { layer: Phaser.Tilemaps.LayerData; /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. */ - tileset: Phaser.Tilemaps.Tileset; + tileset: Phaser.Tilemaps.Tileset[]; /** * Used internally with the canvas render. This holds the tiles that are visible within the @@ -50576,6 +69023,80 @@ declare namespace Phaser { */ culledTiles: any[]; + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + */ + skipCull: boolean; + + /** + * The total number of tiles drawn by the renderer in the last frame. + */ + readonly tilesDrawn: integer; + + /** + * The total number of tiles in this layer. Updated every frame. + */ + readonly tilesTotal: integer; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingX: integer; + + /** + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingY: integer; + + /** + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1. The Phaser.Tilemaps.LayerData object for this Layer + * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + */ + cullCallback: Function; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + */ + gidMap: Phaser.Tilemaps.Tileset[]; + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + */ + setRenderOrder(renderOrder: integer | string): this; + /** * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting * faces are used internally for optimizing collisions against tiles. This method is mostly used @@ -50589,10 +69110,10 @@ declare namespace Phaser { * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the * layer. Interesting faces are used internally for optimizing collisions against tiles. This method * is mostly used internally. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. */ calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50610,7 +69131,7 @@ declare namespace Phaser { * @param scene The Scene to create the Sprites within. Default scene the map is within. * @param camera The Camera to use when determining the world XY Default main camera. */ - createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: object, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; + createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; /** * Returns the tiles in the given layer that are within the cameras viewport. @@ -50623,13 +69144,13 @@ declare namespace Phaser { * Copies the tiles in the source rectangular area to a new destination (all specified in tile * coordinates) within the layer. This copies all tile properties & recalculates collision * information in the destination region. - * @param srcTileX [description] - * @param srcTileY [description] - * @param width [description] - * @param height [description] - * @param destTileX [description] - * @param destTileY [description] - * @param recalculateFaces [description] Default true. + * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. + * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. + * @param width The width of the area to copy, in tiles, not pixels. + * @param height The height of the area to copy, in tiles, not pixels. + * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. + * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ copy(srcTileX: integer, srcTileY: integer, width: integer, height: integer, destTileX: integer, destTileY: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50642,12 +69163,12 @@ declare namespace Phaser { * Sets the tiles in the given rectangular area (in tile coordinates) of the layer with the * specified index. Tiles will be set to collide if the given index is a colliding index. * Collision information in the region will be recalculated. - * @param index [description] - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param recalculateFaces [description] Default true. + * @param index The tile index to fill the area with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ fill(index: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50659,19 +69180,13 @@ declare namespace Phaser { * callback as the first and only parameter. The callback should return true for tiles that pass the * filter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. */ - filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.Tile[]; + filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.Tile[]; /** * Searches the entire map layer for the first tile matching the given index, then returns that Tile @@ -50690,49 +69205,34 @@ declare namespace Phaser { * Find the first tile in the given rectangular area (in tile coordinates) of the layer that * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns * true. Similar to Array.prototype.find in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. */ - findTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.Tile; + findTile(callback: FindTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.Tile; /** * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given * callback. Similar to Array.prototype.forEach in vanilla JS. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. */ - forEachTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.DynamicTilemapLayer; + forEachTile(callback: EachTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.DynamicTilemapLayer; /** * Gets a tile at the given tile coordinates from the given layer. * @param tileX X position to get the tile from (given in tile units, not pixels). * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param nonNull If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. Default false. + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. Default false. */ getTileAt(tileX: integer, tileY: integer, nonNull?: boolean): Phaser.Tilemaps.Tile; @@ -50740,74 +69240,55 @@ declare namespace Phaser { * Gets a tile at the given world coordinates from the given layer. * @param worldX X position to get the tile from (given in pixels) * @param worldY Y position to get the tile from (given in pixels) - * @param nonNull If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. Default false. - * @param camera [description] Default main camera. + * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. Default false. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param FilteringOptions Optional filters to apply when getting the tiles. */ - getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.Tile[]; + getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, FilteringOptions?: object): Phaser.Tilemaps.Tile[]; /** * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, * Line, Rectangle or Triangle. The shape should be in world coordinates. * @param shape A shape in world (pixel) coordinates - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param camera [description] Default main camera. + * @param FilteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, FilteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * @param worldX [description] - * @param worldY [description] - * @param width [description] - * @param height [description] - * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param camera [description] Default main camera. + * @param worldX The world x coordinate for the top-left of the area. + * @param worldY The world y coordinate for the top-left of the area. + * @param width The width of the area. + * @param height The height of the area. + * @param FilteringOptions Optional filters to apply when getting the tiles. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, FilteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns * false if there is no tile or if the tile at that location has an index of -1. - * @param tileX [description] - * @param tileY [description] + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. */ hasTileAt(tileX: integer, tileY: integer): boolean; /** * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns * false if there is no tile or if the tile at that location has an index of -1. - * @param worldX [description] - * @param worldY [description] - * @param camera [description] Default main camera. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. */ hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; @@ -50817,9 +69298,9 @@ declare namespace Phaser { * location. If you pass in an index, only the index at the specified location will be changed. * Collision information will be recalculated at the specified location. * @param tile The index of this tile to set or a Tile object. - * @param tileX [description] - * @param tileY [description] - * @param recalculateFaces [description] Default true. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ putTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; @@ -50829,12 +69310,12 @@ declare namespace Phaser { * specified location. If you pass in an index, only the index at the specified location will be * changed. Collision information will be recalculated at the specified location. * @param tile The index of this tile to set or a Tile object. - * @param worldX [description] - * @param worldY [description] - * @param recalculateFaces [description] Default true. - * @param camera [description] + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ - putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: integer, worldY: integer, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; + putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified @@ -50842,11 +69323,10 @@ declare namespace Phaser { * all attributes will be copied over to the specified location. If you pass in an index, only the * index at the specified location will be changed. Collision information will be recalculated * within the region tiles were changed. - * @param tile A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param tileX [description] - * @param tileY [description] - * @param recalculateFaces [description] Default true. + * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ putTilesAt(tile: integer[] | integer[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: integer, tileY: integer, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50856,10 +69336,10 @@ declare namespace Phaser { * those will be used for randomly assigning new tile indexes. If an array is not provided, the * indexes found within the region (excluding -1) will be used for randomly assigning new tile * indexes. This method only modifies tile indexes and does not change collision information. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param indexes An array of indexes to randomly draw from during randomization. */ randomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, indexes?: integer[]): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50867,27 +69347,23 @@ declare namespace Phaser { /** * Removes the tile at the given tile coordinates in the specified layer and updates the layer's * collision information. - * @param tile The index of this tile to set or a Tile object. - * @param tileX [description] - * @param tileY [description] - * @param replaceWithNull If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. Default true. - * @param recalculateFaces [description] Default true. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. */ - removeTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; + removeTileAt(tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.Tile; /** * Removes the tile at the given world coordinates in the specified layer and updates the layer's * collision information. - * @param tile The index of this tile to set or a Tile object. - * @param worldX [description] - * @param worldY [description] - * @param replaceWithNull If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. Default true. - * @param recalculateFaces [description] Default true. - * @param camera [description] Default main camera. + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ - removeTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; + removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to @@ -50896,37 +69372,49 @@ declare namespace Phaser { * wherever you want on the screen. * @param graphics The target Graphics object to draw upon. * @param styleConfig An object specifying the colors to use for the debug drawing. - * @param styleConfig.tileColor Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. Default blue. - * @param styleConfig.collidingTileColor Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. Default orange. - * @param styleConfig.faceColor Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. Default grey. */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: object): Phaser.Tilemaps.DynamicTilemapLayer; + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig): Phaser.Tilemaps.DynamicTilemapLayer; /** * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching * `findIndex` and updates their index to match `newIndex`. This only modifies the index and does * not change collision information. - * @param findIndex [description] - * @param newIndex [description] - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param findIndex The index of the tile to search for. + * @param newIndex The index of the tile to replace it with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. */ replaceByIndex(findIndex: integer, newIndex: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; + /** + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. + */ + setSkipCull(value?: boolean): this; + + /** + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. + * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. + */ + setCullPadding(paddingX?: integer, paddingY?: integer): this; + /** * Sets collision on the given tile or tiles within a layer by index. You can pass in either a * single numeric index or an array of indexes: [2, 3, 15, 20]. The `collides` parameter controls if * collision will be enabled (true) or disabled (false). * @param indexes Either a single tile index, or an array of tile indexes. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50937,10 +69425,8 @@ declare namespace Phaser { * enabled (true) or disabled (false). * @param start The first index of the tile to be set for collision. * @param stop The last index of the tile to be set for collision. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50952,12 +69438,9 @@ declare namespace Phaser { * has a value of true. Any tile that doesn't have "collides" set to true will be ignored. You can * also use an array of values, e.g. `{ types: ["stone", "lava", "sand" ] }`. If a tile has a * "types" property that matches any of those values, its collision flag will be updated. - * @param properties An object with tile properties and corresponding values that should - * be checked. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. + * @param properties An object with tile properties and corresponding values that should be checked. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50966,10 +69449,8 @@ declare namespace Phaser { * the given array. The `collides` parameter controls if collision will be enabled (true) or * disabled (false). * @param indexes An array of the tile indexes to not be counted for collision. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50978,10 +69459,8 @@ declare namespace Phaser { * (typically defined in Tiled within the tileset collision editor). If any objects are found within * a tiles collision group, the tile's colliding information will be set. The `collides` parameter * controls if collision will be enabled (true) or disabled (false). - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. */ setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean): Phaser.Tilemaps.DynamicTilemapLayer; @@ -50990,35 +69469,34 @@ declare namespace Phaser { * tiles on this layer that have the same index. If a callback is already set for the tile index it * will be replaced. Set the callback to null to remove it. If you want to set a callback for a tile * at a specific location on the map then see setTileLocationCallback. - * @param indexes Either a single tile index, or an array of tile indexes to have a - * collision callback set for. + * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. * @param callback The callback that will be invoked when the tile is collided with. * @param callbackContext The context under which the callback is called. */ - setTileIndexCallback(indexes: integer | any[], callback: Function, callbackContext: object): Phaser.Tilemaps.DynamicTilemapLayer; + setTileIndexCallback(indexes: integer | integer[], callback: Function, callbackContext: object): Phaser.Tilemaps.DynamicTilemapLayer; /** * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. * If a callback is already set for the tile index it will be replaced. Set the callback to null to * remove it. - * @param tileX [description] - * @param tileY [description] - * @param width [description] - * @param height [description] + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param callback The callback that will be invoked when the tile is collided with. * @param callbackContext The context under which the callback is called. */ - setTileLocationCallback(tileX: integer, tileY: integer, width: integer, height: integer, callback: Function, callbackContext?: object): Phaser.Tilemaps.DynamicTilemapLayer; + setTileLocationCallback(tileX?: integer, tileY?: integer, width?: integer, height?: integer, callback?: Function, callbackContext?: object): Phaser.Tilemaps.DynamicTilemapLayer; /** * Shuffles the tiles in a rectangular region (specified in tile coordinates) within the given * layer. It will only randomize the tiles in that area, so if they're all the same nothing will * appear to have changed! This method only modifies tile indexes and does not change collision * information. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. */ shuffle(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; @@ -51028,26 +69506,26 @@ declare namespace Phaser { * information. * @param tileA First tile index. * @param tileB Second tile index. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. */ swapByIndex(tileA: integer, tileB: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.DynamicTilemapLayer; /** * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the * layers position, scale and scroll. - * @param tileX [description] - * @param camera [description] Default main camera. + * @param tileX The x coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; /** * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the * layers position, scale and scroll. - * @param tileY [description] - * @param camera [description] Default main camera. + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; @@ -51055,10 +69533,10 @@ declare namespace Phaser { * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the * layers position, scale and scroll. This will return a new Vector2 object or update the given * `point` object. - * @param tileX [description] - * @param tileY [description] - * @param point [description] - * @param camera [description] Default main camera. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; @@ -51076,10 +69554,10 @@ declare namespace Phaser { * * The probability of any index being choose is (the index's weight) / (sum of all weights). This * method only modifies tile indexes and does not change collision information. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param weightedIndexes An array of objects to randomly draw from during * randomization. They should be in the form: { index: 0, weight: 4 } or * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. @@ -51089,20 +69567,18 @@ declare namespace Phaser { /** * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the * layers position, scale and scroll. - * @param worldX [description] - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param camera [description] Default main camera. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; /** * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the * layers position, scale and scroll. - * @param worldY [description] - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param camera [description] Default main camera. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; @@ -51110,12 +69586,11 @@ declare namespace Phaser { * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the * layers position, scale and scroll. This will return a new Vector2 object or update the given * `point` object. - * @param worldX [description] - * @param worldY [description] - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param point [description] - * @param camera [description] Default main camera. + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. Default true. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; @@ -51180,6 +69655,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -51202,6 +69678,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -51209,7 +69686,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -51217,28 +69694,50 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -51246,6 +69745,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -51444,15 +69944,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -51488,6 +69988,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -51502,6 +70007,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -51516,6 +70026,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -51644,8 +70159,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -51781,37 +70297,37 @@ declare namespace Phaser { constructor(config?: object); /** - * [description] + * The name of the layer, if specified in Tiled. */ name: string; /** - * [description] + * The x offset of where to draw from the top left */ x: number; /** - * [description] + * The y offset of where to draw from the top left */ y: number; /** - * [description] + * The width in tile of the layer. */ width: number; /** - * [description] + * The height in tiles of the layer. */ height: number; /** - * [description] + * The pixel width of the tiles. */ tileWidth: number; /** - * [description] + * The pixel height of the tiles. */ tileHeight: number; @@ -51826,12 +70342,12 @@ declare namespace Phaser { baseTileHeight: number; /** - * [description] + * The width in pixels of the entire layer. */ widthInPixels: number; /** - * [description] + * The height in pixels of the entire layer. */ heightInPixels: number; @@ -51846,7 +70362,7 @@ declare namespace Phaser { visible: boolean; /** - * [description] + * Layer specific properties (can be specified in Tiled) */ properties: object; @@ -51871,9 +70387,9 @@ declare namespace Phaser { bodies: any[]; /** - * [description] + * An array of the tile indexes */ - data: any[]; + data: number[]; /** * [description] @@ -51892,40 +70408,40 @@ declare namespace Phaser { * * @param config [description] */ - constructor(config?: object); + constructor(config?: MapDataConfig); /** - * [description] + * The key in the Phaser cache that corresponds to the loaded tilemap data. */ name: string; /** - * [description] + * The width of the entire tilemap. */ width: number; /** - * [description] + * The height of the entire tilemap. */ height: number; /** - * [description] + * The width of the tiles. */ tileWidth: number; /** - * [description] + * The height of the tiles. */ tileHeight: number; /** - * [description] + * The width in pixels of the entire tilemap. */ widthInPixels: number; /** - * [description] + * The height in pixels of the entire tilemap. */ heightInPixels: number; @@ -51935,47 +70451,57 @@ declare namespace Phaser { format: integer; /** - * [description] + * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. */ orientation: string; /** - * [description] + * Determines the draw order of tilemap. Default is right-down + * + * 0, or 'right-down' + * 1, or 'left-down' + * 2, or 'right-up' + * 3, or 'left-up' + */ + renderOrder: string; + + /** + * The version of the map data (as specified in Tiled). */ version: string; /** - * [description] + * Map specific properties (can be specified in Tiled) */ properties: object; /** - * [description] + * An array with all the layers configured to the MapData. */ - layers: any[]; + layers: Phaser.Tilemaps.LayerData[] | Phaser.Tilemaps.ObjectLayer; /** - * [description] + * An array of Tiled Image Layers. */ images: any[]; /** - * [description] + * An object of Tiled Object Layers. */ objects: object; /** - * [description] + * An object of collision data. Must be created as physics object or will return undefined. */ collision: object; /** - * [description] + * An array of Tilesets. */ - tilesets: any[]; + tilesets: Phaser.Tilemaps.Tileset[]; /** - * [description] + * The collection of images the map uses(specified in Tiled) */ imageCollections: any[]; @@ -51997,42 +70523,50 @@ declare namespace Phaser { class ObjectLayer { /** * - * @param config [description] + * @param config The data for the layer from the Tiled JSON object. */ constructor(config?: object); /** - * [description] + * The name of the Object Layer. */ name: string; /** - * [description] + * The opacity of the layer, between 0 and 1. */ opacity: number; /** - * [description] + * The custom properties defined on the Object Layer, keyed by their name. */ properties: object; /** - * [description] + * The type of each custom property defined on the Object Layer, keyed by its name. */ propertyTypes: object; /** - * [description] + * The type of the layer, which should be `objectgroup`. */ type: string; /** - * [description] + * Whether the layer is shown (`true`) or hidden (`false`). */ visible: boolean; /** - * [description] + * An array of all objects on this Object Layer. + * + * Each Tiled object corresponds to a JavaScript object in this array. It has an `id` (unique), `name` (as assigned in Tiled), `type` (as assigned in Tiled), `rotation` (in clockwise degrees), `properties` (if any), `visible` state (`true` if visible, `false` otherwise), `x` and `y` coordinates (in pixels, relative to the tilemap), and a `width` and `height` (in pixels). + * + * An object tile has a `gid` property (GID of the represented tile), a `flippedHorizontal` property, a `flippedVertical` property, and `flippedAntiDiagonal` property. The {@link http://docs.mapeditor.org/en/latest/reference/tmx-map-format/|Tiled documentation} contains information on flipping and rotation. + * + * Polylines have a `polyline` property, which is an array of objects corresponding to points, where each point has an `x` property and a `y` property. Polygons have an identically structured array in their `polygon` property. Text objects have a `text` property with the text's properties. + * + * Rectangles and ellipses have a `rectangle` or `ellipse` property set to `true`. */ objects: Phaser.GameObjects.GameObject[]; @@ -52127,8 +70661,8 @@ declare namespace Phaser { function AssignTileProperties(mapData: Phaser.Tilemaps.MapData): void; /** - * [description] - * @param data [description] + * Decode base-64 encoded data, for example as exported by Tiled. + * @param data Base-64 encoded data to decode. */ function Base64Decode(data: object): any[]; @@ -52165,16 +70699,16 @@ declare namespace Phaser { function ParseJSONTiled(name: string, json: object, insertNull: boolean): Phaser.Tilemaps.MapData; /** - * [description] - * @param tiledObject [description] - * @param offsetX [description] Default 0. - * @param offsetY [description] Default 0. + * Convert a Tiled object to an internal parsed object normalising and copying properties over, while applying optional x and y offsets. The parsed object will always have the properties `id`, `name`, `type`, `rotation`, `properties`, `visible`, `x`, `y`, `width` and `height`. Other properties will be added according to the object type (such as text, polyline, gid etc.) + * @param tiledObject Tiled object to convert to an internal parsed object normalising and copying properties over. + * @param offsetX Optional additional offset to apply to the object's x property. Defaults to 0. Default 0. + * @param offsetY Optional additional offset to apply to the object's y property. Defaults to 0. Default 0. */ function ParseObject(tiledObject: object, offsetX?: number, offsetY?: number): object; /** - * [description] - * @param json [description] + * Parses a Tiled JSON object into an array of ObjectLayer objects. + * @param json The Tiled JSON object. */ function ParseObjectLayers(json: object): any[]; @@ -52192,9 +70726,9 @@ declare namespace Phaser { function ParseTilesets(json: object): object; /** - * [description] - * @param object [description] - * @param keys [description] + * Returns a new object that only contains the `keys` that were found on the object provided. If no `keys` are found, an empty object is returned. + * @param object The object to pick the provided keys from. + * @param keys An array of properties to retrieve from the provided object. */ function Pick(object: object, keys: any[]): object; @@ -52225,24 +70759,25 @@ declare namespace Phaser { function ParseToTilemap(scene: Phaser.Scene, key?: string, tileWidth?: integer, tileHeight?: integer, width?: integer, height?: integer, data?: integer[][], insertNull?: boolean): Phaser.Tilemaps.Tilemap; /** - * A StaticTilemapLayer is a game object that renders LayerData from a Tilemap. A - * StaticTilemapLayer can only render tiles from a single tileset. + * A Static Tilemap Layer is a Game Object that renders LayerData from a Tilemap when used in combination + * with one, or more, Tilesets. * - * A StaticTilemapLayer is optimized for speed over flexibility. You cannot apply per-tile - * effects like tint or alpha. You cannot change the tiles in a StaticTilemapLayer. Use this - * over a DynamicTilemapLayer when you don't need either of those features. + * A Static Tilemap Layer is optimized for rendering speed over flexibility. You cannot apply per-tile + * effects like tint or alpha, or change the tiles or tilesets the layer uses. + * + * Use a Static Tilemap Layer instead of a Dynamic Tilemap Layer when you don't need tile manipulation features. */ class StaticTilemapLayer extends Phaser.GameObjects.GameObject implements Phaser.GameObjects.Components.Alpha, Phaser.GameObjects.Components.BlendMode, Phaser.GameObjects.Components.ComputedSize, Phaser.GameObjects.Components.Depth, Phaser.GameObjects.Components.Flip, Phaser.GameObjects.Components.GetBounds, Phaser.GameObjects.Components.Origin, Phaser.GameObjects.Components.Pipeline, Phaser.GameObjects.Components.ScaleMode, Phaser.GameObjects.Components.Transform, Phaser.GameObjects.Components.Visible, Phaser.GameObjects.Components.ScrollFactor { /** * - * @param scene [description] + * @param scene The Scene to which this Game Object belongs. * @param tilemap The Tilemap this layer is a part of. * @param layerIndex The index of the LayerData associated with this layer. - * @param tileset The tileset used to render the tiles in this layer. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. * @param x The world x position where the top left of this layer will be placed. Default 0. * @param y The world y position where the top left of this layer will be placed. Default 0. */ - constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: Phaser.Tilemaps.Tileset, x?: number, y?: number); + constructor(scene: Phaser.Scene, tilemap: Phaser.Tilemaps.Tilemap, layerIndex: integer, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number); /** * Used internally by physics system to perform fast type checks. @@ -52266,21 +70801,112 @@ declare namespace Phaser { layer: Phaser.Tilemaps.LayerData; /** - * The Tileset associated with this layer. A tilemap layer can only render from one Tileset. + * The Tileset/s associated with this layer. + * + * As of Phaser 3.14 this property is now an array of Tileset objects, previously it was a single reference. */ - tileset: Phaser.Tilemaps.Tileset; + tileset: Phaser.Tilemaps.Tileset[]; /** - * Used internally with the canvas render. This holds the tiles that are visible within the - * camera. + * Used internally by the Canvas renderer. + * This holds the tiles that are visible within the camera in the last frame. */ culledTiles: any[]; + /** + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this, and toggling this flag allows + * you to do so. Also see `setSkipCull` for a chainable method that does the same thing. + */ + skipCull: boolean; + + /** + * Canvas only. + * + * The total number of tiles drawn by the renderer in the last frame. + * + * This only works when rending with Canvas. + */ + readonly tilesDrawn: integer; + + /** + * Canvas only. + * + * The total number of tiles in this layer. Updated every frame. + */ + readonly tilesTotal: integer; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its horizontal size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingX: integer; + + /** + * Canvas only. + * + * The amount of extra tiles to add into the cull rectangle when calculating its vertical size. + * + * See the method `setCullPadding` for more details. + */ + cullPaddingY: integer; + + /** + * Canvas only. + * + * The callback that is invoked when the tiles are culled. + * + * By default it will call `TilemapComponents.CullTiles` but you can override this to call any function you like. + * + * It will be sent 3 arguments: + * + * 1. The Phaser.Tilemaps.LayerData object for this Layer + * 2. The Camera that is culling the layer. You can check its `dirty` property to see if it has changed since the last cull. + * 3. A reference to the `culledTiles` array, which should be used to store the tiles you want rendered. + * + * See the `TilemapComponents.CullTiles` source code for details on implementing your own culling system. + */ + cullCallback: Function; + + /** + * An array holding the mapping between the tile indexes and the tileset they belong to. + */ + gidMap: Phaser.Tilemaps.Tileset[]; + /** * Upload the tile data to a VBO. * @param camera The camera to render to. + * @param tilesetIndex The tileset index. */ - upload(camera: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.StaticTilemapLayer; + upload(camera: Phaser.Cameras.Scene2D.Camera, tilesetIndex: integer): Phaser.Tilemaps.StaticTilemapLayer; + + /** + * Sets the rendering (draw) order of the tiles in this layer. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + */ + setRenderOrder(renderOrder: integer | string): this; /** * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting @@ -52295,10 +70921,10 @@ declare namespace Phaser { * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the * layer. Interesting faces are used internally for optimizing collisions against tiles. This method * is mostly used internally. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. */ calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer): Phaser.Tilemaps.StaticTilemapLayer; @@ -52316,7 +70942,7 @@ declare namespace Phaser { * @param scene The Scene to create the Sprites within. Default scene the map is within. * @param camera The Camera to use when determining the world XY Default main camera. */ - createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: object, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; + createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.GameObjects.Sprite[]; /** * Returns the tiles in the given layer that are within the cameras viewport. @@ -52326,9 +70952,28 @@ declare namespace Phaser { cull(camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** - * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + * Canvas only. + * + * You can control if the Cameras should cull tiles before rendering them or not. + * By default the camera will try to cull the tiles in this layer, to avoid over-drawing to the renderer. + * + * However, there are some instances when you may wish to disable this. + * @param value Set to `true` to stop culling tiles. Set to `false` to enable culling again. Default true. */ - destroy(): void; + setSkipCull(value?: boolean): this; + + /** + * Canvas only. + * + * When a Camera culls the tiles in this layer it does so using its view into the world, building up a + * rectangle inside which the tiles must exist or they will be culled. Sometimes you may need to expand the size + * of this 'cull rectangle', especially if you plan on rotating the Camera viewing the layer. Do so + * by providing the padding values. The values given are in tiles, not pixels. So if the tile width was 32px + * and you set `paddingX` to be 4, it would add 32px x 4 to the cull rectangle (adjusted for scale) + * @param paddingX The amount of extra horizontal tiles to add to the cull check padding. Default 1. + * @param paddingY The amount of extra vertical tiles to add to the cull check padding. Default 1. + */ + setCullPadding(paddingX?: integer, paddingY?: integer): this; /** * Searches the entire map layer for the first tile matching the given index, then returns that Tile @@ -52350,19 +70995,13 @@ declare namespace Phaser { * @param callback The callback. Each tile in the given area will be passed to this * callback as the first and only parameter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. */ - findTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.Tile; + findTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile; /** * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given @@ -52372,19 +71011,13 @@ declare namespace Phaser { * callback as the first and only parameter. The callback should return true for tiles that pass the * filter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. */ - filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.Tile[]; + filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile[]; /** * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given @@ -52392,19 +71025,13 @@ declare namespace Phaser { * @param callback The callback. Each tile in the given area will be passed to this * callback as the first and only parameter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. */ - forEachTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.StaticTilemapLayer; + forEachTile(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.StaticTilemapLayer; /** * Gets a tile at the given tile coordinates from the given layer. @@ -52421,72 +71048,54 @@ declare namespace Phaser { * @param worldY Y position to get the tile from (given in pixels) * @param nonNull If true, function won't return null for empty tiles, but a Tile * object with an index of -1. Default false. - * @param camera [description] Default main camera. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile; /** * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. */ - getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object): Phaser.Tilemaps.Tile[]; + getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions): Phaser.Tilemaps.Tile[]; /** * Gets the tiles in the given rectangular area (in world coordinates) of the layer. - * @param worldX [description] - * @param worldY [description] - * @param width [description] - * @param height [description] + * @param worldX The leftmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param worldY The topmost tile index (in tile coordinates) to use as the origin of the area to filter. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles high from the `tileY` index the area will be. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param camera [description] Default main camera. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, * Line, Rectangle or Triangle. The shape should be in world coordinates. * @param shape A shape in world (pixel) coordinates * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param camera [description] Default main camera. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Tilemaps.Tile[]; /** * Checks if there is a tile at the given location (in tile coordinates) in the given layer. Returns * false if there is no tile or if the tile at that location has an index of -1. - * @param tileX [description] - * @param tileY [description] + * @param tileX X position to get the tile from in tile coordinates. + * @param tileY Y position to get the tile from in tile coordinates. */ hasTileAt(tileX: integer, tileY: integer): boolean; /** * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns * false if there is no tile or if the tile at that location has an index of -1. - * @param worldX [description] - * @param worldY [description] - * @param camera [description] Default main camera. + * @param worldX The X coordinate of the world position. + * @param worldY The Y coordinate of the world position. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera): boolean; @@ -52497,14 +71106,8 @@ declare namespace Phaser { * wherever you want on the screen. * @param graphics The target Graphics object to draw upon. * @param styleConfig An object specifying the colors to use for the debug drawing. - * @param styleConfig.tileColor Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. Default blue. - * @param styleConfig.collidingTileColor Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. Default orange. - * @param styleConfig.faceColor Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. Default grey. */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: object): Phaser.Tilemaps.StaticTilemapLayer; + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig): Phaser.Tilemaps.StaticTilemapLayer; /** * Sets collision on the given tile or tiles within a layer by index. You can pass in either a @@ -52589,10 +71192,10 @@ declare namespace Phaser { * Sets a collision callback for the given rectangular area (in tile coordinates) within the layer. * If a callback is already set for the tile index it will be replaced. Set the callback to null to * remove it. - * @param tileX [description] - * @param tileY [description] - * @param width [description] - * @param height [description] + * @param tileX The leftmost tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The topmost tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. * @param callback The callback that will be invoked when the tile is collided with. * @param callbackContext The context under which the callback is called. */ @@ -52601,16 +71204,16 @@ declare namespace Phaser { /** * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the * layers position, scale and scroll. - * @param tileX [description] - * @param camera [description] Default main camera. + * @param tileX The X coordinate, in tile coordinates. + * @param camera The Camera to use when calculating the world values from the tile index. Default main camera. */ tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; /** * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the * layers position, scale and scroll. - * @param tileY [description] - * @param camera [description] Default main camera. + * @param tileY The Y coordinate, in tile coordinates. + * @param camera The Camera to use when calculating the world values from the tile index. Default main camera. */ tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera): number; @@ -52618,30 +71221,30 @@ declare namespace Phaser { * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the * layers position, scale and scroll. This will return a new Vector2 object or update the given * `point` object. - * @param tileX [description] - * @param tileY [description] - * @param point [description] - * @param camera [description] Default main camera. + * @param tileX The X coordinate, in tile coordinates. + * @param tileY The Y coordinate, in tile coordinates. + * @param point A Vector2 to store the coordinates in. If not given, a new Vector2 is created. + * @param camera The Camera to use when calculating the world values from the tile index. Default main camera. */ tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; /** * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the * layers position, scale and scroll. - * @param worldX [description] + * @param worldX The X coordinate, in world pixels. * @param snapToFloor Whether or not to round the tile coordinate down to the * nearest integer. Default true. - * @param camera [description] Default main camera. + * @param camera The Camera to use when calculating the tile index from the world values.] Default main camera. */ worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; /** * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the * layers position, scale and scroll. - * @param worldY [description] + * @param worldY The Y coordinate, in world pixels. * @param snapToFloor Whether or not to round the tile coordinate down to the * nearest integer. Default true. - * @param camera [description] Default main camera. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera): number; @@ -52649,15 +71252,20 @@ declare namespace Phaser { * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the * layers position, scale and scroll. This will return a new Vector2 object or update the given * `point` object. - * @param worldX [description] - * @param worldY [description] + * @param worldX The X coordinate, in world pixels. + * @param worldY The Y coordinate, in world pixels. * @param snapToFloor Whether or not to round the tile coordinate down to the * nearest integer. Default true. - * @param point [description] - * @param camera [description] Default main camera. + * @param point A Vector2 to store the coordinates in. If not given, a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. */ worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera): Phaser.Math.Vector2; + /** + * Destroys this StaticTilemapLayer and removes its link to the associated LayerData. + */ + destroy(): void; + /** * Clears all alpha values associated with this Game Object. * @@ -52719,6 +71327,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE * * Canvas has more available depending on browser support. * @@ -52741,6 +71350,7 @@ declare namespace Phaser { * * ADD * * MULTIPLY * * SCREEN + * * ERASE (only works when rendering to a framebuffer, like a Render Texture) * * Canvas has more available depending on browser support. * @@ -52748,7 +71358,7 @@ declare namespace Phaser { * * Blend modes have different effects under Canvas and WebGL, and from browser to browser, depending * on support. Blend Modes also cause a WebGL batch flush should it encounter a new blend mode. For these - * reasons try to be careful about the construction of your Scene and the frequency of which blend modes + * reasons try to be careful about the construction of your Scene and the frequency in which blend modes * are used. * @param value The BlendMode value. Either a string or a CONST. */ @@ -52756,28 +71366,50 @@ declare namespace Phaser { /** * The native (un-scaled) width of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayWidth` property. */ width: number; /** * The native (un-scaled) height of this Game Object. + * + * Changing this value will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or use + * the `displayHeight` property. */ height: number; /** * The displayed width of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayWidth: number; /** * The displayed height of this Game Object. + * * This value takes into account the scale factor. + * + * Setting this value will adjust the Game Object's scale property. */ displayHeight: number; /** - * Sets the size of this Game Object. + * Sets the internal size of this Game Object, as used for frame or physics body creation. + * + * This will not change the size that the Game Object is rendered in-game. + * For that you need to either set the scale of the Game Object (`setScale`) or call the + * `setDisplaySize` method, which is the same thing as changing the scale but allows you + * to do so by giving pixel values. + * + * If you have enabled this Game Object for input, changing the size will _not_ change the + * size of the hit area. To do this you should adjust the `input.hitArea` object directly. * @param width The width of this Game Object. * @param height The height of this Game Object. */ @@ -52785,6 +71417,7 @@ declare namespace Phaser { /** * Sets the display size of this Game Object. + * * Calling this will adjust the scale. * @param width The width of this Game Object. * @param height The height of this Game Object. @@ -52983,15 +71616,15 @@ declare namespace Phaser { /** * Sets the initial WebGL Pipeline of this Game Object. * This should only be called during the instantiation of the Game Object. - * @param pipelineName The name of the pipeline to set on this Game Object. + * @param pipelineName The name of the pipeline to set on this Game Object. Defaults to the Texture Tint Pipeline. Default TextureTintPipeline. */ - initPipeline(pipelineName: string): boolean; + initPipeline(pipelineName?: string): boolean; /** * Sets the active WebGL Pipeline of this Game Object. * @param pipelineName The name of the pipeline to set on this Game Object. */ - setPipeline(pipelineName: string): boolean; + setPipeline(pipelineName: string): this; /** * Resets the WebGL Pipeline of this Game Object back to the default it was created with. @@ -53139,8 +71772,9 @@ declare namespace Phaser { /** * Gets the world transform matrix for this Game Object, factoring in any parent Containers. * @param tempMatrix The matrix to populate with the values from this Game Object. + * @param parentMatrix A temporary matrix to hold parent values during the calculations. */ - getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; + getWorldTransformMatrix(tempMatrix?: Phaser.GameObjects.Components.TransformMatrix, parentMatrix?: Phaser.GameObjects.Components.TransformMatrix): Phaser.GameObjects.Components.TransformMatrix; /** * The visible state of the Game Object. @@ -53168,6 +71802,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorX: number; @@ -53182,6 +71821,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. */ scrollFactorY: number; @@ -53196,6 +71840,11 @@ declare namespace Phaser { * A value of 1 means it will move exactly in sync with a camera. * A value of 0 means it will not move at all, even if the camera moves. * Other values control the degree to which the camera movement is mapped to this Game Object. + * + * Please be aware that scroll factor values other than 1 are not taken in to consideration when + * calculating physics collisions. Bodies always collide based on their world position, but changing + * the scroll factor is a visual adjustment to where the textures are rendered, which can offset + * them from physics bodies if not accounted for in your code. * @param x The horizontal scroll factor of this Game Object. * @param y The vertical scroll factor of this Game Object. If not set it will use the `x` value. Default x. */ @@ -53516,8 +72165,9 @@ declare namespace Phaser { readonly hasInterestingFace: boolean; /** - * The tileset that contains this Tile. This will only return null if accessed from a LayerData - * instance before the tile is placed within a StaticTilemapLayer or DynamicTilemapLayer. + * The tileset that contains this Tile. This is null if accessed from a LayerData instance + * before the tile is placed in a StaticTilemapLayer or DynamicTilemapLayer, or if the tile has + * an index that doesn't correspond to any of the map's tilesets. */ readonly tileset: Phaser.Tilemaps.Tileset; @@ -53704,6 +72354,20 @@ declare namespace Phaser { */ orientation: string; + /** + * The render (draw) order of the map data (as specified in Tiled), usually 'right-down'. + * + * The draw orders are: + * + * right-down + * left-down + * right-up + * left-up + * + * This can be changed via the `setRenderOrder` method. + */ + renderOrder: string; + /** * The format of the map data. */ @@ -53756,6 +72420,31 @@ declare namespace Phaser { */ currentLayerIndex: integer; + /** + * Sets the rendering (draw) order of the tiles in this map. + * + * The default is 'right-down', meaning it will order the tiles starting from the top-left, + * drawing to the right and then moving down to the next row. + * + * The draw orders are: + * + * 0 = right-down + * 1 = left-down + * 2 = right-up + * 3 = left-up + * + * Setting the render order does not change the tiles or how they are stored in the layer, + * it purely impacts the order in which they are rendered. + * + * You can provide either an integer (0 to 3), or the string version of the order. + * + * Calling this method _after_ creating Static or Dynamic Tilemap Layers will **not** automatically + * update them to use the new render order. If you call this method after creating layers, use their + * own `setRenderOrder` methods to change them as needed. + * @param renderOrder The render (draw) order value. Either an integer between 0 and 3, or a string: 'right-down', 'left-down', 'right-up' or 'left-up'. + */ + setRenderOrder(renderOrder: integer | string): this; + /** * Adds an image to the map to be used as a tileset. A single map may use multiple tilesets. * Note that the tileset name can be found in the JSON file exported from Tiled, or in the Tiled @@ -53790,26 +72479,34 @@ declare namespace Phaser { convertLayerToStatic(layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer): Phaser.Tilemaps.StaticTilemapLayer; /** - * See component documentation. If no layer specified, the map's current layer is used. This - * cannot be applied to StaticTilemapLayers. + * Copies the tiles in the source rectangular area to a new destination (all specified in tile + * coordinates) within the layer. This copies all tile properties & recalculates collision + * information in the destination region. + * + * If no layer specified, the map's current layer is used. This cannot be applied to StaticTilemapLayers. + * @param srcTileX The x coordinate of the area to copy from, in tiles, not pixels. + * @param srcTileY The y coordinate of the area to copy from, in tiles, not pixels. + * @param width The width of the area to copy, in tiles, not pixels. + * @param height The height of the area to copy, in tiles, not pixels. + * @param destTileX The x coordinate of the area to copy to, in tiles, not pixels. + * @param destTileY The y coordinate of the area to copy to, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - copy(): Phaser.Tilemaps.Tilemap; + copy(srcTileX: integer, srcTileY: integer, width: integer, height: integer, destTileX: integer, destTileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** - * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set - * to this new layer. + * Creates a new and empty DynamicTilemapLayer. The currently selected layer in the map is set to this new layer. * @param name The name of this layer. Must be unique within the map. - * @param tileset The tileset the new layer will use. - * @param width The width of the layer in tiles. If not specified, it will default - * to the map's width. - * @param height The height of the layer in tiles. If not specified, it will default - * to the map's height. - * @param tileWidth The width of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileWidth. - * @param tileHeight The height of the tiles the layer uses for calculations. If not - * specified, it will default to the map's tileHeight. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The world x position where the top left of this layer will be placed. Default 0. + * @param y The world y position where the top left of this layer will be placed. Default 0. + * @param width The width of the layer in tiles. If not specified, it will default to the map's width. + * @param height The height of the layer in tiles. If not specified, it will default to the map's height. + * @param tileWidth The width of the tiles the layer uses for calculations. If not specified, it will default to the map's tileWidth. + * @param tileHeight The height of the tiles the layer uses for calculations. If not specified, it will default to the map's tileHeight. */ - createBlankDynamicLayer(name: string, tileset: Phaser.Tilemaps.Tileset, width: integer, height: integer, tileWidth: integer, tileHeight: integer): Phaser.Tilemaps.DynamicTilemapLayer; + createBlankDynamicLayer(name: string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number, width?: integer, height?: integer, tileWidth?: integer, tileHeight?: integer): Phaser.Tilemaps.DynamicTilemapLayer; /** * Creates a new DynamicTilemapLayer that renders the LayerData associated with the given @@ -53821,21 +72518,21 @@ declare namespace Phaser { * * Unlike a static layer, a dynamic layer can be modified. See DynamicTilemapLayer for more * information. - * @param layerID The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param tileset The tileset the new layer will use. - * @param x The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param y The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. + * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. + * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. */ - createDynamicLayer(layerID: integer | string, tileset: Phaser.Tilemaps.Tileset, x: number, y: number): Phaser.Tilemaps.DynamicTilemapLayer; + createDynamicLayer(layerID: integer | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x: number, y: number): Phaser.Tilemaps.DynamicTilemapLayer; /** * Creates a Sprite for every object matching the given gid in the map data. All properties from * the map data objectgroup are copied into the `spriteConfig`, so you can use this as an easy * way to configure Sprite properties from within the map editor. For example giving an object a * property of alpha: 0.5 in the map editor will duplicate that when the Sprite is created. + * + * Custom object properties not sharing names with the Sprite's own properties are copied to the + * Sprite's {@link Phaser.GameObjects.Sprite#data data store}. * @param name The name of the object layer (from Tiled) to create Sprites from. * @param id Either the id (object), gid (tile object) or name (object or * tile object) from Tiled. Ids are unique in Tiled, but a gid is shared by all tile objects @@ -53844,7 +72541,7 @@ declare namespace Phaser { * scene.make.sprite). * @param scene The Scene to create the Sprites within. Default the scene the map is within. */ - createFromObjects(name: string, id: integer | string, spriteConfig: object, scene?: Phaser.Scene): Phaser.GameObjects.Sprite[]; + createFromObjects(name: string, id: integer | string, spriteConfig: SpriteConfig, scene?: Phaser.Scene): Phaser.GameObjects.Sprite[]; /** * Creates a Sprite for every object matching the given tile indexes in the layer. You can @@ -53855,13 +72552,12 @@ declare namespace Phaser { * @param replacements The tile index, or array of indexes, to change a converted * tile to. Set to `null` to leave the tiles unchanged. If an array is given, it is assumed to be a * one-to-one mapping with the indexes array. - * @param spriteConfig The config object to pass into the Sprite creator (i.e. - * scene.make.sprite). + * @param spriteConfig The config object to pass into the Sprite creator (i.e. scene.make.sprite). * @param scene The Scene to create the Sprites within. Default scene the map is within. - * @param camera The Camera to use when determining the world XY Default main camera. - * @param layer [description] + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: object, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.GameObjects.Sprite[]; + createFromTiles(indexes: integer | any[], replacements: integer | any[], spriteConfig: SpriteConfig, scene?: Phaser.Scene, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.GameObjects.Sprite[]; /** * Creates a new StaticTilemapLayer that renders the LayerData associated with the given @@ -53873,15 +72569,12 @@ declare namespace Phaser { * * It's important to remember that a static layer cannot be modified. See StaticTilemapLayer for * more information. - * @param layerID The layer array index value, or if a string is given, the - * layer name from Tiled. - * @param tileset The tileset the new layer will use. - * @param x The x position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. - * @param y The y position to place the layer in the world. If not specified, it will - * default to the layer offset from Tiled or 0. + * @param layerID The layer array index value, or if a string is given, the layer name from Tiled. + * @param tileset The tileset, or an array of tilesets, used to render this layer. Can be a string or a Tileset object. + * @param x The x position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. + * @param y The y position to place the layer in the world. If not specified, it will default to the layer offset from Tiled or 0. Default 0. */ - createStaticLayer(layerID: integer | string, tileset: Phaser.Tilemaps.Tileset, x: number, y: number): Phaser.Tilemaps.StaticTilemapLayer; + createStaticLayer(layerID: integer | string, tileset: string | string[] | Phaser.Tilemaps.Tileset | Phaser.Tilemaps.Tileset[], x?: number, y?: number): Phaser.Tilemaps.StaticTilemapLayer; /** * Removes all layer data from this Tilemap and nulls the scene reference. This will destroy any @@ -53896,15 +72589,15 @@ declare namespace Phaser { * * If no layer specified, the map's current layer is used. * This cannot be applied to StaticTilemapLayers. - * @param index [description] - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param recalculateFaces [description] Default true. - * @param layer [description] + * @param index The tile index to fill the area with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - fill(index: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + fill(index: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * For each object in the given object layer, run the given filter callback function. Any @@ -53925,20 +72618,14 @@ declare namespace Phaser { * callback as the first and only parameter. The callback should return true for tiles that pass the * filter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to filter. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param layer [description] + * @param layer The tile layer to use. If not given the current layer is used. */ - filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + filterTiles(callback: Function, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; /** * Searches the entire map layer for the first tile matching the given index, then returns that Tile @@ -53949,11 +72636,10 @@ declare namespace Phaser { * If no layer specified, the map's current layer is used. * @param index The tile index value to search for. * @param skip The number of times to skip a matching tile before returning. Default 0. - * @param reverse If true it will scan the layer in reverse, starting at the - * bottom-right. Otherwise it scans from the top-left. Default false. - * @param layer [description] + * @param reverse If true it will scan the layer in reverse, starting at the bottom-right. Otherwise it scans from the top-left. Default false. + * @param layer The tile layer to use. If not given the current layer is used. */ - findByIndex(index: integer, skip?: integer, reverse?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + findByIndex(index: integer, skip?: integer, reverse?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * Find the first object in the given object layer that satisfies the provided testing function. @@ -53970,46 +72656,32 @@ declare namespace Phaser { * satisfies the provided testing function. I.e. finds the first tile for which `callback` returns * true. Similar to Array.prototype.find in vanilla JS. * If no layer specified, the maps current layer is used. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param layer [description] + * @param layer The Tile layer to run the search on. If not provided will use the current layer. */ - findTile(callback: FindTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + findTile(callback: FindTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * For each tile in the given rectangular area (in tile coordinates) of the layer, run the given * callback. Similar to Array.prototype.forEach in vanilla JS. * * If no layer specified, the map's current layer is used. - * @param callback The callback. Each tile in the given area will be passed to this - * callback as the first and only parameter. + * @param callback The callback. Each tile in the given area will be passed to this callback as the first and only parameter. * @param context The context under which the callback should be run. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area to search. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide - * on at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param layer [description] + * @param layer The Tile layer to run the search on. If not provided will use the current layer. */ - forEachTile(callback: EachTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object, layer?: LayerData): Phaser.Tilemaps.Tilemap; + forEachTile(callback: EachTileCallback, context?: object, tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Gets the image layer index based on its name. @@ -54062,41 +72734,33 @@ declare namespace Phaser { * If no layer specified, the map's current layer is used. * @param tileX X position to get the tile from (given in tile units, not pixels). * @param tileY Y position to get the tile from (given in tile units, not pixels). - * @param nonNull If true getTile won't return null for empty tiles, but a Tile - * object with an index of -1. Default false. - * @param layer [description] + * @param nonNull If true getTile won't return null for empty tiles, but a Tile object with an index of -1. Default false. + * @param layer The tile layer to use. If not given the current layer is used. */ - getTileAt(tileX: integer, tileY: integer, nonNull?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + getTileAt(tileX: integer, tileY: integer, nonNull?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * Gets a tile at the given world coordinates from the given layer. * If no layer specified, the map's current layer is used. * @param worldX X position to get the tile from (given in pixels) * @param worldY Y position to get the tile from (given in pixels) - * @param nonNull If true, function won't return null for empty tiles, but a Tile - * object with an index of -1. Default false. - * @param camera [description] Default main camera. - * @param layer [description] + * @param nonNull If true, function won't return null for empty tiles, but a Tile object with an index of -1. Default false. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + getTileAtWorldXY(worldX: number, worldY: number, nonNull?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * Gets the tiles in the given rectangular area (in tile coordinates) of the layer. * If no layer specified, the maps current layer is used. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param layer [description] + * @param layer The tile layer to use. If not given the current layer is used. */ - getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: object, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + getTilesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, filteringOptions?: FilteringOptions, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; /** * Gets the tiles that overlap with the given shape in the given layer. The shape must be a Circle, @@ -54104,35 +72768,29 @@ declare namespace Phaser { * If no layer specified, the maps current layer is used. * @param shape A shape in world (pixel) coordinates * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param camera [description] Default main camera. - * @param layer [description] + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + getTilesWithinShape(shape: Phaser.Geom.Circle | Phaser.Geom.Line | Phaser.Geom.Rectangle | Phaser.Geom.Triangle, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; /** * Gets the tiles in the given rectangular area (in world coordinates) of the layer. * If no layer specified, the maps current layer is used. - * @param worldX [description] - * @param worldY [description] - * @param width [description] - * @param height [description] + * @param worldX The world x coordinate for the top-left of the area. + * @param worldY The world y coordinate for the top-left of the area. + * @param width The width of the area. + * @param height The height of the area. * @param filteringOptions Optional filters to apply when getting the tiles. - * @param filteringOptions.isNotEmpty If true, only return tiles that don't have - * -1 for an index. Default false. - * @param filteringOptions.isColliding If true, only return tiles that collide on - * at least one side. Default false. - * @param filteringOptions.hasInterestingFace If true, only return tiles that - * have at least one interesting face. Default false. - * @param camera [description] Default main camera. - * @param layer [description] + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: object, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile[]; + getTilesWithinWorldXY(worldX: number, worldY: number, width: number, height: number, filteringOptions?: FilteringOptions, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile[]; + + /** + * Gets the Tileset that has the given `name`, or null if an invalid `name` is given. + * @param name The name of the Tileset to get. + */ + getTileset(name: string): Phaser.Tilemaps.Tileset; /** * Gets the index of the Tileset within this.tilesets that has the given `name`, or null if an @@ -54146,23 +72804,23 @@ declare namespace Phaser { * false if there is no tile or if the tile at that location has an index of -1. * * If no layer specified, the map's current layer is used. - * @param tileX [description] - * @param tileY [description] - * @param layer [description] + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The tile layer to use. If not given the current layer is used. */ - hasTileAt(tileX: integer, tileY: integer, layer?: Phaser.Tilemaps.LayerData): boolean; + hasTileAt(tileX: integer, tileY: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): boolean; /** * Checks if there is a tile at the given location (in world coordinates) in the given layer. Returns * false if there is no tile or if the tile at that location has an index of -1. * * If no layer specified, the maps current layer is used. - * @param worldX [description] - * @param worldY [description] - * @param camera [description] Default main camera. - * @param layer [description] + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param camera The Camera to use when factoring in which tiles to return. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): boolean; + hasTileAtWorldXY(worldX: number, worldY: number, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): boolean; /** * The LayerData object that is currently selected in the map. You can set this property using @@ -54180,12 +72838,12 @@ declare namespace Phaser { * * This cannot be applied to StaticTilemapLayers. * @param tile The index of this tile to set or a Tile object. - * @param tileX [description] - * @param tileY [description] - * @param recalculateFaces [description] Default true. - * @param layer [description] + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - putTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + putTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * Puts a tile at the given world coordinates (pixels) in the specified layer. You can pass in either @@ -54196,13 +72854,13 @@ declare namespace Phaser { * If no layer specified, the maps current layer is used. This * cannot be applied to StaticTilemapLayers. * @param tile The index of this tile to set or a Tile object. - * @param worldX [description] - * @param worldY [description] - * @param recalculateFaces [description] Default true. - * @param camera [description] Default main camera. - * @param layer [description] + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: integer, worldY: integer, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + putTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * Puts an array of tiles or a 2D array of tiles at the given tile coordinates in the specified @@ -54213,14 +72871,13 @@ declare namespace Phaser { * * If no layer specified, the maps current layer is used. * This cannot be applied to StaticTilemapLayers. - * @param tile A row (array) or grid (2D array) of Tiles - * or tile indexes to place. - * @param tileX [description] - * @param tileY [description] - * @param recalculateFaces [description] Default true. - * @param layer [description] + * @param tile A row (array) or grid (2D array) of Tiles or tile indexes to place. + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - putTilesAt(tile: integer[] | integer[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + putTilesAt(tile: integer[] | integer[][] | Phaser.Tilemaps.Tile[] | Phaser.Tilemaps.Tile[][], tileX: integer, tileY: integer, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the @@ -54231,14 +72888,14 @@ declare namespace Phaser { * * If no layer specified, the maps current layer is used. * This cannot be applied to StaticTilemapLayers. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param indexes An array of indexes to randomly draw from during randomization. - * @param layer [description] + * @param layer The tile layer to use. If not given the current layer is used. */ - randomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, indexes?: integer[], layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + randomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, indexes?: integer[], layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Calculates interesting faces at the given tile coordinates of the specified layer. Interesting @@ -54246,11 +72903,11 @@ declare namespace Phaser { * internally to optimize recalculating faces when only one tile has been changed. * * If no layer specified, the maps current layer is used. - * @param tileX [description] - * @param tileY [description] - * @param layer [description] + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param layer The tile layer to use. If not given the current layer is used. */ - calculateFacesAt(tileX: integer, tileY: integer, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + calculateFacesAt(tileX: integer, tileY: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Calculates interesting faces within the rectangular area specified (in tile coordinates) of the @@ -54258,13 +72915,13 @@ declare namespace Phaser { * is mostly used internally. * * If no layer specified, the map's current layer is used. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param layer [description] + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. */ - calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + calculateFacesWithin(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Removes all layers from this Tilemap and destroys any associated StaticTilemapLayers or @@ -54278,15 +72935,13 @@ declare namespace Phaser { * * If no layer specified, the maps current layer is used. * This cannot be applied to StaticTilemapLayers. - * @param tile The index of this tile to set or a Tile object. - * @param tileX [description] - * @param tileY [description] - * @param replaceWithNull If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. Default true. - * @param recalculateFaces [description] Default true. - * @param layer [description] + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - removeTileAt(tile: integer | Phaser.Tilemaps.Tile, tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + removeTileAt(tileX: integer, tileY: integer, replaceWithNull?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * Removes the tile at the given world coordinates in the specified layer and updates the layer's @@ -54294,16 +72949,14 @@ declare namespace Phaser { * * If no layer specified, the maps current layer is used. * This cannot be applied to StaticTilemapLayers. - * @param tile The index of this tile to set or a Tile object. - * @param worldX [description] - * @param worldY [description] - * @param replaceWithNull If true, this will replace the tile at the specified - * location with null instead of a Tile with an index of -1. Default true. - * @param recalculateFaces [description] Default true. - * @param camera [description] Default main camera. - * @param layer [description] + * @param worldX The x coordinate, in pixels. + * @param worldY The y coordinate, in pixels. + * @param replaceWithNull If true, this will replace the tile at the specified location with null instead of a Tile with an index of -1. Default true. + * @param recalculateFaces `true` if the faces data should be recalculated. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - removeTileAtWorldXY(tile: integer | Phaser.Tilemaps.Tile, worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tile; + removeTileAtWorldXY(worldX: number, worldY: number, replaceWithNull?: boolean, recalculateFaces?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tile; /** * Draws a debug representation of the layer to the given Graphics. This is helpful when you want to @@ -54314,15 +72967,9 @@ declare namespace Phaser { * If no layer specified, the maps current layer is used. * @param graphics The target Graphics object to draw upon. * @param styleConfig An object specifying the colors to use for the debug drawing. - * @param styleConfig.tileColor Color to use for drawing a filled rectangle at - * non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. Default blue. - * @param styleConfig.collidingTileColor Color to use for drawing a filled - * rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. Default orange. - * @param styleConfig.faceColor Color to use for drawing a line at interesting - * tile faces. If set to null, interesting tile faces will not be drawn. Default grey. - * @param layer [description] + * @param layer The tile layer to use. If not given the current layer is used. */ - renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: object, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + renderDebug(graphics: Phaser.GameObjects.Graphics, styleConfig: StyleConfig, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching @@ -54331,15 +72978,15 @@ declare namespace Phaser { * * If no layer specified, the maps current layer is used. * This cannot be applied to StaticTilemapLayers. - * @param findIndex [description] - * @param newIndex [description] - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param layer [description] + * @param findIndex The index of the tile to search for. + * @param newIndex The index of the tile to replace it with. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. */ - replaceByIndex(findIndex: integer, newIndex: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + replaceByIndex(findIndex: integer, newIndex: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets collision on the given tile or tiles within a layer by index. You can pass in either a @@ -54348,13 +72995,11 @@ declare namespace Phaser { * * If no layer specified, the map's current layer is used. * @param indexes Either a single tile index, or an array of tile indexes. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - * @param layer [description] + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + setCollision(indexes: integer | any[], collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets collision on a range of tiles in a layer whose index is between the specified `start` and @@ -54365,13 +73010,11 @@ declare namespace Phaser { * If no layer specified, the map's current layer is used. * @param start The first index of the tile to be set for collision. * @param stop The last index of the tile to be set for collision. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - * @param layer [description] + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + setCollisionBetween(start: integer, stop: integer, collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets collision on the tiles within a layer by checking tile properties. If a tile has a property @@ -54383,15 +73026,12 @@ declare namespace Phaser { * "types" property that matches any of those values, its collision flag will be updated. * * If no layer specified, the map's current layer is used. - * @param properties An object with tile properties and corresponding values that should - * be checked. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - * @param layer [description] + * @param properties An object with tile properties and corresponding values that should be checked. + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + setCollisionByProperty(properties: object, collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets collision on all tiles in the given layer, except for tiles that have an index specified in @@ -54400,13 +73040,11 @@ declare namespace Phaser { * * If no layer specified, the map's current layer is used. * @param indexes An array of the tile indexes to not be counted for collision. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - * @param layer [description] + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + setCollisionByExclusion(indexes: integer[], collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets collision on the tiles within a layer by checking each tile's collision group data @@ -54415,13 +73053,11 @@ declare namespace Phaser { * controls if collision will be enabled (true) or disabled (false). * * If no layer specified, the map's current layer is used. - * @param collides If true it will enable collision. If false it will clear - * collision. Default true. - * @param recalculateFaces Whether or not to recalculate the tile faces after the - * update. Default true. - * @param layer [description] + * @param collides If true it will enable collision. If false it will clear collision. Default true. + * @param recalculateFaces Whether or not to recalculate the tile faces after the update. Default true. + * @param layer The tile layer to use. If not given the current layer is used. */ - setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + setCollisionFromCollisionGroup(collides?: boolean, recalculateFaces?: boolean, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets a global collision callback for the given tile index within the layer. This will affect all @@ -54430,13 +73066,12 @@ declare namespace Phaser { * at a specific location on the map then see setTileLocationCallback. * * If no layer specified, the map's current layer is used. - * @param indexes Either a single tile index, or an array of tile indexes to have a - * collision callback set for. + * @param indexes Either a single tile index, or an array of tile indexes to have a collision callback set for. * @param callback The callback that will be invoked when the tile is collided with. * @param callbackContext The context under which the callback is called. - * @param layer [description] + * @param layer The tile layer to use. If not given the current layer is used. */ - setTileIndexCallback(indexes: integer | any[], callback: Function, callbackContext: object, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + setTileIndexCallback(indexes: integer | any[], callback: Function, callbackContext: object, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets a collision callback for the given rectangular area (in tile coordindates) within the layer. @@ -54444,15 +73079,15 @@ declare namespace Phaser { * remove it. * * If no layer specified, the map's current layer is used. - * @param tileX [description] - * @param tileY [description] - * @param width [description] - * @param height [description] + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. + * @param width How many tiles wide from the `tileX` index the area will be. + * @param height How many tiles tall from the `tileY` index the area will be. * @param callback The callback that will be invoked when the tile is collided with. * @param callbackContext The context under which the callback is called. - * @param layer [description] + * @param layer The tile layer to use. If not given the current layer is used. */ - setTileLocationCallback(tileX: integer, tileY: integer, width: integer, height: integer, callback: Function, callbackContext?: object, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + setTileLocationCallback(tileX: integer, tileY: integer, width: integer, height: integer, callback: Function, callbackContext?: object, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Sets the current layer to the LayerData associated with `layer`. @@ -54490,13 +73125,13 @@ declare namespace Phaser { * * If no layer specified, the maps current layer is used. * This cannot be applied to StaticTilemapLayers. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param layer [description] + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. */ - shuffle(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + shuffle(tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Scans the given rectangular area (given in tile coordinates) for tiles with an index matching @@ -54507,35 +73142,36 @@ declare namespace Phaser { * This cannot be applied to StaticTilemapLayers. * @param tileA First tile index. * @param tileB Second tile index. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. - * @param layer [description] + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. + * @param layer The tile layer to use. If not given the current layer is used. */ - swapByIndex(tileA: integer, tileB: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + swapByIndex(tileA: integer, tileB: integer, tileX?: integer, tileY?: integer, width?: integer, height?: integer, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Converts from tile X coordinates (tile units) to world X coordinates (pixels), factoring in the * layers position, scale and scroll. * * If no layer specified, the maps current layer is used. - * @param tileX [description] - * @param camera [description] Default main camera. - * @param layer [description] + * @param tileX The x coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): number; + tileToWorldX(tileX: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; /** * Converts from tile Y coordinates (tile units) to world Y coordinates (pixels), factoring in the * layers position, scale and scroll. * * If no layer specified, the maps current layer is used. - * @param tileY [description] - * @param camera [description] Default main camera. - * @param layer [description] + * @param tileY The y coordinate, in tiles, not pixels. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer + * to use. If not given the current layer is used. */ - tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): number; + tileToWorldY(tileY: integer, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; /** * Converts from tile XY coordinates (tile units) to world XY coordinates (pixels), factoring in the @@ -54543,13 +73179,13 @@ declare namespace Phaser { * `point` object. * * If no layer specified, the maps current layer is used. - * @param tileX [description] - * @param tileY [description] - * @param point [description] - * @param camera [description] Default main camera. - * @param layer [description] + * @param tileX The x coordinate, in tiles, not pixels. + * @param tileY The y coordinate, in tiles, not pixels. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + tileToWorldXY(tileX: integer, tileY: integer, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Math.Vector2; /** * Randomizes the indexes of a rectangular region of tiles (in tile coordinates) within the @@ -54568,42 +73204,41 @@ declare namespace Phaser { * * If no layer specified, the map's current layer is used. This * cannot be applied to StaticTilemapLayers. - * @param tileX [description] Default 0. - * @param tileY [description] Default 0. - * @param width [description] Default max width based on tileX. - * @param height [description] Default max height based on tileY. + * @param tileX The left most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param tileY The top most tile index (in tile coordinates) to use as the origin of the area. Default 0. + * @param width How many tiles wide from the `tileX` index the area will be. Default max width based on tileX. + * @param height How many tiles tall from the `tileY` index the area will be. Default max height based on tileY. * @param weightedIndexes An array of objects to randomly draw from during * randomization. They should be in the form: { index: 0, weight: 4 } or * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. - * @param layer [description] + * @param layer The tile layer to use. If not given the current layer is used. */ - weightedRandomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, weightedIndexes?: object[], layer?: Phaser.Tilemaps.LayerData): Phaser.Tilemaps.Tilemap; + weightedRandomize(tileX?: integer, tileY?: integer, width?: integer, height?: integer, weightedIndexes?: object[], layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Tilemaps.Tilemap; /** * Converts from world X coordinates (pixels) to tile X coordinates (tile units), factoring in the * layers position, scale and scroll. * * If no layer specified, the maps current layer is used. - * @param worldX [description] - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param camera [description] Default main camera. - * @param layer [description] + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer + * to use. If not given the current layer is used. */ - worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): number; + worldToTileX(worldX: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; /** * Converts from world Y coordinates (pixels) to tile Y coordinates (tile units), factoring in the * layers position, scale and scroll. * * If no layer specified, the maps current layer is used. - * @param worldY [description] - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param camera [description] Default main camera. - * @param layer [description] + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. Default true. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): number; + worldToTileY(worldY: number, snapToFloor?: boolean, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): number; /** * Converts from world XY coordinates (pixels) to tile XY coordinates (tile units), factoring in the @@ -54611,15 +73246,14 @@ declare namespace Phaser { * `point` object. * * If no layer specified, the maps current layer is used. - * @param worldX [description] - * @param worldY [description] - * @param snapToFloor Whether or not to round the tile coordinate down to the - * nearest integer. Default true. - * @param point [description] - * @param camera [description] Default main camera. - * @param layer [description] + * @param worldX The x coordinate to be converted, in pixels, not tiles. + * @param worldY The y coordinate to be converted, in pixels, not tiles. + * @param snapToFloor Whether or not to round the tile coordinate down to the nearest integer. Default true. + * @param point A Vector2 to store the coordinates in. If not given a new Vector2 is created. + * @param camera The Camera to use when calculating the tile index from the world values. Default main camera. + * @param layer The tile layer to use. If not given the current layer is used. */ - worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: Phaser.Tilemaps.LayerData): Phaser.Math.Vector2; + worldToTileXY(worldX: number, worldY: number, snapToFloor?: boolean, point?: Phaser.Math.Vector2, camera?: Phaser.Cameras.Scene2D.Camera, layer?: string | integer | Phaser.Tilemaps.DynamicTilemapLayer | Phaser.Tilemaps.StaticTilemapLayer): Phaser.Math.Vector2; } @@ -54690,6 +73324,11 @@ declare namespace Phaser { */ readonly image: Phaser.Textures.Texture; + /** + * The gl texture used by the WebGL renderer. + */ + readonly glTexture: WebGLTexture; + /** * The number of tile rows in the the tileset. */ @@ -54779,88 +73418,98 @@ declare namespace Phaser { namespace Time { /** - * [description] + * The Clock is a Scene plugin which creates and updates Timer Events for its Scene. */ class Clock { /** * - * @param scene [description] + * @param scene The Scene which owns this Clock. */ constructor(scene: Phaser.Scene); /** - * [description] + * The Scene which owns this Clock. */ scene: Phaser.Scene; /** - * [description] + * The Scene Systems object of the Scene which owns this Clock. */ systems: Phaser.Scenes.Systems; /** - * [description] + * The current time of the Clock, in milliseconds. + * + * If accessed externally, this is equivalent to the `time` parameter normally passed to a Scene's `update` method. */ now: number; /** - * [description] + * The scale of the Clock's time delta. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Clock and anything which uses it, such as its Timer Events. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing the Clock. */ timeScale: number; /** - * [description] + * Whether the Clock is paused (`true`) or active (`false`). + * + * When paused, the Clock will not update any of its Timer Events, thus freezing time. */ paused: boolean; /** - * [description] - * @param config [description] + * Creates a Timer Event and adds it to the Clock at the start of the frame. + * @param config The configuration for the Timer Event. */ addEvent(config: TimerEventConfig): Phaser.Time.TimerEvent; /** - * [description] - * @param delay [description] - * @param callback [description] - * @param args [description] - * @param callbackScope [description] + * Creates a Timer Event and adds it to the Clock at the start of the frame. + * + * This is a shortcut for {@link #addEvent} which can be shorter and is compatible with the syntax of the GreenSock Animation Platform (GSAP). + * @param delay The delay of the function call, in milliseconds. + * @param callback The function to call after the delay expires. + * @param args The arguments to call the function with. + * @param callbackScope The scope (`this` object) to call the function with. */ delayedCall(delay: number, callback: Function, args: any[], callbackScope: any): Phaser.Time.TimerEvent; /** - * [description] + * Clears and recreates the array of pending Timer Events. */ clearPendingEvents(): Phaser.Time.Clock; /** - * [description] + * Schedules all active Timer Events for removal at the start of the frame. */ removeAllEvents(): Phaser.Time.Clock; /** - * [description] - * @param time [description] - * @param delta [description] + * Updates the arrays of active and pending Timer Events. Called at the start of the frame. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ preUpdate(time: number, delta: number): void; /** - * [description] - * @param time [description] - * @param delta [description] + * Updates the Clock's internal time and all of its Timer Events. + * @param time The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(time: number, delta: number): void; } /** - * [description] + * A Timer Event represents a delayed function call. It's managed by a Scene's {@link Clock} and will call its function after a set amount of time has passed. The Timer Event can optionally repeat - i.e. call its function multiple times before finishing, or loop indefinitely. + * + * Because it's managed by a Clock, a Timer Event is based on game time, will be affected by its Clock's time scale, and will pause if its Clock pauses. */ class TimerEvent { /** * - * @param config [description] + * @param config The configuration for the Timer Event, including its delay and callback. */ constructor(config: TimerEventConfig); @@ -54910,23 +73559,27 @@ declare namespace Phaser { startAt: number; /** - * [description] + * The time in milliseconds which has elapsed since the Timer Event's creation. + * + * This value is local for the Timer Event and is relative to its Clock. As such, it's influenced by the Clock's time scale and paused state, the Timer Event's initial {@link #startAt} property, and the Timer Event's {@link #timeScale} and {@link #paused} state. */ elapsed: number; /** - * [description] + * Whether or not this timer is paused. */ paused: boolean; /** - * [description] + * Whether the Timer Event's function has been called. + * + * When the Timer Event fires, this property will be set to `true` before the callback function is invoked and will be reset immediately afterward if the Timer Event should repeat. The value of this property does not directly influence whether the Timer Event will be removed from its Clock, but can prevent it from firing. */ hasDispatched: boolean; /** - * [description] - * @param config [description] + * Completely reinitializes the Timer Event, regardless of its current state, according to a configuration object. + * @param config The new state for the Timer Event. */ reset(config: TimerEventConfig): Phaser.Time.TimerEvent; @@ -54941,28 +73594,32 @@ declare namespace Phaser { getOverallProgress(): number; /** - * [description] + * Returns the number of times this Timer Event will repeat before finishing. + * + * This should not be confused with the number of times the Timer Event will fire before finishing. A return value of 0 doesn't indicate that the Timer Event has finished running - it indicates that it will not repeat after the next time it fires. */ getRepeatCount(): number; /** - * [description] + * Returns the local elapsed time for the current iteration of the Timer Event. */ getElapsed(): number; /** - * [description] + * Returns the local elapsed time for the current iteration of the Timer Event in seconds. */ getElapsedSeconds(): number; /** - * [description] - * @param dispatchCallback [description] + * Forces the Timer Event to immediately expire, thus scheduling its removal in the next frame. + * @param dispatchCallback If `true` (by default `false`), the function of the Timer Event will be called before its removal from its Clock. */ - remove(dispatchCallback: Function): void; + remove(dispatchCallback?: boolean): void; /** - * [description] + * Destroys all object references in the Timer Event, i.e. its callback, scope, and arguments. + * + * Normally, this method is only called by the Clock when it shuts down. As such, it doesn't stop the Timer Event. If called manually, the Timer Event will still be updated by the Clock, but it won't do anything when it fires. */ destroy(): void; @@ -54973,10 +73630,10 @@ declare namespace Phaser { namespace Tweens { namespace Builders { /** - * [description] - * @param source [description] - * @param key [description] - * @param defaultValue [description] + * Retrieves the value of the given key from an object. + * @param source The object to retrieve the value from. + * @param key The key to look for in the `source` object. + * @param defaultValue The default value to return if the `key` doesn't exist or if no `source` object is provided. */ function GetBoolean(source: object, key: string, defaultValue: any): any; @@ -54997,26 +73654,30 @@ declare namespace Phaser { /** * [description] - * @param config [description] + * @param config The configuration object of the tween to get the target(s) from. */ function GetProps(config: object): any[]; /** - * [description] - * @param config [description] + * Extracts an array of targets from a Tween configuration object. + * + * The targets will be looked for in a `targets` property. If it's a function, its return value will be used as the result. + * @param config The configuration object to use. */ function GetTargets(config: object): any[]; /** - * [description] + * Returns an array of all tweens in the given config * @param config [description] */ function GetTweens(config: object): any[]; /** - * [description] - * @param key [description] - * @param propertyValue [description] + * Returns `getStart` and `getEnd` functions for a Tween's Data based on a target property and end value. + * + * If the end value is a number, it will be treated as an absolute value and the property will be tweened to it. A string can be provided to specify a relative end value which consists of an operation (`+=` to add to the current value, `-=` to subtract from the current value, `*=` to multiply the current value, or `/=` to divide the current value) followed by its operand. A function can be provided to allow greater control over the end value; it will receive the target object being tweened, the name of the property being tweened, and the current value of the property as its arguments. If both the starting and the ending values need to be controlled, an object with `getStart` and `getEnd` callbacks, which will receive the same arguments, can be provided instead. If an object with a `value` property is provided, the property will be used as the effective value under the same rules described here. + * @param key The name of the property to modify. + * @param propertyValue The ending value of the property, as described above. */ function GetValueOp(key: string, propertyValue: any): Function; @@ -55029,9 +73690,38 @@ declare namespace Phaser { function NumberTweenBuilder(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, config: object, defaults: Phaser.Tweens.TweenConfigDefaults): Phaser.Tweens.Tween; /** - * [description] - * @param manager [description] - * @param config [description] + * Builds a Timeline of Tweens based on a configuration object. + * + * The configuration object (`config`) can have the following properties: + * + * `tweens` - an array of tween configuration objects to create and add into the new Timeline, as described by `TweenBuilder`. If this doesn't exist or is empty, the Timeline will start off paused and none of the other configuration settings will be read. If it's a function, it will be called and its return value will be used as the array. + * `targets` - an array (or function which returns one) of default targets to which to apply the Timeline. Each individual Tween configuration can override this value. + * `totalDuration` - if specified, each Tween in the Timeline will get an equal portion of this duration, usually in milliseconds, by default. Each individual Tween configuration can override the Tween's duration. + * `duration` - if `totalDuration` is not specified, the default duration, usually in milliseconds, of each Tween which will be created. Each individual Tween configuration can override the Tween's duration. + * `delay`, `easeParams`, `ease`, `hold`, `repeat`, `repeatDelay`, `yoyo`, `flipX`, `flipY` - the default settings for each Tween which will be created, as specified by `TweenBuilder`. Each individual Tween configuration can override any of these values. + * `completeDelay` - if specified, the time to wait, usually in milliseconds, before the Timeline completes. + * `loop` - how many times the Timeline should loop, or -1 to loop indefinitely. + * `loopDelay` - the time, usually in milliseconds, between each loop + * `paused` - if `true`, the Timeline will start paused + * `useFrames` - if `true`, all duration in the Timeline will be in frames instead of milliseconds + * `callbackScope` - the default scope (`this` value) to use for each callback registered by the Timeline Builder. If not specified, the Timeline itself will be used. + * `onStart` - if specified, the `onStart` callback for the Timeline, called every time it starts playing + * `onStartScope` - the scope (`this` value) to use for the `onStart` callback. If not specified, the `callbackScope` will be used. + * `onStartParams` - additional arguments to pass to the `onStart` callback. The Timeline will always be the first argument. + * `onUpdate` - if specified, the `onUpdate` callback for the Timeline, called every frame it's active, regardless of its Tweens + * `onUpdateScope` - the scope (`this` value) to use for the `onUpdate` callback. If not specified, the `callbackScope` will be used. + * `onUpdateParams` - additional arguments to pass to the `onUpdate` callback. The Timeline will always be the first argument. + * `onLoop` - if specified, the `onLoop` callback for the Timeline, called every time it loops + * `onLoopScope` - the scope (`this` value) to use for the `onLoop` callback. If not specified, the `callbackScope` will be used. + * `onLoopParams` - additional arguments to pass to the `onLoop` callback. The Timeline will always be the first argument. + * `onYoyo` - if specified, the `onYoyo` callback for the Timeline, called every time it yoyos + * `onYoyoScope` - the scope (`this` value) to use for the `onYoyo` callback. If not specified, the `callbackScope` will be used. + * `onYoyoParams` - additional arguments to pass to the `onYoyo` callback. The first argument will always be `null`, while the Timeline will always be the second argument. + * `onComplete` - if specified, the `onComplete` callback for the Timeline, called after it completes + * `onCompleteScope` - the scope (`this` value) to use for the `onComplete` callback. If not specified, the `callbackScope` will be used. + * `onCompleteParams` - additional arguments to pass to the `onComplete` callback. The Timeline will always be the first argument. + * @param manager The Tween Manager to which the Timeline will belong. + * @param config The configuration object for the Timeline, as described above. */ function TimelineBuilder(manager: Phaser.Tweens.TweenManager, config: object): Phaser.Tweens.Timeline; @@ -55039,29 +73729,159 @@ declare namespace Phaser { * [description] * @param parent [description] * @param config [description] - * @param defaults [description] + * @param defaults Tween configuration defaults. + * ` */ function TweenBuilder(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, config: object, defaults: Phaser.Tweens.TweenConfigDefaults): Phaser.Tweens.Tween; } + namespace Events { + /** + * The Timeline Complete Event. + * + * This event is dispatched by a Tween Timeline when it completes playback. + * + * Listen to it from a Timeline instance using `Timeline.on('complete', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('complete', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_COMPLETE: any; + + /** + * The Timeline Loop Event. + * + * This event is dispatched by a Tween Timeline every time it loops. + * + * Listen to it from a Timeline instance using `Timeline.on('loop', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * loop: 4, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('loop', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_LOOP: any; + + /** + * The Timeline Pause Event. + * + * This event is dispatched by a Tween Timeline when it is paused. + * + * Listen to it from a Timeline instance using `Timeline.on('pause', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('pause', listener); + * // At some point later ... + * timeline.pause(); + * ``` + */ + const TIMELINE_PAUSE: any; + + /** + * The Timeline Resume Event. + * + * This event is dispatched by a Tween Timeline when it is resumed from a paused state. + * + * Listen to it from a Timeline instance using `Timeline.on('resume', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('resume', listener); + * // At some point later ... + * timeline.resume(); + * ``` + */ + const TIMELINE_RESUME: any; + + /** + * The Timeline Start Event. + * + * This event is dispatched by a Tween Timeline when it starts. + * + * Listen to it from a Timeline instance using `Timeline.on('start', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('start', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_START: any; + + /** + * The Timeline Update Event. + * + * This event is dispatched by a Tween Timeline every time it updates, which can happen a lot of times per second, + * so be careful about listening to this event unless you absolutely require it. + * + * Listen to it from a Timeline instance using `Timeline.on('update', listener)`, i.e.: + * + * ```javascript + * var timeline = this.tweens.timeline({ + * targets: image, + * ease: 'Power1', + * duration: 3000, + * tweens: [ { x: 600 }, { y: 500 }, { x: 100 }, { y: 100 } ] + * }); + * timeline.on('update', listener); + * timeline.play(); + * ``` + */ + const TIMELINE_UPDATE: any; + + } + /** - * [description] + * A Timeline combines multiple Tweens into one. Its overall behavior is otherwise similar to a single Tween. + * + * The Timeline updates all of its Tweens simultaneously. Its methods allow you to easily build a sequence of Tweens (each one starting after the previous one) or run multiple Tweens at once during given parts of the Timeline. */ class Timeline extends Phaser.Events.EventEmitter { /** * - * @param manager [description] + * @param manager The Tween Manager which owns this Timeline. */ constructor(manager: Phaser.Tweens.TweenManager); /** - * [description] + * The Tween Manager which owns this Timeline. */ manager: Phaser.Tweens.TweenManager; /** - * [description] + * A constant value which allows this Timeline to be easily identified as one. */ isTimeline: boolean; @@ -55153,18 +73973,19 @@ declare namespace Phaser { totalProgress: number; /** - * [description] - * @param value [description] + * Sets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * Value isn't used when calculating total duration of the tween, it's a run-time delta adjustment only. + * @param value The time scale value to set. */ setTimeScale(value: number): Phaser.Tweens.Timeline; /** - * [description] + * Gets the value of the time scale applied to this Timeline. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. */ getTimeScale(): number; /** - * [description] + * Check whether or not the Timeline is playing. */ isPlaying(): boolean; @@ -55187,46 +74008,46 @@ declare namespace Phaser { hasOffset(tween: Phaser.Tweens.Tween): boolean; /** - * [description] - * @param value [description] + * Checks whether the offset value is a number or a directive that is relative to previous tweens. + * @param value The offset value to be evaluated */ isOffsetAbsolute(value: number): boolean; /** - * [description] - * @param value [description] + * Checks if the offset is a relative value rather than an absolute one. If the value is just a number, this returns false. + * @param value The offset value to be evaluated */ isOffsetRelative(value: string): boolean; /** - * [description] - * @param value [description] - * @param base [description] + * Parses the relative offset value, returning a positive or negative number. + * @param value The relative offset, in the format of '-=500', for example. The first character determines whether it will be a positive or negative number. Spacing matters here. + * @param base The value to use as the offset. */ getRelativeOffset(value: string, base: number): number; /** - * [description] + * Calculates the total duration of the timeline. Computes all tween's durations and returns the full duration of the timeline. The resulting number is stored in the timeline, not as a return value. */ calcDuration(): void; /** - * [description] + * Initializes the timeline, which means all Tweens get their init() called, and the total duration will be computed. Returns a boolean indicating whether the timeline is auto-started or not. */ init(): boolean; /** - * [description] - * @param resetFromLoop [description] + * Resets all of the timeline's tweens back to their initial states. The boolean parameter indicates whether tweens that are looping should reset as well, or not. + * @param resetFromLoop If true, resets all looping tweens to their initial values. */ resetTweens(resetFromLoop: boolean): void; /** - * [description] - * @param type [description] - * @param callback [description] - * @param params [description] - * @param scope [description] + * Sets a callback for the Timeline. + * @param type The internal type of callback to set. + * @param callback Timeline allows multiple tweens to be linked together to create a streaming sequence. + * @param params The parameters to pass to the callback. + * @param scope The context scope of the callback. */ setCallback(type: string, callback: Function, params?: any[], scope?: object): Phaser.Tweens.Timeline; @@ -55237,7 +74058,7 @@ declare namespace Phaser { makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; /** - * [description] + * Starts playing the timeline. */ play(): void; @@ -55250,7 +74071,7 @@ declare namespace Phaser { * Returns 'true' if this Timeline has finished and should be removed from the Tween Manager. * Otherwise, returns false. * @param timestamp [description] - * @param delta [description] + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(timestamp: number, delta: number): boolean; @@ -55260,23 +74081,23 @@ declare namespace Phaser { stop(): void; /** - * [description] + * Pauses the timeline, retaining its internal state. */ pause(): Phaser.Tweens.Timeline; /** - * [description] + * Resumes the timeline from where it was when it was paused. */ resume(): Phaser.Tweens.Timeline; /** - * [description] - * @param target [description] + * Checks if any of the tweens has the target as the object they are operating on. Retuns false if no tweens operate on the target object. + * @param target The target to check all tweens against. */ hasTarget(target: object): boolean; /** - * [description] + * Stops all the Tweens in the Timeline immediately, whatever stage of progress they are at and flags them for removal by the TweenManager. */ destroy(): void; @@ -55369,65 +74190,68 @@ declare namespace Phaser { type TweenConfigDefaults = { /** - * [description] + * The object, or an array of objects, to run the tween on. */ targets: object | object[]; /** - * [description] + * The number of milliseconds to delay before the tween will start. */ delay?: number; /** - * [description] + * The duration of the tween in milliseconds. */ duration?: number; /** - * [description] + * The easing equation to use for the tween. */ ease?: string; /** - * [description] + * Optional easing parameters. */ easeParams?: any[]; /** - * [description] + * The number of milliseconds to hold the tween for before yoyo'ing. */ hold?: number; /** - * [description] + * The number of times to repeat the tween. */ repeat?: number; /** - * [description] + * The number of milliseconds to pause before a tween will repeat. */ repeatDelay?: number; /** - * [description] + * Should the tween complete, then reverse the values incrementally to get back to the starting tween values? The reverse tweening will also take `duration` milliseconds to complete. */ yoyo?: boolean; /** - * [description] + * Horizontally flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipX` property. */ flipX?: boolean; /** - * [description] + * Vertically flip the target of the Tween when it completes (before it yoyos, if set to do so). Only works for targets that support the `flipY` property. */ flipY?: boolean; }; /** - * [description] + * A Tween is able to manipulate the properties of one or more objects to any given value, based + * on a duration and type of ease. They are rarely instantiated directly and instead should be + * created via the TweenManager. */ class Tween { /** * - * @param parent [description] - * @param data [description] - * @param targets [description] + * @param parent A reference to the parent of this Tween. Either the Tween Manager or a Tween Timeline instance. + * @param data An array of TweenData objects, each containing a unique property to be tweened. + * @param targets An array of targets to be tweened. */ constructor(parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline, data: Phaser.Tweens.TweenDataConfig[], targets: any[]); /** - * [description] + * A reference to the parent of this Tween. + * Either the Tween Manager or a Tween Timeline instance. */ parent: Phaser.Tweens.TweenManager | Phaser.Tweens.Timeline; @@ -55442,12 +74266,12 @@ declare namespace Phaser { data: Phaser.Tweens.TweenDataConfig[]; /** - * data array doesn't change, so we can cache the length + * The cached length of the data array. */ totalData: integer; /** - * An array of references to the target/s this Tween is operating on + * An array of references to the target/s this Tween is operating on. */ targets: object[]; @@ -55457,7 +74281,7 @@ declare namespace Phaser { totalTargets: integer; /** - * If true then duration, delay, etc values are all frame totals. + * If `true` then duration, delay, etc values are all frame totals. */ useFrames: boolean; @@ -55469,7 +74293,7 @@ declare namespace Phaser { /** * Loop this tween? Can be -1 for an infinite loop, or an integer. - * When enabled it will play through ALL TweenDatas again (use TweenData.repeat to loop a single TD) + * When enabled it will play through ALL TweenDatas again. Use TweenData.repeat to loop a single element. */ loop: number; @@ -55549,52 +74373,55 @@ declare namespace Phaser { callbacks: object; /** - * [description] + * Returns the current value of the Tween. */ getValue(): number; /** - * [description] - * @param value [description] + * Set the scale the time applied to this Tween. A value of 1 runs in real-time. A value of 0.5 runs 50% slower, and so on. + * @param value The scale factor for timescale. */ - setTimeScale(value: number): Phaser.Tweens.Tween; + setTimeScale(value: number): this; /** - * [description] + * Returns the scale of the time applied to this Tween. */ getTimeScale(): number; /** - * [description] + * Checks if the Tween is currently active. */ isPlaying(): boolean; /** - * [description] + * Checks if the Tween is currently paused. */ isPaused(): boolean; /** - * [description] - * @param target [description] + * See if this Tween is currently acting upon the given target. + * @param target The target to check against this Tween. */ hasTarget(target: object): boolean; /** - * [description] - * @param key [description] - * @param value [description] - * @param startToCurrent [description] + * Updates the value of a property of this Tween to a new value, without adjusting the + * Tween duration or current progress. + * + * You can optionally tell it to set the 'start' value to be the current value (before the change). + * @param key The property to set the new value for. + * @param value The new value of the property. + * @param startToCurrent Should this change set the start value to be the current value? Default false. */ - updateTo(key: string, value: any, startToCurrent: boolean): Phaser.Tweens.Tween; + updateTo(key: string, value: any, startToCurrent?: boolean): this; /** - * [description] + * Restarts the tween from the beginning. */ - restart(): void; + restart(): this; /** - * [description] + * Internal method that calculates the overall duration of the Tween. */ calcDuration(): void; @@ -55605,46 +74432,48 @@ declare namespace Phaser { init(): boolean; /** - * [description] + * Internal method that advances to the next state of the Tween during playback. */ nextState(): void; /** - * [description] + * Pauses the Tween immediately. Use `resume` to continue playback. */ - pause(): Phaser.Tweens.Tween; + pause(): this; /** - * [description] - * @param resetFromTimeline [description] + * Starts a Tween playing. + * + * You only need to call this method if you have configured the tween to be paused on creation. + * @param resetFromTimeline Is this Tween being played as part of a Timeline? */ - play(resetFromTimeline: boolean): void; + play(resetFromTimeline: boolean): this; /** - * [description] - * @param resetFromLoop [description] + * Internal method that resets all of the Tween Data, including the progress and elapsed values. + * @param resetFromLoop Has this method been called as part of a loop? */ resetTweenData(resetFromLoop: boolean): void; /** - * [description] + * Resumes the playback of a previously paused Tween. */ - resume(): Phaser.Tweens.Tween; + resume(): this; /** - * [description] - * @param toPosition A value between 0 and 1. + * Attempts to seek to a specific position in a Tween. + * @param toPosition A value between 0 and 1 which represents the progress point to seek to. */ - seek(toPosition: number): void; + seek(toPosition: number): this; /** - * [description] - * @param type [description] - * @param callback [description] - * @param params [description] - * @param scope [description] + * Sets an event based callback to be invoked during playback. + * @param type Type of the callback. + * @param callback Callback function. + * @param params An array of parameters for specified callbacks types. + * @param scope The context the callback will be invoked in. */ - setCallback(type: string, callback: Function, params?: any[], scope?: object): Phaser.Tweens.Tween; + setCallback(type: string, callback: Function, params?: any[], scope?: object): this; /** * Flags the Tween as being complete, whatever stage of progress it is at. @@ -55655,41 +74484,41 @@ declare namespace Phaser { * If you don't need a delay, or have an onComplete callback, then call `Tween.stop` instead. * @param delay The time to wait before invoking the complete callback. If zero it will fire immediately. Default 0. */ - complete(delay?: number): void; + complete(delay?: number): this; /** * Stops the Tween immediately, whatever stage of progress it is at and flags it for removal by the TweenManager. * @param resetTo A value between 0 and 1. */ - stop(resetTo?: number): void; + stop(resetTo?: number): this; /** - * [description] - * @param timestamp [description] - * @param delta [description] + * Internal method that advances the Tween based on the time values. + * @param timestamp The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(timestamp: number, delta: number): boolean; /** - * [description] - * @param tween [description] - * @param tweenData [description] - * @param diff [description] + * Internal method used as part of the playback process that sets a tween to play in reverse. + * @param tween The Tween to update. + * @param tweenData The TweenData property to update. + * @param diff Any extra time that needs to be accounted for in the elapsed and progress values. */ setStateFromEnd(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, diff: number): integer; /** - * Was PLAYING_BACKWARD and has hit the start. - * @param tween [description] - * @param tweenData [description] - * @param diff [description] + * Internal method used as part of the playback process that sets a tween to play from the start. + * @param tween The Tween to update. + * @param tweenData The TweenData property to update. + * @param diff Any extra time that needs to be accounted for in the elapsed and progress values. */ setStateFromStart(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, diff: number): integer; /** - * [description] - * @param tween [description] - * @param tweenData [description] + * Internal method that advances the TweenData based on the time value given. + * @param tween The Tween to update. + * @param tweenData The TweenData property to update. * @param delta Either a value in ms, or 1 if Tween.useFrames is true */ updateTweenData(tween: Phaser.Tweens.Tween, tweenData: Phaser.Tweens.TweenDataConfig, delta: number): boolean; @@ -55796,156 +74625,164 @@ declare namespace Phaser { }; /** - * [description] - * @param target [description] - * @param key [description] - * @param getEnd [description] - * @param getStart [description] - * @param ease [description] - * @param delay [description] - * @param duration [description] - * @param yoyo [description] - * @param hold [description] - * @param repeat [description] - * @param repeatDelay [description] - * @param flipX [description] - * @param flipY [description] + * Returns a TweenDataConfig object that describes the tween data for a unique property of a unique target. A single Tween consists of multiple TweenDatas, depending on how many properties are being changed by the Tween. + * + * This is an internal function used by the TweenBuilder and should not be accessed directly, instead, Tweens should be created using the GameObjectFactory or GameObjectCreator. + * @param target The target to tween. + * @param key The property of the target to tween. + * @param getEnd What the property will be at the END of the Tween. + * @param getStart What the property will be at the START of the Tween. + * @param ease The ease function this tween uses. + * @param delay Time in ms/frames before tween will start. + * @param duration Duration of the tween in ms/frames. + * @param yoyo Determines whether the tween should return back to its start value after hold has expired. + * @param hold Time in ms/frames the tween will pause before repeating or returning to its starting value if yoyo is set to true. + * @param repeat Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. + * @param repeatDelay Time in ms/frames before the repeat will start. + * @param flipX Should toggleFlipX be called when yoyo or repeat happens? + * @param flipY Should toggleFlipY be called when yoyo or repeat happens? */ function TweenData(target: object, key: string, getEnd: Function, getStart: Function, ease: Function, delay: number, duration: number, yoyo: boolean, hold: number, repeat: number, repeatDelay: number, flipX: boolean, flipY: boolean): TweenDataConfig; /** - * [description] + * The Tween Manager is a default Scene Plugin which controls and updates Tweens and Timelines. */ class TweenManager { /** * - * @param scene [description] + * @param scene The Scene which owns this Tween Manager. */ constructor(scene: Phaser.Scene); /** - * [description] + * The Scene which owns this Tween Manager. */ scene: Phaser.Scene; /** - * [description] + * The Systems object of the Scene which owns this Tween Manager. */ systems: Phaser.Scenes.Systems; /** - * [description] + * The time scale of the Tween Manager. + * + * This value scales the time delta between two frames, thus influencing the speed of time for all Tweens owned by this Tween Manager. */ timeScale: number; /** * Create a Tween Timeline and return it, but do NOT add it to the active or pending Tween lists. - * @param config [description] + * @param config The configuration object for the Timeline and its Tweens. */ createTimeline(config: object): Phaser.Tweens.Timeline; /** * Create a Tween Timeline and add it to the active Tween list/ - * @param config [description] + * @param config The configuration object for the Timeline and its Tweens. */ timeline(config: object): Phaser.Tweens.Timeline; /** * Create a Tween and return it, but do NOT add it to the active or pending Tween lists. - * @param config [description] + * @param config The configuration object for the Tween as per {@link Phaser.Tweens.Builders.TweenBuilder}. */ create(config: object): Phaser.Tweens.Tween; /** * Create a Tween and add it to the active Tween list. - * @param config [description] + * @param config The configuration object for the Tween as per the {@link Phaser.Tweens.Builders.TweenBuilder}. */ add(config: object): Phaser.Tweens.Tween; /** * Add an existing tween into the active Tween list. - * @param tween [description] + * @param tween The Tween to add. */ existing(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; /** * Create a Tween and add it to the active Tween list. - * @param config [description] + * @param config The configuration object for the Number Tween as per the {@link Phaser.Tweens.Builders.NumberTweenBuilder}. */ addCounter(config: object): Phaser.Tweens.Tween; /** - * [description] + * Updates the Tween Manager's internal lists at the start of the frame. + * + * This method will return immediately if no changes have been indicated. */ preUpdate(): void; /** - * [description] - * @param timestamp [description] - * @param delta [description] + * Updates all Tweens and Timelines of the Tween Manager. + * @param timestamp The current time in milliseconds. + * @param delta The delta time in ms since the last frame. This is a smoothed and capped value based on the FPS rate. */ update(timestamp: number, delta: number): void; /** - * [description] - * @param tween [description] + * Checks if a Tween or Timeline is active and adds it to the Tween Manager at the start of the frame if it isn't. + * @param tween The Tween to check. */ makeActive(tween: Phaser.Tweens.Tween): Phaser.Tweens.TweenManager; /** * Passes all Tweens to the given callback. - * @param callback [description] - * @param scope [description] - * @param args [description] + * @param callback The function to call. + * @param scope The scope (`this` object) to call the function with. + * @param args The arguments to pass into the function. Its first argument will always be the Tween currently being iterated. */ each(callback: Function, scope?: object, ...args: any[]): void; /** - * [description] + * Returns an array of all active Tweens and Timelines in the Tween Manager. */ getAllTweens(): Phaser.Tweens.Tween[]; /** - * [description] + * Returns the scale of the time delta for all Tweens and Timelines owned by this Tween Manager. */ getGlobalTimeScale(): number; /** - * [description] - * @param target [description] + * Returns an array of all Tweens or Timelines in the Tween Manager which affect the given target or array of targets. + * @param target The target to look for. Provide an array to look for multiple targets. */ getTweensOf(target: object | any[]): Phaser.Tweens.Tween[]; /** - * [description] - * @param target [description] + * Checks if the given object is being affected by a playing Tween. + * @param target target Phaser.Tweens.Tween object */ isTweening(target: object): boolean; /** - * [description] + * Stops all Tweens in this Tween Manager. They will be removed at the start of the frame. */ killAll(): Phaser.Tweens.TweenManager; /** - * [description] - * @param target [description] + * Stops all Tweens which affect the given target or array of targets. The Tweens will be removed from the Tween Manager at the start of the frame. + * @param target The target to look for. Provide an array to look for multiple targets. */ killTweensOf(target: object | any[]): Phaser.Tweens.TweenManager; /** - * [description] + * Pauses all Tweens in this Tween Manager. */ pauseAll(): Phaser.Tweens.TweenManager; /** - * [description] + * Resumes all Tweens in this Tween Manager. */ resumeAll(): Phaser.Tweens.TweenManager; /** - * [description] - * @param value [description] + * Sets a new scale of the time delta for this Tween Manager. + * + * The time delta is the time elapsed between two consecutive frames and influences the speed of time for this Tween Manager and all Tweens it owns. Values higher than 1 increase the speed of time, while values smaller than 1 decrease it. A value of 0 freezes time and is effectively equivalent to pausing all Tweens. + * @param value The new scale of the time delta, where 1 is the normal speed. */ setGlobalTimeScale(value: number): Phaser.Tweens.TweenManager; @@ -56031,7 +74868,7 @@ declare namespace Phaser { * @param array The array to search. * @param callback A callback to be invoked for each item in the array. * @param context The context in which the callback is invoked. - * @param args Additional arguments that will be passed to the callback, after the child. + * @param args Additional arguments that will be passed to the callback, after the current array item. */ function Each(array: any[], callback: Function, context: object, ...args: any[]): any[]; @@ -56047,12 +74884,15 @@ declare namespace Phaser { function EachInRange(array: any[], callback: Function, context: object, startIndex: integer, endIndex: integer, ...args: any[]): any[]; /** - * [description] + * Searches a pre-sorted array for the closet value to the given number. + * + * If the `key` argument is given it will assume the array contains objects that all have the required `key` property name, + * and will check for the closest value of those to the given number. * @param value The value to search for in the array. * @param array The array to search, which must be sorted. * @param key An optional property key. If specified the array elements property will be checked against value. */ - function FindClosestInSorted(value: number, array: any[], key?: string): number | object; + function FindClosestInSorted(value: number, array: any[], key?: string): number | any; /** * Returns all elements in the array. @@ -56095,60 +74935,80 @@ declare namespace Phaser { * @param startIndex An optional start index. Default 0. * @param length An optional length, the total number of elements (from the startIndex) to choose from. Default array.length. */ - function GetRandom(array: any[], startIndex?: integer, length?: integer): object; + function GetRandom(array: any[], startIndex?: integer, length?: integer): any; namespace Matrix { /** - * [description] - * @param matrix [description] + * Checks if an array can be used as a matrix. + * + * A matrix is a two-dimensional array (array of arrays), where all sub-arrays (rows) have the same length. There must be at least two rows: + * + * ``` + * [ + * [ 1, 1, 1, 1, 1, 1 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 2, 0, 1, 2, 0, 4 ], + * [ 2, 0, 3, 4, 0, 4 ], + * [ 2, 0, 0, 0, 0, 4 ], + * [ 3, 3, 3, 3, 3, 3 ] + * ] + * ``` + * @param matrix The array to check. */ function CheckMatrix(matrix: any[]): boolean; /** - * [description] - * @param matrix [description] + * Generates a string (which you can pass to console.log) from the given Array Matrix. + * @param matrix A 2-dimensional array. */ function MatrixToString(matrix: any[]): string; /** - * [description] - * @param matrix [description] + * Reverses the columns in the given Array Matrix. + * @param matrix The array matrix to reverse the columns for. */ function ReverseColumns(matrix: any[]): any[]; /** - * [description] - * @param matrix [description] + * Reverses the rows in the given Array Matrix. + * @param matrix The array matrix to reverse the rows for. */ function ReverseRows(matrix: any[]): any[]; /** - * [description] - * @param matrix [description] + * Rotates the array matrix 180 degrees. + * @param matrix The array to rotate. */ function Rotate180(matrix: any[]): any[]; /** - * [description] - * @param matrix [description] + * Rotates the array matrix to the left (or 90 degrees) + * @param matrix The array to rotate. */ function RotateLeft(matrix: any[]): any[]; /** - * [description] + * Rotates the array matrix based on the given rotation value. + * + * The value can be given in degrees: 90, -90, 270, -270 or 180, + * or a string command: `rotateLeft`, `rotateRight` or `rotate180`. + * + * Based on the routine from {@link http://jsfiddle.net/MrPolywhirl/NH42z/}. * @param matrix The array to rotate. - * @param direction The amount to rotate the matrix by. The value can be given in degrees: 90, -90, 270, -270 or 180, or a string command: `rotateLeft`, `rotateRight` or `rotate180`. Default 90. + * @param direction The amount to rotate the matrix by. Default 90. */ function RotateMatrix(matrix: any[], direction?: number | string): any[]; /** - * [description] - * @param matrix [description] + * Rotates the array matrix to the left (or -90 degrees) + * @param matrix The array to rotate. */ function RotateRight(matrix: any[]): any[]; /** - * [description] + * Transposes the elements of the given matrix (array of arrays). + * + * The transpose of a matrix is a new matrix whose rows are the columns of the original. * @param array The array matrix to transpose. */ function TransposeMatrix(array: any[]): any[]; @@ -56216,22 +75076,57 @@ declare namespace Phaser { function NumberArrayStep(start?: number, end?: number, step?: number): number[]; /** - * [description] - * @param arr [description] - * @param k [description] - * @param left [description] - * @param right [description] - * @param compare [description] + * A [Floyd-Rivest](https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm) quick selection algorithm. + * + * Rearranges the array items so that all items in the [left, k] range are smaller than all items in [k, right]; + * The k-th element will have the (k - left + 1)th smallest value in [left, right]. + * + * The array is modified in-place. + * + * Based on code by [Vladimir Agafonkin](https://www.npmjs.com/~mourner) + * @param arr The array to sort. + * @param k The k-th element index. + * @param left The index of the left part of the range. Default 0. + * @param right The index of the right part of the range. + * @param compare An optional comparison function. Is passed two elements and should return 0, 1 or -1. */ - function QuickSelect(arr: any[], k: number, left: number, right: number, compare: Function): void; + function QuickSelect(arr: any[], k: integer, left?: integer, right?: integer, compare?: Function): void; /** - * [description] - * @param a [description] - * @param b [description] - * @param options [description] + * Creates an array populated with a range of values, based on the given arguments and configuration object. + * + * Range ([a,b,c], [1,2,3]) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2,3], qty = 3) = + * a1, a1, a1, a2, a2, a2, a3, a3, a3, b1, b1, b1, b2, b2, b2, b3, b3, b3 + * + * Range ([a,b,c], [1,2,3], repeat x1) = + * a1, a2, a3, b1, b2, b3, c1, c2, c3, a1, a2, a3, b1, b2, b3, c1, c2, c3 + * + * Range ([a,b], [1,2], repeat -1 = endless, max = 14) = + * Maybe if max is set then repeat goes to -1 automatically? + * a1, a2, b1, b2, a1, a2, b1, b2, a1, a2, b1, b2, a1, a2 (capped at 14 elements) + * + * Range ([a], [1,2,3,4,5], random = true) = + * a4, a1, a5, a2, a3 + * + * Range ([a, b], [1,2,3], random = true) = + * b3, a2, a1, b1, a3, b2 + * + * Range ([a, b, c], [1,2,3], randomB = true) = + * a3, a1, a2, b2, b3, b1, c1, c3, c2 + * + * Range ([a], [1,2,3,4,5], yoyo = true) = + * a1, a2, a3, a4, a5, a5, a4, a3, a2, a1 + * + * Range ([a, b], [1,2,3], yoyo = true) = + * a1, a2, a3, b1, b2, b3, b3, b2, b1, a3, a2, a1 + * @param a The first array of range elements. + * @param b The second array of range elements. + * @param options A range configuration object. Can contain: repeat, random, randomB, yoyo, max, qty. */ - function Range(a: any[], b: any[], options: object): any[]; + function Range(a: any[], b: any[], options?: object): any[]; /** * Removes the given item, or array of items, from the array. @@ -56350,11 +75245,29 @@ declare namespace Phaser { /** * Removes a single item from an array and returns it without creating gc, like the native splice does. * Based on code by Mike Reinstein. - * @param array [description] - * @param index [description] + * @param array The array to splice from. + * @param index The index of the item which should be spliced. */ function SpliceOne(array: any[], index: integer): any; + namespace StableSortFunctions { + /** + * Sort the input array and simply copy it back if the result isn't in the original array, which happens on an odd number of passes. + * @param arr The input array. + * @param comp The comparison handler. + */ + function inplace(arr: any[], comp: Function): any[]; + + } + + /** + * A stable array sort, because `Array#sort()` is not guaranteed stable. + * This is an implementation of merge sort, without recursion. + * @param arr The input array to be sorted. + * @param comp The comparison handler. + */ + function StableSort(arr: any[], comp: Function): any[]; + /** * Swaps the position of two elements in the given array. * The elements must exist in the same array. @@ -56375,7 +75288,7 @@ declare namespace Phaser { */ function NOOP(): void; - namespace Object { + namespace Objects { /** * Shallow Object Clone. Will not clone nested objects. * @param obj the object from which to clone @@ -56388,10 +75301,37 @@ declare namespace Phaser { function Extend(): object; /** - * [description] - * @param source [description] - * @param key [description] - * @param defaultValue [description] + * Retrieves a value from an object. Allows for more advanced selection options, including: + * + * Allowed types: + * + * Implicit + * { + * x: 4 + * } + * + * From function + * { + * x: function () + * } + * + * Randomly pick one element from the array + * { + * x: [a, b, c, d, e, f] + * } + * + * Random integer between min and max: + * { + * x: { randInt: [min, max] } + * } + * + * Random float between min and max: + * { + * x: { randFloat: [min, max] } + * } + * @param source The object to retrieve the value from. + * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param defaultValue The value to return if the `key` isn't found in the `source` object. */ function GetAdvancedValue(source: object, key: string, defaultValue: any): any; @@ -56404,20 +75344,20 @@ declare namespace Phaser { function GetFastValue(source: object, key: string, defaultValue?: any): any; /** - * [description] - * @param source [description] - * @param key [description] - * @param min [description] - * @param max [description] - * @param defaultValue [description] + * Retrieves and clamps a numerical value from an object. + * @param source The object to retrieve the value from. + * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`). + * @param min The minimum value which can be returned. + * @param max The maximum value which can be returned. + * @param defaultValue The value to return if the property doesn't exist. It's also constrained to the given bounds. */ function GetMinMaxValue(source: object, key: string, min: number, max: number, defaultValue: number): number; /** - * [description] - * @param source [description] - * @param key [description] - * @param defaultValue [description] + * Retrieves a value from an object. + * @param source The object to retrieve the value from. + * @param key The name of the property to retrieve from the object. If a property is nested, the names of its preceding properties should be separated by a dot (`.`) - `banner.hideBanner` would return the value of the `hideBanner` property from the object stored in the `banner` property of the `source` object. + * @param defaultValue The value to return if the `key` isn't found in the `source` object. */ function GetValue(source: object, key: string, defaultValue: any): any; @@ -56436,9 +75376,9 @@ declare namespace Phaser { function HasAny(source: object, keys: string[]): boolean; /** - * [description] - * @param source [description] - * @param key [description] + * Determine whether the source object has a property with the specified key. + * @param source The source object to be checked. + * @param key The property to check for within the object */ function HasValue(source: object, key: string): boolean; @@ -56452,8 +75392,8 @@ declare namespace Phaser { /** * Creates a new Object using all values from obj1 and obj2. * If a value exists in both obj1 and obj2, the value in obj1 is used. - * @param obj1 [description] - * @param obj2 [description] + * @param obj1 The first object. + * @param obj2 The second object. */ function Merge(obj1: object, obj2: object): object; @@ -56461,8 +75401,8 @@ declare namespace Phaser { * Creates a new Object using all values from obj1. * * Then scans obj2. If a property is found in obj2 that *also* exists in obj1, the value from obj2 is used, otherwise the property is skipped. - * @param obj1 [description] - * @param obj2 [description] + * @param obj1 The first object to merge. + * @param obj2 The second object to merge. Keys from this object which also exist in `obj1` will be copied to `obj1`. */ function MergeRight(obj1: object, obj2: object): object; @@ -56510,7 +75450,7 @@ declare namespace Phaser { * For example if given the string `Atari 520ST` it would return `TS025 iratA`. * @param string The string to be reversed. */ - function ReverseString(string: string): string; + function Reverse(string: string): string; /** * Capitalizes the first letter of a string if there is one. @@ -56518,10 +75458,790 @@ declare namespace Phaser { */ function UppercaseFirst(str: string): string; + /** + * Creates and returns an RFC4122 version 4 compliant UUID. + * + * The string is in the form: `xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx` where each `x` is replaced with a random + * hexadecimal digit from 0 to f, and `y` is replaced with a random hexadecimal digit from 8 to b. + */ + function UUID(): string; + } } + /** + * The Facebook Instant Games Plugin for Phaser 3 provides a seamless bridge between Phaser + * and the Facebook Instant Games API version 6.2. + * + * You can access this plugin via the `facebook` property in a Scene, i.e: + * + * ```javascript + * this.facebook.getPlatform(); + * ``` + * + * If this is unavailable please check to make sure you're using a build of Phaser that has + * this plugin within it. You can quickly check this by looking at the dev tools console + * header - the Phaser version number will have `-FB` after it if this plugin is loaded. + * + * If you are building your own version of Phaser then use this Webpack DefinePlugin flag: + * + * `"typeof PLUGIN_FBINSTANT": JSON.stringify(true)` + * + * You will find that every Instant Games API method has a mapping in this plugin. + * For a full list please consult either the plugin documentation, or the 6.2 SDK documentation + * at https://developers.facebook.com/docs/games/instant-games/sdk/fbinstant6.2 + * + * Internally this plugin uses its own Data Manager to handle seamless user data updates and provides + * handy functions for advertisement displaying, opening share dialogs, logging, leaderboards, purchase API requests, + * loader integration and more. + * + * To get started with Facebook Instant Games you will need to register on Facebook and create a new Instant + * Game app that has its own unique app ID. Facebook have also provided a dashboard interface for setting up + * various features for your game, including leaderboards, ad requests and the payments API. There are lots + * of guides on the Facebook Developers portal to assist with setting these + * various systems up: https://developers.facebook.com/docs/games/instant-games/guides + * + * For more details follow the Quick Start guide here: https://developers.facebook.com/docs/games/instant-games + */ + class FacebookInstantGamesPlugin extends Phaser.Events.EventEmitter { + /** + * + * @param game A reference to the Phaser.Game instance. + */ + constructor(game: Phaser.Game); + + /** + * A reference to the Phaser.Game instance. + */ + readonly game: Phaser.Game; + + /** + * A Data Manager instance. + * It allows you to store, query and retrieve any key/value data you may need to store. + * It's also used internally by the plugin to store FBIG API data. + */ + data: Phaser.Data.DataManager; + + /** + * Has the Facebook Instant Games API loaded yet? + * This is set automatically during the boot process. + */ + hasLoaded: boolean; + + /** + * Is the Data Manager currently locked? + */ + dataLocked: boolean; + + /** + * A list of the Facebook Instant Games APIs that are available, + * based on the given platform, context and user privacy settings. + * This value is populated automatically during boot. + */ + supportedAPIs: string[]; + + /** + * Holds the entry point that the game was launched from. + * This value is populated automatically during boot. + */ + entryPoint: string; + + /** + * An object that contains any data associated with the entry point that the game was launched from. + * The contents of the object are developer-defined, and can occur from entry points on different platforms. + * This will return null for older mobile clients, as well as when there is no data associated with the particular entry point. + * This value is populated automatically during boot. + */ + entryPointData: any; + + /** + * A unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * This value is populated automatically during boot. + */ + contextID: string; + + /** + * The current context in which your game is running. This can be either `null` or + * one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * This value is populated automatically during boot. + */ + contextType: string; + + /** + * The current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * This value is populated automatically during boot. + */ + locale: string; + + /** + * The platform on which the game is currently running, i.e. `IOS`. + * This value is populated automatically during boot. + */ + platform: string; + + /** + * The string representation of the Facebook Instant Games SDK version being used. + * This value is populated automatically during boot. + */ + version: string; + + /** + * Holds the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * This value is populated automatically during boot if the API is supported. + */ + playerID: string; + + /** + * The player's localized display name. + * This value is populated automatically during boot if the API is supported. + */ + playerName: string; + + /** + * A url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * This value is populated automatically during boot if the API is supported. + */ + playerPhotoURL: string; + + /** + * Whether a player can subscribe to the game bot or not. + */ + playerCanSubscribeBot: boolean; + + /** + * Does the current platform and context allow for use of the payments API? + * Currently this is only available on Facebook.com and Android 6+. + */ + paymentsReady: boolean; + + /** + * The set of products that are registered to the game. + */ + catalog: Product[]; + + /** + * Contains all of the player's unconsumed purchases. + * The game must fetch the current player's purchases as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + */ + purchases: Purchase[]; + + /** + * Contains all of the leaderboard data, as populated by the `getLeaderboard()` method. + */ + leaderboards: Phaser.FacebookInstantGamesPlugin.Leaderboard[]; + + /** + * Contains AdInstance objects, as created by the `preloadAds()` method. + */ + ads: AdInstance[]; + + /** + * Call this method from your `Scene.preload` in order to sync the load progress + * of the Phaser Loader with the Facebook Instant Games loader display, i.e.: + * + * ```javascript + * this.facebook.showLoadProgress(this); + * this.facebook.once('startgame', this.startGame, this); + * ``` + * @param scene The Scene for which you want to show loader progress for. + */ + showLoadProgress(scene: Phaser.Scene): this; + + /** + * This method is called automatically when the game has finished loading, + * if you used the `showLoadProgress` method. If your game doesn't need to + * load any assets, or you're managing the load yourself, then call this + * method directly to start the API running. + * + * When the API has finished starting this plugin will emit a `startgame` event + * which you should listen for. + */ + gameStarted(): void; + + /** + * Checks to see if a given Facebook Instant Games API is available or not. + * @param api The API to check for, i.e. `player.getID`. + */ + checkAPI(api: string): boolean; + + /** + * Returns the unique identifier for the current game context. This represents a specific context + * that the game is being played in (for example, a particular messenger conversation or facebook post). + * The identifier will be null if game is being played in a solo context. + * + * It is only populated if `contextGetID` is in the list of supported APIs. + */ + getID(): string; + + /** + * Returns the current context in which your game is running. This can be either `null` or one of: + * + * `POST` - The game is running inside of a Facebook post. + * `THREAD` - The game is running inside a Facebook Messenger thread. + * `GROUP` - The game is running inside a Facebook Group. + * `SOLO` - This is the default context, the player is the only participant. + * + * It is only populated if `contextGetType` is in the list of supported APIs. + */ + getType(): string; + + /** + * Returns the current locale. + * See https://origincache.facebook.com/developers/resources/?id=FacebookLocales.xml for a complete list of supported locale values. + * Use this to determine what languages the current game should be localized with. + * It is only populated if `getLocale` is in the list of supported APIs. + */ + getLocale(): string; + + /** + * Returns the platform on which the game is currently running, i.e. `IOS`. + * It is only populated if `getPlatform` is in the list of supported APIs. + */ + getPlatform(): string; + + /** + * Returns the string representation of the Facebook Instant Games SDK version being used. + * It is only populated if `getSDKVersion` is in the list of supported APIs. + */ + getSDKVersion(): string; + + /** + * Returns the id of the player. This is a string based ID, the same as `FBInstant.player.getID()`. + * It is only populated if `playerGetID` is in the list of supported APIs. + */ + getPlayerID(): string; + + /** + * Returns the player's localized display name. + * It is only populated if `playerGetName` is in the list of supported APIs. + */ + getPlayerName(): string; + + /** + * Returns the url to the player's public profile photo. The photo will always be a square, and with dimensions + * of at least 200x200. When rendering it in the game, the exact dimensions should never be assumed to be constant. + * It's recommended to always scale the image to a desired size before rendering. + * It is only populated if `playerGetPhoto` is in the list of supported APIs. + */ + getPlayerPhotoURL(): string; + + /** + * Load the player's photo and store it in the Texture Manager, ready for use in-game. + * + * This method works by using a Scene Loader instance and then asking the Loader to + * retrieve the image. + * + * When complete the plugin will emit a `photocomplete` event, along with the key of the photo. + * + * ```javascript + * this.facebook.loadPlayerPhoto(this, 'player').once('photocomplete', function (key) { + * this.add.image(x, y, 'player); + * }, this); + * ``` + * @param scene The Scene that will be responsible for loading this photo. + * @param key The key to use when storing the photo in the Texture Manager. + */ + loadPlayerPhoto(scene: Phaser.Scene, key: string): this; + + /** + * Checks if the current player can subscribe to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they can subscribe, the `playerCanSubscribeBot` property is set to `true` + * and this plugin will emit the `cansubscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `cansubscribebotfail` event instead. + */ + canSubscribeBot(): this; + + /** + * Subscribes the current player to the game bot. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `subscribebot` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `subscribebotfail` event instead. + */ + subscribeBot(): this; + + /** + * Gets the associated data from the player based on the given key, or array of keys. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the data is set into this plugins Data Manager and the + * `getdata` event will be emitted. + * @param keys The key/s of the data to retrieve. + */ + getData(keys: string | string[]): this; + + /** + * Set data to be saved to the designated cloud storage of the current player. The game can store up to 1MB of data for each unique player. + * + * The data save is requested in an async call, so the result isn't available immediately. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to replace the data object directly. + * + * When the APIs `setDataAsync` call resolves it will emit the `savedata` event from this plugin. If the call fails for some + * reason it will emit `savedatafail` instead. + * + * The call resolving does not necessarily mean that the input has already been persisted. Rather, it means that the data was valid and + * has been scheduled to be saved. It also guarantees that all values that were set are now available in `getData`. + * @param data An object containing a set of key-value pairs that should be persisted to cloud storage. + * The object must contain only serializable values - any non-serializable values will cause the entire modification to be rejected. + */ + saveData(data: object): this; + + /** + * Immediately flushes any changes to the player data to the designated cloud storage. + * This function is expensive, and should primarily be used for critical changes where persistence needs to be immediate + * and known by the game. Non-critical changes should rely on the platform to persist them in the background. + * NOTE: Calls to player.setDataAsync will be rejected while this function's result is pending. + * + * Data managed via this plugins Data Manager instance is automatically synced with Facebook. However, you can call this + * method directly if you need to flush the data directly. + * + * When the APIs `flushDataAsync` call resolves it will emit the `flushdata` event from this plugin. If the call fails for some + * reason it will emit `flushdatafail` instead. + */ + flushData(): this; + + /** + * Retrieve stats from the designated cloud storage of the current player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `getstatsfail` event instead. + * @param keys An optional array of unique keys to retrieve stats for. If the function is called without it, it will fetch all stats. + */ + getStats(keys?: string[]): this; + + /** + * Save the stats of the current player to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `savestats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `savestatsfail` event instead. + * @param data An object containing a set of key-value pairs that should be persisted to cloud storage as stats. Note that only numerical values are stored. + */ + saveStats(data: object): this; + + /** + * Increment the stats of the current player and save them to the designated cloud storage. + * + * Stats in the Facebook Instant Games API are purely numerical values paired with a string-based key. Only numbers can be saved as stats, + * all other data types will be ignored. + * + * The data object provided for this call should contain offsets for how much to modify the stats by: + * + * ```javascript + * this.facebook.incStats({ + * level: 1, + * zombiesSlain: 17, + * rank: -1 + * }); + * ``` + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `incstats` event will be emitted along with the data object returned. + * + * If the call fails, i.e. it's not in the list of supported APIs, or the request was rejected, + * it will emit a `incstatsfail` event instead. + * @param data An object containing a set of key-value pairs indicating how much to increment each stat in cloud storage. Note that only numerical values are processed. + */ + incStats(data: object): this; + + /** + * Sets the data associated with the individual gameplay session for the current context. + * + * This function should be called whenever the game would like to update the current session data. + * + * This session data may be used to populate a variety of payloads, such as game play webhooks. + * @param data An arbitrary data object, which must be less than or equal to 1000 characters when stringified. + */ + saveSession(data: object): this; + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openShare(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This invokes a dialog to let the user invite a friend to play this game, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openInvite(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openRequest(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This invokes a dialog to let the user share specified content, either as a message in Messenger or as a post on the user's timeline. + * + * A blob of data can be attached to the share which every game session launched from the share will be able to access via the `this.entryPointData` property. + * + * This data must be less than or equal to 1000 characters when stringified. + * + * When this method is called you should consider your game paused. Listen out for the `resume` event from this plugin to know when the dialog has been closed. + * + * The user may choose to cancel the share action and close the dialog. The resulting `resume` event will be dispatched regardless if the user actually shared the content or not. + * @param text A text message to be shared. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param sessionData A blob of data to attach to the share. + */ + openChallenge(text: string, key: string, frame?: string, sessionData?: object): this; + + /** + * This function determines whether the number of participants in the current game context is between a given minimum and maximum, inclusive. + * If one of the bounds is null only the other bound will be checked against. + * It will always return the original result for the first call made in a context in a given game play session. + * Subsequent calls, regardless of arguments, will return the answer to the original query until a context change occurs and the query result is reset. + * @param min The minimum bound of the context size query. + * @param max The maximum bound of the context size query. + */ + isSizeBetween(min?: integer, max?: integer): object; + + /** + * Request a switch into a specific context. If the player does not have permission to enter that context, + * or if the player does not provide permission for the game to enter that context, this will emit a `switchfail` event. + * + * Otherwise, the plugin will emit the `switch` event when the game has switched into the specified context. + * @param contextID The ID of the desired context. + */ + switchContext(contextID: string): this; + + /** + * Opens a context selection dialog for the player. If the player selects an available context, + * the client will attempt to switch into that context, and emit the `choose` event if successful. + * Otherwise, if the player exits the menu or the client fails to switch into the new context, the `choosefail` event will be emitted. + * @param contextID The ID of the desired context. + */ + chooseContext(contextID: string): this; + + /** + * Attempts to create or switch into a context between a specified player and the current player. + * This plugin will emit the `create` event once the context switch is completed. + * If the API call fails, such as if the player listed is not a Connected Player of the current player or if the + * player does not provide permission to enter the new context, then the plugin will emit a 'createfail' event. + * @param playerID ID of the player. + */ + createContext(playerID: string): this; + + /** + * Fetches an array of ConnectedPlayer objects containing information about active players + * (people who played the game in the last 90 days) that are connected to the current player. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `players` event along + * with the player data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `playersfail` event instead. + */ + getPlayers(): this; + + /** + * Fetches the game's product catalog. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getcatalog` event along + * with the catalog data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getcatalogfail` event instead. + */ + getCatalog(): this; + + /** + * Begins the purchase flow for a specific product. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `purchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `purchasefail` event instead. + * @param productID The identifier of the product to purchase. + * @param developerPayload An optional developer-specified payload, to be included in the returned purchase's signed request. + */ + purchase(productID: string, developerPayload?: string): this; + + /** + * Fetches all of the player's unconsumed purchases. The game must fetch the current player's purchases + * as soon as the client indicates that it is ready to perform payments-related operations, + * i.e. at game start. The game can then process and consume any purchases that are waiting to be consumed. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `getpurchases` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `getpurchasesfail` event instead. + */ + getPurchases(): this; + + /** + * Consumes a specific purchase belonging to the current player. Before provisioning a product's effects to the player, + * the game should request the consumption of the purchased product. Once the purchase is successfully consumed, + * the game should immediately provide the player with the effects of their purchase. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If they are successfully subscribed this plugin will emit the `consumepurchase` event along + * with the purchase data. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `consumepurchasefail` event instead. + * @param purchaseToken The purchase token of the purchase that should be consumed. + */ + consumePurchases(purchaseToken: string): this; + + /** + * Informs Facebook of a custom update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * @param cta The call to action text. + * @param text The text object. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param template The update template key. + * @param updateData The update data object payload. + */ + update(cta: string, text: object, key: string, frame: string | integer, template: string, updateData: object): this; + + /** + * Informs Facebook of a leaderboard update that occurred in the game. + * This will temporarily yield control to Facebook and Facebook will decide what to do based on what the update is. + * Once Facebook returns control to the game the plugin will emit an `update` or `upatefail` event. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * The `text` parameter is an update payload with the following structure: + * + * ``` + * text: { + * default: 'X just invaded Y\'s village!', + * localizations: { + * ar_AR: 'X \u0641\u0642\u0637 \u063A\u0632\u062A ' + + * '\u0642\u0631\u064A\u0629 Y!', + * en_US: 'X just invaded Y\'s village!', + * es_LA: '\u00A1X acaba de invadir el pueblo de Y!', + * } + * } + * ``` + * @param cta The call to action text. + * @param text The text object. + * @param key The key of the texture to use as the share image. + * @param frame The frame of the texture to use as the share image. Set to `null` if you don't require a frame, but do need to set session data. + * @param template The update template key. + * @param updateData The update data object payload. + */ + updateLeaderboard(cta: string, text: object, key: string, frame: string | integer, template: string, updateData: object): this; + + /** + * Request that the client switch to a different Instant Game. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the game switches successfully this plugin will emit the `switchgame` event and the client will load the new game. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `switchgamefail` event instead. + * @param appID The Application ID of the Instant Game to switch to. The application must be an Instant Game, and must belong to the same business as the current game. + * @param data An optional data payload. This will be set as the entrypoint data for the game being switched to. Must be less than or equal to 1000 characters when stringified. + */ + switchGame(appID: string, data?: object): this; + + /** + * Prompts the user to create a shortcut to the game if they are eligible to. + * Can only be called once per session. + * + * It makes an async call to the API, so the result isn't available immediately. + * + * If the user choose to create a shortcut this plugin will emit the `shortcutcreated` event. + * + * If they cannot, i.e. it's not in the list of supported APIs, or the request + * was rejected, it will emit a `shortcutcreatedfail` event instead. + */ + createShortcut(): this; + + /** + * Quits the game. + */ + quit(): void; + + /** + * Log an app event with FB Analytics. + * + * See https://developers.facebook.com/docs/javascript/reference/v2.8#app_events for more details about FB Analytics. + * @param name Name of the event. Must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. + * @param value An optional numeric value that FB Analytics can calculate a sum with. + * @param params An optional object that can contain up to 25 key-value pairs to be logged with the event. Keys must be 2 to 40 characters, and can only contain '_', '-', ' ', and alphanumeric characters. Values must be less than 100 characters in length. + */ + log(name: string, value?: number, params?: object): this; + + /** + * Attempt to create an instance of an interstitial ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showAd()`. + * + * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * @param placementID The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + */ + preloadAds(placementID: string | string[]): this; + + /** + * Attempt to create an instance of an rewarded video ad. + * + * If the instance is created successfully then the ad is preloaded ready for display in-game via the method `showVideo()`. + * + * If the ad loads it will emit the `adloaded` event, passing the AdInstance as the only parameter. + * + * If the ad cannot be displayed because there was no inventory to fill it, it will emit the `adsnofill` event. + * @param placementID The ad placement ID, or an array of IDs, as created in your Audience Network settings within Facebook. + */ + preloadVideoAds(placementID: string | string[]): this; + + /** + * Displays a previously loaded interstitial ad. + * + * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed, it will emit the `adsnotloaded` event. + * @param placementID The ad placement ID to display. + */ + showAd(placementID: string): this; + + /** + * Displays a previously loaded interstitial video ad. + * + * If the ad is successfully displayed this plugin will emit the `adfinished` event, with the AdInstance object as its parameter. + * + * If the ad cannot be displayed, it will emit the `adsnotloaded` event. + * @param placementID The ad placement ID to display. + */ + showVideo(placementID: string): this; + + /** + * Attempts to match the current player with other users looking for people to play with. + * If successful, a new Messenger group thread will be created containing the matched players and the player will + * be context switched to that thread. This plugin will also dispatch the `matchplayer` event, containing the new context ID and Type. + * + * The default minimum and maximum number of players in one matched thread are 2 and 20 respectively, + * depending on how many players are trying to get matched around the same time. + * + * The values can be changed in `fbapp-config.json`. See the Bundle Config documentation for documentation about `fbapp-config.json`. + * @param matchTag Optional extra information about the player used to group them with similar players. Players will only be grouped with other players with exactly the same tag. The tag must only include letters, numbers, and underscores and be 100 characters or less in length. + * @param switchImmediately Optional extra parameter that specifies whether the player should be immediately switched to the new context when a match is found. By default this will be false which will mean the player needs explicitly press play after being matched to switch to the new context. Default false. + */ + matchPlayer(matchTag?: string, switchImmediately?: boolean): this; + + /** + * Fetch a specific leaderboard belonging to this Instant Game. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes the `getleaderboard` event will be emitted along with a Leaderboard object instance. + * @param name The name of the leaderboard. Each leaderboard for an Instant Game must have its own distinct name. + */ + getLeaderboard(name: string): this; + + /** + * Quits the Facebook API and then destroys this plugin. + */ + destroy(): void; + + } + } declare type ArcadeBodyBounds = { @@ -56609,6 +76329,10 @@ declare type PhysicsGroupConfig = GroupConfig & { * Sets {@link Phaser.Physics.Arcade.Body#drag drag.y}. */ dragY?: number; + /** + * Sets {@link Phaser.Physics.Arcade.Body#enable enable}. + */ + enable?: boolean; /** * Sets {@link Phaser.Physics.Arcade.Body#gravity gravity.x}. */ @@ -56657,87 +76381,91 @@ declare type PhysicsGroupConfig = GroupConfig & { declare type PhysicsGroupDefaults = { /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setCollideWorldBounds}. */ setCollideWorldBounds: boolean; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAccelerationX}. */ setAccelerationX: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAccelerationY}. */ setAccelerationY: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAllowDrag}. */ setAllowDrag: boolean; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAllowGravity}. */ setAllowGravity: boolean; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAllowRotation}. */ setAllowRotation: boolean; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setBounceX}. */ setBounceX: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setBounceY}. */ setBounceY: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setDragX}. */ setDragX: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setDragY}. */ setDragY: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setEnable}. + */ + setEnable: boolean; + /** + * As {@link Phaser.Physics.Arcade.Body#setGravityX}. */ setGravityX: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setGravityY}. */ setGravityY: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setFrictionX}. */ setFrictionX: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setFrictionY}. */ setFrictionY: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setVelocityX}. */ setVelocityX: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setVelocityY}. */ setVelocityY: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAngularVelocity}. */ setAngularVelocity: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAngularAcceleration}. */ setAngularAcceleration: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setAngularDrag}. */ setAngularDrag: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setMass}. */ setMass: number; /** - * [description] + * As {@link Phaser.Physics.Arcade.Body#setImmovable}. */ setImmovable: boolean; }; @@ -56855,65 +76583,65 @@ declare type ArcadeWorldConfig = { declare type CheckCollisionObject = { /** - * [description] + * Will bodies collide with the top side of the world bounds? */ up: boolean; /** - * [description] + * Will bodies collide with the bottom side of the world bounds? */ down: boolean; /** - * [description] + * Will bodies collide with the left side of the world bounds? */ left: boolean; /** - * [description] + * Will bodies collide with the right side of the world bounds? */ right: boolean; }; declare type ArcadeWorldDefaults = { /** - * [description] + * Set to `true` to render dynamic body outlines to the debug display. */ debugShowBody: boolean; /** - * [description] + * Set to `true` to render static body outlines to the debug display. */ debugShowStaticBody: boolean; /** - * [description] + * Set to `true` to render body velocity markers to the debug display. */ debugShowVelocity: boolean; /** - * [description] + * The color of dynamic body outlines when rendered to the debug display. */ bodyDebugColor: number; /** - * [description] + * The color of static body outlines when rendered to the debug display. */ staticBodyDebugColor: number; /** - * [description] + * The color of the velocity markers when rendered to the debug display. */ velocityDebugColor: number; }; declare type ArcadeWorldTreeMinMax = { /** - * [description] + * The minimum x value used in RTree searches. */ minX: number; /** - * [description] + * The minimum y value used in RTree searches. */ minY: number; /** - * [description] + * The maximum x value used in RTree searches. */ maxX: number; /** - * [description] + * The maximum y value used in RTree searches. */ maxY: number; }; @@ -56935,23 +76663,23 @@ declare type JSONImpactBody = { */ size: object; /** - * [description] + * The entity's position in the game world. */ pos: object; /** - * [description] + * Current velocity in pixels per second. */ vel: object; /** - * [description] + * 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. */ accel: object; /** - * [description] + * Deceleration to be subtracted from the entity's velocity per second. Only applies if `accel` is 0. */ friction: object; /** - * [description] + * The maximum velocity a body can move. */ maxVel: object; /** @@ -56982,6 +76710,30 @@ declare type JSONImpactBody = { declare type CollideCallback = (body: Phaser.Physics.Impact.Body, other: Phaser.Physics.Impact.Body, axis: string)=>void; +declare type CollisionOptions = { + /** + * 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. + */ + slopeTileProperty?: string; + /** + * A tile index to slope definition map. + */ + slopeMap?: object; + /** + * If specified, the default slope ID to + * assign to a colliding tile. If not specified, the tile's index is used. + */ + defaultCollidingSlope?: integer; + /** + * The default slope ID to assign to a + * non-colliding tile. + */ + defaultNonCollidingSlope?: integer; +}; + declare namespace MatterJS { /** * The `Matter.Body` module contains methods for creating and manipulating body models. @@ -57025,8 +76777,42 @@ declare namespace MatterJS { class Engine { } + /** + * The `Matter.Vertices` module contains methods for creating and manipulating sets of vertices. + * A set of vertices is an array of `Matter.Vector` with additional indexing properties inserted by `Vertices.create`. + * A `Matter.Body` maintains a set of vertices to represent the shape of the object (its convex hull). + */ + class Vertices { + } + } +declare type MatterTileOptions = { + /** + * An existing Matter body to be used instead of creating a new one. + */ + body?: MatterJS.Body; + /** + * Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved. + */ + isStatic?: boolean; + /** + * Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world. + */ + addToWorld?: boolean; +}; + +declare type MatterBodyTileOptions = { + /** + * Whether or not the newly created body should be made static. This defaults to true since typically tiles should not be moved. + */ + isStatic?: boolean; + /** + * Whether or not to add the newly created body (or existing body if options.body is used) to the Matter world. + */ + addToWorld?: boolean; +}; + declare type CorePluginContainer = { /** * The unique name of this plugin in the core plugin cache. @@ -57057,72 +76843,6 @@ declare type CustomPluginContainer = { plugin: Function; }; -declare namespace Phaser.Plugins.PluginCache { - /** - * Static method called directly by the Core internal Plugins. - * Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin) - * Plugin is the object to instantiate to create the plugin - * Mapping is what the plugin is injected into the Scene.Systems as (i.e. input) - * @param key A reference used to get this plugin from the plugin cache. - * @param plugin The plugin to be stored. Should be the core object, not instantiated. - * @param mapping If this plugin is to be injected into the Scene Systems, this is the property key map used. - * @param custom Core Scene plugin or a Custom Scene plugin? Default false. - */ - function register(key: string, plugin: Function, mapping: string, custom?: boolean): void; - - /** - * Stores a custom plugin in the global plugin cache. - * The key must be unique, within the scope of the cache. - * @param key A reference used to get this plugin from the plugin cache. - * @param plugin The plugin to be stored. Should be the core object, not instantiated. - * @param mapping If this plugin is to be injected into the Scene Systems, this is the property key map used. - */ - function registerCustom(key: string, plugin: Function, mapping: string): void; - - /** - * Checks if the given key is already being used in the core plugin cache. - * @param key The key to check for. - */ - function hasCore(key: string): boolean; - - /** - * Checks if the given key is already being used in the custom plugin cache. - * @param key The key to check for. - */ - function hasCustom(key: string): boolean; - - /** - * Returns the core plugin object from the cache based on the given key. - * @param key The key of the core plugin to get. - */ - function getCore(key: string): CorePluginContainer; - - /** - * Returns the custom plugin object from the cache based on the given key. - * @param key The key of the custom plugin to get. - */ - function getCustom(key: string): CustomPluginContainer; - - /** - * Returns an object from the custom cache based on the given key that can be instantiated. - * @param key The key of the custom plugin to get. - */ - function getCustomClass(key: string): Function; - - /** - * Removes a core plugin based on the given key. - * @param key The key of the core plugin to remove. - */ - function remove(key: string): void; - - /** - * Removes a custom plugin based on the given key. - * @param key The key of the custom plugin to remove. - */ - function removeCustom(key: string): void; - -} - declare type GlobalPlugin = { /** * The unique name of this plugin within the plugin cache. @@ -57142,34 +76862,42 @@ declare type GlobalPlugin = { mapping?: string; }; -declare type RendererConfig = { - /** - * [description] - */ - clearBeforeRender: boolean; - /** - * [description] - */ - pixelArt: boolean; - /** - * [description] - */ - backgroundColor: Phaser.Display.Color; - /** - * [description] - */ - resolution: number; - /** - * [description] - */ - autoResize: boolean; - /** - * [description] - */ - roundPixels: boolean; -}; +declare type SnapshotCallback = (snapshot: Phaser.Display.Color | HTMLImageElement)=>void; -declare type SnapshotCallback = (snapshot: HTMLImageElement)=>void; +declare type SnapshotState = { + /** + * The function to call after the snapshot is taken. + */ + callback: SnapshotCallback; + /** + * The format of the image to create, usually `image/png` or `image/jpeg`. + */ + type?: string; + /** + * The image quality, between 0 and 1. Used for image formats with lossy compression, such as `image/jpeg`. + */ + encoderOptions?: number; + /** + * The x coordinate to start the snapshot from. + */ + x?: integer; + /** + * The y coordinate to start the snapshot from. + */ + y?: integer; + /** + * The width of the snapshot. + */ + width?: integer; + /** + * The height of the snapshot. + */ + height?: integer; + /** + * Is this a snapshot to get a single pixel, or an area? + */ + getPixel?: boolean; +}; /** * Implements a model view projection matrices. @@ -57280,72 +77008,56 @@ declare interface ModelViewProjection { declare type WebGLContextCallback = (renderer: Phaser.Renderer.WebGL.WebGLRenderer)=>void; -declare type SnapshotState = { +declare type SceneTransitionConfig = { /** - * [description] + * The Scene key to transition to. */ - callback: SnapshotCallback; + target: string; /** - * [description] + * The duration, in ms, for the transition to last. */ - type: string; + duration?: integer; /** - * [description] + * Will the Scene responsible for the transition be sent to sleep on completion (`true`), or stopped? (`false`) */ - encoder: number; + sleep?: boolean; + /** + * Will the Scenes Input system be able to process events while it is transitioning in or out? + */ + allowInput?: boolean; + /** + * Move the target Scene to be above this one before the transition starts. + */ + moveAbove?: boolean; + /** + * Move the target Scene to be below this one before the transition starts. + */ + moveBelow?: boolean; + /** + * This callback is invoked every frame for the duration of the transition. + */ + onUpdate?: Function; + /** + * The context in which the callback is invoked. + */ + onUpdateScope?: any; + /** + * An object containing any data you wish to be passed to the target Scenes init / create methods. + */ + data?: any; }; -declare namespace Phaser.Scenes.ScenePlugin { - type SceneTransitionConfig = { - /** - * The Scene key to transition to. - */ - target: string; - /** - * The duration, in ms, for the transition to last. - */ - duration?: integer; - /** - * Will the Scene responsible for the transition be sent to sleep on completion (`true`), or stopped? (`false`) - */ - sleep?: boolean; - /** - * Will the Scenes Input system be able to process events while it is transitioning in or out? - */ - allowInput?: boolean; - /** - * Move the target Scene to be above this one before the transition starts. - */ - moveAbove?: boolean; - /** - * Move the target Scene to be below this one before the transition starts. - */ - moveBelow?: boolean; - /** - * This callback is invoked every frame for the duration of the transition. - */ - onUpdate?: Function; - /** - * The context in which the callback is invoked. - */ - onUpdateScope?: any; - /** - * An object containing any data you wish to be passed to the target Scenes init / create methods. - */ - data?: any; - }; - -} - declare type EachActiveSoundCallback = (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Sound.BaseSound[])=>void; -declare namespace Phaser.Sound.BaseSound { +/** + * Audio sprite sound type. + */ +declare type AudioSpriteSound = { /** - * Audio sprite sound type. + * Local reference to 'spritemap' object form json file generated by audiosprite tool. */ - type AudioSpriteSound = ()=>void; - -} + spritemap: object; +}; /** * Config object containing various sound settings. @@ -57403,11 +77115,33 @@ declare type SoundMarker = { config?: SoundConfig; }; -declare type EachListCallback = (item: any, ...args: any[])=>void; +declare type EachListCallback = (item: I, ...args: any[])=>void; -declare type EachMapCallback = (key: string, entry: any)=>void; +declare type EachMapCallback = (key: string, entry: E)=>void; -declare type EachSetCallback = (entry: any, index: number)=>void; +declare type EachSetCallback = (entry: E, index: number)=>void; + +/** + * An object containing the position and color data for a single pixel in a CanvasTexture. + */ +declare type PixelConfig = { + /** + * The x-coordinate of the pixel. + */ + x: integer; + /** + * The y-coordinate of the pixel. + */ + y: integer; + /** + * The color of the pixel, not including the alpha channel. + */ + color: integer; + /** + * The alpha of the pixel, between 0 and 1. + */ + alpha: number; +}; declare type EachTextureCallback = (texture: Phaser.Textures.Texture, ...args: any[])=>void; @@ -57473,9 +77207,9 @@ declare type SpriteSheetFromAtlasConfig = { spacing?: integer; }; -declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; +declare type FindTileCallback = (value: Phaser.Tilemaps.Tile, index: integer, array: Phaser.Tilemaps.Tile[])=>void; -declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: number, array: Phaser.Tilemaps.Tile[])=>void; +declare type EachTileCallback = (value: Phaser.Tilemaps.Tile, index: integer, array: Phaser.Tilemaps.Tile[])=>void; declare type GetTilesWithinFilteringOptions = { /** @@ -57492,10 +77226,119 @@ declare type GetTilesWithinFilteringOptions = { hasInterestingFace?: boolean; }; +declare type MapDataConfig = { + /** + * The key in the Phaser cache that corresponds to the loaded tilemap data. + */ + name?: string; + /** + * The width of the entire tilemap. + */ + width?: number; + /** + * The height of the entire tilemap. + */ + height?: number; + /** + * The width of the tiles. + */ + tileWidth?: number; + /** + * The height of the tiles. + */ + tileHeight?: number; + /** + * The width in pixels of the entire tilemap. + */ + widthInPixels?: number; + /** + * The height in pixels of the entire tilemap. + */ + heightInPixels?: number; + /** + * The format of the Tilemap, as defined in Tiled. + */ + format?: integer; + /** + * The orientation of the map data (i.e. orthogonal, isometric, hexagonal), default 'orthogonal'. + */ + orientation?: string; + /** + * Determines the draw order of tilemap. Default is right-down. + */ + renderOrder?: string; + /** + * The version of Tiled the map uses. + */ + version?: number; + /** + * Map specific properties (can be specified in Tiled). + */ + properties?: number; + /** + * The layers of the tilemap. + */ + layers?: Phaser.Tilemaps.LayerData[]; + /** + * An array with all the layers configured to the MapData. + */ + images?: any[]; + /** + * An array of Tiled Image Layers. + */ + objects?: object; + /** + * An object of Tiled Object Layers. + */ + collision?: object; + /** + * The tilesets the map uses. + */ + tilesets?: Phaser.Tilemaps.Tileset[]; + /** + * The collection of images the map uses(specified in Tiled). + */ + imageCollections?: any[]; + /** + * [description] + */ + tiles?: any[]; +}; + declare type TilemapFilterCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; declare type TilemapFindCallback = (value: Phaser.GameObjects.GameObject, index: number, array: Phaser.GameObjects.GameObject[])=>void; +declare type FilteringOptions = { + /** + * If true, only return tiles that don't have -1 for an index. + */ + isNotEmpty?: boolean; + /** + * If true, only return tiles that collide on at least one side. + */ + isColliding?: boolean; + /** + * If true, only return tiles that have at least one interesting face. + */ + hasInterestingFace?: boolean; +}; + +declare type StyleConfig = { + /** + * Color to use for drawing a filled rectangle at non-colliding tile locations. If set to null, non-colliding tiles will not be drawn. + */ + tileColor?: number; + /** + * Color to use for drawing a filled rectangle at colliding tile locations. If set to null, colliding tiles will not be drawn. + */ + collidingTileColor?: number; + /** + * Color to use for drawing a line at interesting tile faces. If set to null, interesting tile faces will not be drawn. + */ + faceColor?: number; +}; + declare type TilemapConfig = { /** * The key in the Phaser cache that corresponds to the loaded tilemap data. @@ -57534,62 +77377,62 @@ declare type TilemapConfig = { declare type TimerEventConfig = { /** - * [description] + * The delay after which the Timer Event should fire, in milliseconds. */ delay?: number; /** - * [description] + * The total number of times the Timer Event will repeat before finishing. */ repeat?: number; /** - * [description] + * `true` if the Timer Event should repeat indefinitely. */ loop?: boolean; /** - * [description] + * The callback which will be called when the Timer Event fires. */ callback?: Function; /** - * [description] + * The scope (`this` object) with which to invoke the `callback`. */ callbackScope?: any; /** - * [description] + * Additional arguments to be passed to the `callback`. */ args?: any[]; /** - * [description] + * The scale of the elapsed time. */ timeScale?: number; /** - * [description] + * The initial elapsed time in milliseconds. Useful if you want a long duration with repeat, but for the first loop to fire quickly. */ startAt?: number; /** - * [description] + * `true` if the Timer Event should be paused. */ paused?: boolean; }; declare type TweenDataGenConfig = { /** - * [description] + * Time in ms/frames before tween will start. */ delay: Function; /** - * [description] + * Duration of the tween in ms/frames, excludes time for yoyo or repeats. */ duration: Function; /** - * [description] + * Time in ms/frames the tween will pause before running the yoyo or starting a repeat. */ hold: Function; /** - * [description] + * Number of times to repeat the tween. The tween will always run once regardless, so a repeat value of '1' will play the tween twice. */ repeat: Function; /** - * [description] + * Time in ms/frames before the repeat will start. */ repeatDelay: Function; }; @@ -57606,6 +77449,228 @@ declare class Class { } +declare type AdInstance = { + /** + * Represents an instance of an ad. + */ + instance: any; + /** + * The Audience Network placement ID of this ad instance. + */ + placementID: string; + /** + * Has this ad already been shown in-game? + */ + shown: boolean; + /** + * Is this a video ad? + */ + video: boolean; +}; + +declare namespace Phaser.FacebookInstantGamesPlugin { + /** + * This class represents one single Leaderboard that belongs to a Facebook Instant Game. + * + * You do not need to instantiate this class directly, it will be created when you use the + * `getLeaderboard()` method of the main plugin. + */ + class Leaderboard { + /** + * + * @param plugin A reference to the Facebook Instant Games Plugin. + * @param data An Instant Game leaderboard instance. + */ + constructor(plugin: Phaser.FacebookInstantGamesPlugin, data: any); + + /** + * A reference to the Facebook Instant Games Plugin. + */ + plugin: Phaser.FacebookInstantGamesPlugin; + + /** + * An Instant Game leaderboard instance. + */ + ref: any; + + /** + * The name of the leaderboard. + */ + name: string; + + /** + * The ID of the context that the leaderboard is associated with, or null if the leaderboard is not tied to a particular context. + */ + contextID: string; + + /** + * The total number of player entries in the leaderboard. + * This value defaults to zero. Populate it via the `getEntryCount()` method. + */ + entryCount: integer; + + /** + * The players score object. + * This value defaults to `null`. Populate it via the `getPlayerScore()` method. + */ + playerScore: LeaderboardScore; + + /** + * The scores in the Leaderboard from the currently requested range. + * This value defaults to an empty array. Populate it via the `getScores()` method. + * The contents of this array are reset each time `getScores()` is called. + */ + scores: LeaderboardScore[]; + + /** + * Fetches the total number of player entries in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getentrycount` event along with the count and name of the Leaderboard. + */ + getEntryCount(): this; + + /** + * Updates the player's score. If the player has an existing score, the old score will only be replaced if the new score is better than it. + * NOTE: If the leaderboard is associated with a specific context, the game must be in that context to set a score for the player. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `setscore` event along with the LeaderboardScore object and the name of the Leaderboard. + * + * If the save fails the event will send `null` as the score value. + * @param score The new score for the player. Must be a 64-bit integer number. + * @param data Metadata to associate with the stored score. Must be less than 2KB in size. If an object is given it will be passed to `JSON.stringify`. + */ + setScore(score: integer, data?: string | any): this; + + /** + * Gets the players leaderboard entry and stores it in the `playerScore` property. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getplayerscore` event along with the score and the name of the Leaderboard. + * + * If the player has not yet saved a score, the event will send `null` as the score value, and `playerScore` will be set to `null` as well. + */ + getPlayerScore(): this; + + /** + * Retrieves a set of leaderboard entries, ordered by score ranking in the leaderboard. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. + * @param count The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. Default 10. + * @param offset The offset from the top of the leaderboard that entries will be fetched from. Default 0. + */ + getScores(count?: integer, offset?: integer): this; + + /** + * Retrieves a set of leaderboard entries, based on the current player's connected players (including the current player), ordered by local rank within the set of connected players. + * + * The data is requested in an async call, so the result isn't available immediately. + * + * When the call completes this Leaderboard will emit the `getconnectedscores` event along with an array of LeaderboardScore entries and the name of the Leaderboard. + * @param count The number of entries to attempt to fetch from the leaderboard. Currently, up to a maximum of 100 entries may be fetched per query. Default 10. + * @param offset The offset from the top of the leaderboard that entries will be fetched from. Default 0. + */ + getConnectedScores(count?: integer, offset?: integer): this; + + } + +} + +declare type LeaderboardScore = { + /** + * An integer score value. + */ + score: integer; + /** + * The score value, formatted with the score format associated with the leaderboard. + */ + scoreFormatted: string; + /** + * The Unix timestamp of when the leaderboard entry was last updated. + */ + timestamp: integer; + /** + * The entry's leaderboard ranking. + */ + rank: integer; + /** + * The developer-specified payload associated with the score, or null if one was not set. + */ + data: string; + /** + * The player's localized display name. + */ + playerName: string; + /** + * A url to the player's public profile photo. + */ + playerPhotoURL: string; + /** + * The game's unique identifier for the player. + */ + playerID: string; +}; + +declare type Product = { + /** + * The title of the product. + */ + title?: string; + /** + * The product's game-specified identifier. + */ + productID?: string; + /** + * The product description. + */ + description?: string; + /** + * A link to the product's associated image. + */ + imageURI?: string; + /** + * The price of the product. + */ + price?: string; + /** + * The currency code for the product. + */ + priceCurrencyCode?: string; +}; + +declare type Purchase = { + /** + * A developer-specified string, provided during the purchase of the product. + */ + developerPayload?: string; + /** + * The identifier for the purchase transaction. + */ + paymentID?: string; + /** + * The product's game-specified identifier. + */ + productID?: string; + /** + * Unix timestamp of when the purchase occurred. + */ + purchaseTime?: string; + /** + * A token representing the purchase that may be used to consume the purchase. + */ + purchaseToken?: string; + /** + * Server-signed encoding of the purchase request. + */ + signedRequest?: string; +}; + declare type integer = number; declare module 'phaser' { diff --git a/src/ui/BaseView.ts b/src/ui/BaseView.ts index 10dd5f7..82090c4 100644 --- a/src/ui/BaseView.ts +++ b/src/ui/BaseView.ts @@ -55,7 +55,7 @@ module TK.SpaceTac.UI { console.log(`Starting scene ${classname(this)}`); this.gameui = this.sys.game; - this.timer = new Timer(this.gameui.headless); + this.timer = new Timer(this.gameui.isTesting); this.animations = new Animations(this.tweens); this.particles = new UIParticles(this); this.inputs = new InputManager(this); @@ -93,8 +93,6 @@ module TK.SpaceTac.UI { this.messages = new Messages(this); this.dialogs_opened = []; - this.resize(); - // Browser console variable (for debugging purpose) if (typeof window != "undefined") { let session = this.gameui.session; @@ -107,20 +105,6 @@ module TK.SpaceTac.UI { } } - resize() { - if (this.gameui) { - if (this.layers) { - this.layers.setScale(this.gameui.scaling); - } - if (this.dialogs_layer) { - this.dialogs_layer.setScale(this.gameui.scaling); - } - if (this.cameras.main) { - this.cameras.main.setViewport(0, 0, 1920 * this.gameui.scaling, 1080 * this.gameui.scaling); - } - } - } - get options() { return this.gameui.options; } diff --git a/src/ui/TestGame.ts b/src/ui/TestGame.ts index 4654337..0f1b8a5 100644 --- a/src/ui/TestGame.ts +++ b/src/ui/TestGame.ts @@ -47,7 +47,7 @@ module TK.SpaceTac.UI.Specs { if (scene instanceof BaseView) { testgame.multistorage = new Multi.FakeRemoteStorage(); let connection = new Multi.Connection(RandomGenerator.global.id(12), testgame.multistorage); - check.patch(scene, "getConnection", () => connection); + check.patch(scene as BaseView, "getConnection", () => connection); } let orig_create = bound(scene, "create"); diff --git a/src/ui/battle/Arena.ts b/src/ui/battle/Arena.ts index 372c4cc..f2d9a1a 100644 --- a/src/ui/battle/Arena.ts +++ b/src/ui/battle/Arena.ts @@ -92,6 +92,7 @@ module TK.SpaceTac.UI { */ setupMouseCapture() { let view = this.view; + let button_down = false; let background = new UIBuilder(view, this.container).image("battle-arena-background"); background.setName("mouse-capture"); @@ -99,8 +100,12 @@ module TK.SpaceTac.UI { // Capture clicks on background background.setInteractive(); + background.on("pointerdown", (pointer: Phaser.Input.Pointer) => { + button_down = (pointer.buttons == 1); + }); background.on("pointerup", (pointer: Phaser.Input.Pointer) => { - if (pointer.buttons == 1) { + if (button_down) { + button_down = false; this.callbacks_click.forEach(callback => callback()); } }); diff --git a/src/ui/battle/LogProcessor.ts b/src/ui/battle/LogProcessor.ts index c67c4a3..74d30a9 100644 --- a/src/ui/battle/LogProcessor.ts +++ b/src/ui/battle/LogProcessor.ts @@ -54,7 +54,7 @@ module TK.SpaceTac.UI { * Start log processing */ start() { - if (!this.view.gameui.headless) { + if (!this.view.gameui.isTesting) { this.log.play(async diff => { while (this.view.isPaused()) { await this.view.timer.sleep(500); diff --git a/src/ui/character/CharacterSheet.spec.ts b/src/ui/character/CharacterSheet.spec.ts index 2d943f9..d2e7eda 100644 --- a/src/ui/character/CharacterSheet.spec.ts +++ b/src/ui/character/CharacterSheet.spec.ts @@ -25,7 +25,8 @@ module TK.SpaceTac.UI.Specs { check.equals(sheet.text_name && sheet.text_name.text, "Ship 1"); let portrait = as(UIButton, sheet.group_portraits.getAt(1)); - portrait.emit("pointerup"); + portrait.emit("pointerdown", { buttons: 1 }); + portrait.emit("pointerup", { buttons: 1 }); check.equals(sheet.text_name && sheet.text_name.text, "Ship 2"); }); diff --git a/src/ui/common/InputManager.ts b/src/ui/common/InputManager.ts index b41100e..d473a0a 100644 --- a/src/ui/common/InputManager.ts +++ b/src/ui/common/InputManager.ts @@ -46,7 +46,7 @@ module TK.SpaceTac.UI { } }); - if (!this.game.headless) { + if (!this.game.isTesting) { this.view.input.keyboard.on("keyup", (event: KeyboardEvent) => { if (this.debug) { console.log(event); @@ -147,6 +147,7 @@ module TK.SpaceTac.UI { let enternext: Function | null = null; let entercalled = false; let cursorinside = false; + let leftbutton = false; let destroyed = false; obj.setDataEnabled(); @@ -234,6 +235,7 @@ module TK.SpaceTac.UI { obj.on("pointerdown", (pointer?: Phaser.Input.Pointer) => { if (destroyed || (pointer && pointer.buttons != 1)) return; + leftbutton = true; if (UITools.isVisible(obj)) { holdstart = Timer.nowMs(); @@ -247,7 +249,8 @@ module TK.SpaceTac.UI { }); obj.on("pointerup", (pointer?: Phaser.Input.Pointer) => { - if (destroyed || (pointer && pointer.buttons != 1)) return; + if (destroyed || !leftbutton) return; + leftbutton = false; if (!cursorinside) { effectiveleave(); diff --git a/src/ui/common/UIBuilder.spec.ts b/src/ui/common/UIBuilder.spec.ts index 53bc66d..b3e49cf 100644 --- a/src/ui/common/UIBuilder.spec.ts +++ b/src/ui/common/UIBuilder.spec.ts @@ -38,7 +38,7 @@ module TK.SpaceTac.UI.Specs { return component; } - function checktext(path: (number | string)[], attrs?: Partial, style?: Partial): UIText { + function checktext(path: (number | string)[], attrs?: Partial, style?: Partial): UIText { let text = checkcomp(path, UIText, "", attrs); if (typeof style != "undefined") { @@ -116,8 +116,8 @@ module TK.SpaceTac.UI.Specs { builder.clear(); builder.text("", 0, 0, {}); builder.text("", 0, 0, { size: 61 }); - checktext(["View layers", "base", 0], undefined, { fontFamily: "16pt SpaceTac" }); - checktext(["View layers", "base", 1], undefined, { fontFamily: "61pt SpaceTac" }); + checktext(["View layers", "base", 0], undefined, { fontFamily: "SpaceTac", fontSize: "16pt" }); + checktext(["View layers", "base", 1], undefined, { fontFamily: "SpaceTac", fontSize: "61pt" }); builder.clear(); builder.text("", 0, 0, {}); @@ -140,8 +140,8 @@ module TK.SpaceTac.UI.Specs { builder.clear(); builder.text("", 0, 0, {}); builder.text("", 0, 0, { bold: true }); - checktext(["View layers", "base", 0], undefined, { fontFamily: "16pt SpaceTac" }); - checktext(["View layers", "base", 1], undefined, { fontFamily: "bold 16pt SpaceTac" }); + checktext(["View layers", "base", 0], undefined, { fontFamily: "SpaceTac", fontSize: "16pt", fontStyle: "" }); + checktext(["View layers", "base", 1], undefined, { fontFamily: "SpaceTac", fontSize: "16pt", fontStyle: "bold" }); builder.clear(); builder.text("", 0, 0, {}); @@ -208,10 +208,10 @@ module TK.SpaceTac.UI.Specs { builder.text("t3"); builder.text("t4", undefined, undefined, { bold: true }); - checktext(["View layers", "base", 0], { text: "t1" }, { fontFamily: "16pt SpaceTac" }); - checktext(["View layers", "base", 1], { text: "t2" }, { fontFamily: "bold 16pt SpaceTac" }); - checktext(["View layers", "base", 2], { text: "t3" }, { fontFamily: "16pt SpaceTac" }); - checktext(["View layers", "base", 3], { text: "t4" }, { fontFamily: "bold 16pt SpaceTac" }); + checktext(["View layers", "base", 0], { text: "t1" }, { fontFamily: "SpaceTac", fontSize: "16pt", fontStyle: "" }); + checktext(["View layers", "base", 1], { text: "t2" }, { fontFamily: "SpaceTac", fontSize: "16pt", fontStyle: "bold" }); + checktext(["View layers", "base", 2], { text: "t3" }, { fontFamily: "SpaceTac", fontSize: "16pt", fontStyle: "" }); + checktext(["View layers", "base", 3], { text: "t4" }, { fontFamily: "SpaceTac", fontSize: "16pt", fontStyle: "bold" }); }) test.case("allows to change text or image content", check => {